Repository navigation
Commit ad69f7b
committed
[flutter_tools] Materialize directory listing before deleting stale native assets
Restores `.toList()` on `targetDir.list(followLinks: false)` in `_copyNativeCodeAssetsForOS` so directory enumeration completes before deleting stale entries in `targetDir`, avoiding concurrent directory stream mutation issues on Windows and network filesystems.
Reproduction notes: Both output pairs below were captured on a Linux host, which cannot reproduce the macOS external-volume behavior directly. The first pair comes from a small Dart script (`repro_exdev.dart`) calling `ErrorHandlingFileSystem.file(...).renameSync(...)` from `/tmp` (`tmpfs`) to an `ext4` directory to trigger a real kernel `EXDEV` (`errno = 18`). The second pair comes from running `BOT=true flutter test --no-pub -r expanded` on a minimal app after making `build/native_assets/linux` read-only (`chmod 0555`) while leaving `native_assets.json` writable (`0644`), so `unlink(2)` fails while in-place truncation succeeds; with a writable `build/native_assets/linux` directory, the unfixed tool passes with the same 3-line test output. Local workspace paths inside the fenced output blocks are preserved verbatim to match exact command output.
Previous output:
```
Unhandled exception:
FileSystemException: Cannot rename file to '/usr/local/google/home/bkonyi/.gemini/jetski/brain/0a669702-1e2d-46a6-9c37-fdc4d2ca98a9/scratch/repro_196121_dst.tmp', path = '/tmp/repro_196121_src.tmp' (OS Error: Invalid cross-device link, errno = 18)
#0 _File.throwIfError (dart:io/file_impl.dart:779:7)
#1 _File.renameSync (dart:io/file_impl.dart:396:5)
#2 ForwardingFileSystemEntity.renameSync (package:file/src/forwarding/forwarding_file_system_entity.dart:50:49)
#3 ErrorHandlingFile.renameSync.<anonymous closure> (package:flutter_tools/src/base/error_handling_io.dart:430:31)
#4 _runSync (package:flutter_tools/src/base/error_handling_io.dart:1116:16)
#5 ErrorHandlingFile.renameSync (package:flutter_tools/src/base/error_handling_io.dart:429:12)
#6 main (file:///usr/local/google/home/bkonyi/.gemini/jetski/brain/0a669702-1e2d-46a6-9c37-fdc4d2ca98a9/scratch/repro_exdev.dart:24:37)
flutter#7 _delayEntrypointInvocation.<anonymous closure> (dart:isolate-patch/isolate_patch.dart:313:19)
flutter#8 _RawReceivePort._handleMessage (dart:isolate-patch/isolate_patch.dart:192:12)
```
Current output:
```
Flutter failed to rename file at "/tmp/repro_196121_src.tmp" to "/usr/local/google/home/bkonyi/.gemini/jetski/brain/0a669702-1e2d-46a6-9c37-fdc4d2ca98a9/scratch/repro_196121_dst.tmp".
A file system operation failed across different volumes or mount points.
FileSystemException: Cannot rename file to '/usr/local/google/home/bkonyi/.gemini/jetski/brain/0a669702-1e2d-46a6-9c37-fdc4d2ca98a9/scratch/repro_196121_dst.tmp', path = '/tmp/repro_196121_src.tmp' (OS Error: Invalid cross-device link, errno = 18)
Ensure that the project, build output, and temporary directories are on the same writable volume, or check external volume and security software settings.
```
Previous output (flutter test overwriting existing native_assets.json):
```
Flutter failed to delete file at
"/usr/local/google/home/bkonyi/.gemini/jetski/brain/0a669702-1e2d-46a6-9c37-fdc4
d2ca98a9/scratch/repro_app/build/native_assets/linux/native_assets.json".
Please ensure that the SDK and/or project is installed in a location that has
read/write permissions for the current user.
Try running:
sudo chown -R $(whoami)
/usr/local/google/home/bkonyi/.gemini/jetski/brain/0a669702-1e2d-46a6-9c37-fdc
4d2ca98a9/scratch/repro_app/build/native_assets/linux/native_assets.json
```
Current output (flutter test overwriting existing native_assets.json):
```
00:00 +0: loading /usr/local/google/home/bkonyi/.gemini/jetski/brain/0a669702-1e2d-46a6-9c37-fdc4d2ca98a9/scratch/repro_app/test/smoke_test.dart
00:00 +0: smoke test
00:00 +1: All tests passed!
```
Fixes flutter#1961211 parent e8ecaf8 commit ad69f7b
1 file changed
Lines changed: 1 addition & 1 deletion
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
831 | 831 | | |
832 | 832 | | |
833 | 833 | | |
834 | | - | |
| 834 | + | |
835 | 835 | | |
836 | 836 | | |
837 | 837 | | |
| |||
0 commit comments