File tree 1 file changed +10
-1
lines changed
pkgs/native_assets_cli/lib/src/locking 1 file changed +10
-1
lines changed Original file line number Diff line number Diff line change @@ -25,7 +25,7 @@ Future<T> runUnderDirectoryLock<T>(
25
25
Logger ? logger,
26
26
}) async {
27
27
const lockFileName = '.lock' ;
28
- final lockFile = File . fromUri (directory.uri. resolve ( lockFileName) );
28
+ final lockFile = _fileInDir (directory, lockFileName);
29
29
return _runUnderFileLock (
30
30
lockFile,
31
31
callback,
@@ -34,6 +34,13 @@ Future<T> runUnderDirectoryLock<T>(
34
34
);
35
35
}
36
36
37
+ File _fileInDir (Directory path, String filename) {
38
+ final dirPath = path.path;
39
+ var separator = Platform .pathSeparator;
40
+ if (dirPath.endsWith (separator)) separator = '' ;
41
+ return File ('$dirPath $separator $filename ' );
42
+ }
43
+
37
44
/// Run [callback] with this Dart process having exclusive access to [file] .
38
45
///
39
46
/// Note multiple isolates and isolate groups in the same Dart process share
@@ -73,6 +80,8 @@ Future<T> _runUnderFileLock<T>(
73
80
);
74
81
printed = true ;
75
82
}
83
+ // Don't busy wait, give the CPU some rest.
84
+ // Magic constant taken from flutter_tools for startup lock.
76
85
await Future <void >.delayed (const Duration (milliseconds: 50 ));
77
86
}
78
87
}
You can’t perform that action at this time.
0 commit comments