Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 8 additions & 5 deletions src/startup_stubs/cache_index.h
Original file line number Diff line number Diff line change
Expand Up @@ -9,10 +9,12 @@
//
// CacheDirectoryIndex lists one directory once, at its first lookup (std::call_once; FindFirstFileExW on
// "<directory>\*", files only, so names in subdirectories are not indexed). A lookup answers present, absent or
// unknown. unknown means "look on disk": the listing failed (any error but ERROR_FILE_NOT_FOUND, including a
// missing directory), or the lookup names a directory other than the listed one. A file that another process
// creates after the listing reads absent until the next process starts. add() records the caller's own writes, and
// count_contradiction() counts a write that found a file the index had reported absent.
// unknown. unknown means "look on disk": the listing failed (any error, including a missing directory), or the
// lookup names a directory other than the listed one. An empty directory lists empty, through its "." and ".."
// entries; a directory with no entry at all, such as an empty volume root, fails with ERROR_FILE_NOT_FOUND and so
// uses the disk, as the stand-in did before the index. A file that another process creates after the listing reads
// absent until the next process starts. add() records the caller's own writes, and count_contradiction() counts a
// write that found a file the index had reported absent.
#pragma once

#include <algorithm>
Expand Down Expand Up @@ -159,8 +161,9 @@ class CacheDirectoryIndex {
const HANDLE find = FindFirstFileExW(mask.c_str(), FindExInfoBasic, &found, FindExSearchNameMatch, nullptr,
FIND_FIRST_EX_LARGE_FETCH);
if (find == INVALID_HANDLE_VALUE) {
// Every failure leaves the index unusable, ERROR_FILE_NOT_FOUND (no entry at all, not even "." or
// "..", as in an empty volume root) included: its lookups use the disk.
error = GetLastError();
if (error == ERROR_FILE_NOT_FOUND) error = ERROR_SUCCESS; // no entry at all: an empty listing
} else {
try {
do {
Expand Down
2 changes: 1 addition & 1 deletion tests/startup_cache_index_check.cpp
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
// Checks src/startup_stubs/cache_index.h without a device. prepare_native_mesh57 asks the index before it opens
// <variant>.mesh57-state, and opens the file only for present or unknown. The cache directory holds 2000 other
// cache files, names that look like profiles, a subdirectory and a directory with a profile's name.
// (a) 514 lookups of missing profiles probe the disk 0 times; (b) present profiles, any ASCII case, are read;
// (a) 515 lookups of missing profiles probe the disk 0 times; (b) present profiles, any ASCII case, are read;
// (c) one listing of the top-level files only; (d) other directories and subdirectories: unknown;
// (e) add() and the contradiction counter; (f) an empty directory lists empty, a missing one
// is unknown; (g) concurrent first lookups list once and agree; (h) the name hash and the sorted set.
Expand Down
Loading