Double check before delete

This commit is contained in:
Andras Schmelczer 2025-01-19 13:00:07 +00:00
commit b4b4680422
No known key found for this signature in database
GPG key ID: FC8F2C3D3D1A718C

View file

@ -39,6 +39,11 @@ export class ObsidianFileOperations implements FileOperations {
return new Date((await this.statFile(path)).mtime);
}
public async exists(path: RelativePath): Promise<boolean> {
Logger.getInstance().debug(`Checking existance of ${path}`);
return this.vault.adapter.exists(normalizePath(path));
}
public async create(
path: RelativePath,
newContent: Uint8Array
@ -108,7 +113,7 @@ export class ObsidianFileOperations implements FileOperations {
public async remove(path: RelativePath): Promise<void> {
Logger.getInstance().debug(`Removing file: ${path}`);
if (await this.vault.adapter.exists(normalizePath(path))) {
return this.vault.adapter.remove(normalizePath(path));
await this.vault.adapter.trashSystem(normalizePath(path));
}
}