This commit is contained in:
Andras Schmelczer 2025-11-23 20:27:16 +00:00
parent 4b195b070d
commit 18be9f4dd8
19 changed files with 301 additions and 226 deletions

View file

@ -25,7 +25,7 @@ export class FileOperations {
): [RelativePath, RelativePath] {
const pathParts = path.split("/");
const fileName = pathParts.pop();
if (!fileName || fileName === "") {
if (fileName == null || fileName === "") {
throw new Error(`Path '${path}' cannot be empty`);
}
@ -166,6 +166,10 @@ export class FileOperations {
await this.deletingEmptyParentDirectoriesOfDeletedFile(oldPath);
}
public reset(): void {
this.fs.reset();
}
private async deletingEmptyParentDirectoriesOfDeletedFile(
path: RelativePath
): Promise<void> {
@ -254,8 +258,4 @@ export class FileOperations {
return newName;
}
public reset(): void {
this.fs.reset();
}
}

View file

@ -105,6 +105,10 @@ export class SafeFileSystemOperations implements FileSystemOperations {
);
}
public reset(): void {
this.locks.reset();
}
/**
* Decorate an operation to ensure that the file exists before running it.
* If the operation fails, it will check if the file still exists and throw
@ -138,8 +142,4 @@ export class SafeFileSystemOperations implements FileSystemOperations {
}
}
}
public reset(): void {
this.locks.reset();
}
}