upleb.uk

Public git repos — served from a NIP-34 GRASP relay at git.upleb.uk

summaryrefslogtreecommitdiff
path: root/runtime/shims/file_system.cpp
diff options
context:
space:
mode:
authorezbyDev <198480541+ezbyDev@users.noreply.github.com>2026-11-23 00:57:49 +0100
committerezbyDev <198480541+ezbyDev@users.noreply.github.com>2026-11-23 00:57:49 +0100
commitf09f1b26e43d6858b70810a3d08365104e911d2d (patch)
tree1d728aabbae1e302caaf3db51606e6e418618987 /runtime/shims/file_system.cpp
parentc49b5ec65fbdb315fc760da6256cafebf4325fb1 (diff)
file_system: a missing kRemovedDirMarker is not a marker error (RT-257)
Review on #3955 (@pedro470): a delete one folder down leaves a marker folder without kRemovedDirMarker, and is_regular_file() on the missing sentinel returned false with an error code set. collect() took that for an unreadable marker and asked deleted() about every package entry: 16,000 files after GAME:\d\nested\gone.txt was deleted listed in 1,391 ms instead of 27 ms. The sentinel is now checked with status(): regular means the folder was removed, not_found is the ordinary "holds nested markers" answer, and only another error falls back to deleted(). Same entries either way. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Diffstat (limited to 'runtime/shims/file_system.cpp')
-rw-r--r--runtime/shims/file_system.cpp14
1 files changed, 10 insertions, 4 deletions
diff --git a/runtime/shims/file_system.cpp b/runtime/shims/file_system.cpp
index d6f8df877..fbae1faba 100644
--- a/runtime/shims/file_system.cpp
+++ b/runtime/shims/file_system.cpp
@@ -512,11 +512,17 @@ bool collect(const std::wstring& pattern, const std::vector<std::wstring>& parts
512 markers_exact = false; 512 markers_exact = false;
513 continue; 513 continue;
514 } 514 }
515 std::error_code ec; 515 if (!(m.dwFileAttributes & FILE_ATTRIBUTE_DIRECTORY)) {
516 const bool dir = (m.dwFileAttributes & FILE_ATTRIBUTE_DIRECTORY) != 0;
517 if (!dir || std::filesystem::is_regular_file(marks / m.cFileName / kRemovedDirMarker, ec))
518 deleted_here.insert(ascii_key(m.cFileName)); 516 deleted_here.insert(ascii_key(m.cFileName));
519 if (ec) markers_exact = false; // the folder's marker could not be checked: ask deleted() per entry 517 continue;
518 }
519 // A marker folder is a removed folder only with kRemovedDirMarker in it; without one it just holds the
520 // markers of a nested delete. A missing sentinel is that ordinary answer (status() reports not_found
521 // with an error code set); any other error leaves the decision to deleted() per entry.
522 std::error_code ec;
523 const auto st = std::filesystem::status(marks / m.cFileName / kRemovedDirMarker, ec);
524 if (st.type() == std::filesystem::file_type::regular) deleted_here.insert(ascii_key(m.cFileName));
525 else if (st.type() != std::filesystem::file_type::not_found && ec) markers_exact = false;
520 } while (::FindNextFileW(mh, &m)); 526 } while (::FindNextFileW(mh, &m));
521 if (::GetLastError() != ERROR_NO_MORE_FILES) markers_exact = false; // an incomplete scan 527 if (::GetLastError() != ERROR_NO_MORE_FILES) markers_exact = false; // an incomplete scan
522 ::FindClose(mh); 528 ::FindClose(mh);