Fix getUid failing when a cache file is deleted
MODIFY
packages/@romejs/core/server/Cache.ts
packages/@romejs/core/server/Cache.ts
@@ -169,7 +169,7 @@ export default class Cache {
}
getCacheFilename(path: AbsoluteFilePath): AbsoluteFilePath {
- const uid = this.server.projectManager.getUid(path);
+ const uid = this.server.projectManager.getUid(path, true);
return this.cachePath.append(uid);
}

MODIFY
packages/@romejs/core/server/project/ProjectManager.ts
packages/@romejs/core/server/project/ProjectManager.ts
@@ -253,11 +253,11 @@ export default class ProjectManager {
this.filenameToUid.set(path, uid);
}
- getUid(path: AbsoluteFilePath): string {
+ getUid(path: AbsoluteFilePath, allowMissing: boolean = false): string {
// We maintain a map of file paths to UIDs
// We clear the UID when a path is deleted.
// If getUid is called on a file that doesn't exist then we'll populate it and it will exist forever.
- if (!this.server.memoryFs.exists(path)) {
+ if (!this.server.memoryFs.exists(path) && !allowMissing) {
throw new FileNotFound(path);
}
@@ -307,7 +307,9 @@ export default class ProjectManager {
}
const uid = cleanUidParts(parts);
+ if (!allowMissing) {
this.setUid(path, uid);
+ }
return uid;
}

Fix getUid failing when a cache file is deleted