The ultimate harness for coding agents and beyond. All your agents. All your machines. One command center. Start with code, then follow your curiosity and build across disciplines: CAD, circuits, robots, games and music.
TypeScript 3d-modelingagent-frameworkagent-harnessai-agentscadclaude-codecodexcoding-agentsdeveloper-toolsesp32game-developmentmcp-servermulti-agentopen-hardwareopencodeopenharnesspcbroboticsterminaltmux
fix(mobile): tolerate vanished attachment test folders (outside PR #2401) (#2408)
0xken15b6af08181afd
diff --git a/mobile/test/swarm/swarm_attachment_fakes.dart b/mobile/test/swarm/swarm_attachment_fakes.dartindex 3e8a610fc..1a04582b5 100644--- a/mobile/test/swarm/swarm_attachment_fakes.dart+++ b/mobile/test/swarm/swarm_attachment_fakes.dart@@ -89,12 +89,31 @@ SwarmAttachmentStore storeIn(io.Directory root, FileService storage) =>);/// The files kept under [root], by their path below it.-List<String> keptUnder(io.Directory root) => !root.existsSync()- ? const []- : [- for (final entry in root.listSync(recursive: true))- if (entry is io.File) entry.path.substring(root.path.length + 1),- ];+List<String> keptUnder(io.Directory root) {+ if (!root.existsSync()) return const [];++ final pending = <io.Directory>[root];+ final files = <String>[];+ while (pending.isNotEmpty) {+ final directory = pending.removeLast();+ late final List<io.FileSystemEntity> entries;+ try {+ entries = directory.listSync();+ } on io.PathNotFoundException {+ // The keeper deletes asynchronously. One subtree may disappear after its+ // parent was listed; ignore only that vanished subtree and keep scanning.+ continue;+ }+ for (final entry in entries) {+ if (entry is io.Directory) {+ pending.add(entry);+ } else if (entry is io.File) {+ files.add(entry.path.substring(root.path.length + 1));+ }+ }+ }+ return files;+}/// The one account folder under [root] made read-only, so what is in it/// cannot be deleted, as a phone can refuse; returns the undo, which thediff --git a/mobile/test/swarm/swarm_attachment_keeper_test.dart b/mobile/test/swarm/swarm_attachment_keeper_test.dartindex 17d27b47d..624359db4 100644--- a/mobile/test/swarm/swarm_attachment_keeper_test.dart+++ b/mobile/test/swarm/swarm_attachment_keeper_test.dart@@ -72,6 +72,16 @@ void main() {return keeper;}+ test('a folder removed during the walk does not hide kept sibling files', () {+ final survivor = File('${root.path}${Platform.pathSeparator}survivor.txt')+ ..writeAsStringSync('kept');+ final vanished = Directory('${root.path}${Platform.pathSeparator}vanished');++ expect(keptUnder(_ListingDirectory(root.path, [vanished, survivor])), [+ 'survivor.txt',+ ]);+ });+test('sign-out empties them', () async {await keeping();@@ -190,6 +200,37 @@ void main() {});}+/// Returns a stable parent listing while a real child directory is already+/// gone, reproducing the race between listing a parent and walking its child.+class _ListingDirectory implements Directory {+ _ListingDirectory(this.path, this.entries);++ @override+ final String path;+ final List<FileSystemEntity> entries;++ @override+ bool existsSync() => true;++ @override+ List<FileSystemEntity> listSync({+ bool recursive = false,+ bool followLinks = true,+ }) {+ final listed = <FileSystemEntity>[];+ for (final entry in entries) {+ listed.add(entry);+ if (recursive && entry is Directory) {+ listed.addAll(entry.listSync(recursive: true, followLinks: followLinks));+ }+ }+ return listed;+ }++ @override+ dynamic noSuchMethod(Invocation invocation) => super.noSuchMethod(invocation);+}+class _Log implements AppLog {final failures = <String>[];