mirror of
https://github.com/moltbot/moltbot.git
synced 2026-05-13 15:47:28 +00:00
fix(memory): preserve ENOTDIR missing reads
Signed-off-by: samzong <samzong.lu@gmail.com>
This commit is contained in:
committed by
Peter Steinberger
parent
c6748a8eeb
commit
5ad3fa0a17
@@ -18,12 +18,13 @@ if (!hasPythonModeOverride) {
|
||||
|
||||
export function isFileMissingError(
|
||||
err: unknown,
|
||||
): err is NodeJS.ErrnoException & { code: "ENOENT" } {
|
||||
): err is NodeJS.ErrnoException & { code: "ENOENT" | "ENOTDIR" | "not-found" } {
|
||||
return Boolean(
|
||||
err &&
|
||||
typeof err === "object" &&
|
||||
"code" in err &&
|
||||
((err as Partial<NodeJS.ErrnoException>).code === "ENOENT" ||
|
||||
(err as Partial<NodeJS.ErrnoException>).code === "ENOTDIR" ||
|
||||
(err as { code?: unknown }).code === "not-found"),
|
||||
);
|
||||
}
|
||||
|
||||
@@ -37,6 +37,19 @@ describe("readMemoryFile", () => {
|
||||
text: "",
|
||||
path: path.relative(workspaceDir, missingPath).replace(/\\/g, "/"),
|
||||
});
|
||||
|
||||
const nonDirectoryParentPath = path.join(extraDir, "note.md", "child.md");
|
||||
await fs.writeFile(path.join(extraDir, "note.md"), "note", "utf-8");
|
||||
await expect(
|
||||
readMemoryFile({
|
||||
workspaceDir,
|
||||
extraPaths: [extraDir],
|
||||
relPath: nonDirectoryParentPath,
|
||||
}),
|
||||
).resolves.toEqual({
|
||||
text: "",
|
||||
path: path.relative(workspaceDir, nonDirectoryParentPath).replace(/\\/g, "/"),
|
||||
});
|
||||
} finally {
|
||||
await fs.rm(tmpRoot, { recursive: true, force: true });
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user