mirror of
https://github.com/vrtmrz/obsidian-livesync.git
synced 2026-11-15 12:40:12 +00:00
fix: synchronise case-only file renames safely
This commit is contained in:
1 parent
ba7ea27d0c
commit
869a893c19
362 files changed
+722
-380
No files matched your search
@@ -53,9 +53,11 @@ export class FSAPIFileSystemAdapter implements IFileSystemAdapter<FSAPIFile, FSA
|
||||
// Navigate to the parent directory
|
||||
for (let i = 0; i < parts.length - 1; i++) {
|
||||
currentHandle = await currentHandle.getDirectoryHandle(parts[i]);
|
||||
if (currentHandle.name !== parts[i]) return null;
|
||||
}
|
||||
|
||||
const fileHandle = await currentHandle.getFileHandle(fileName);
|
||||
if (fileHandle.name !== fileName) return null;
|
||||
this.handleCache.set(pathStr, fileHandle);
|
||||
return fileHandle;
|
||||
} catch {
|
||||
@@ -110,6 +112,14 @@ export class FSAPIFileSystemAdapter implements IFileSystemAdapter<FSAPIFile, FSA
|
||||
return Array.from(this.fileCache.values());
|
||||
}
|
||||
|
||||
async renameFile(file: FSAPIFile, newPath: string): Promise<FSAPIFile> {
|
||||
await this.vault.rename(file, newPath);
|
||||
this.clearCache();
|
||||
const renamedFile = await this.refreshFile(newPath);
|
||||
if (!renamedFile) throw new Error(`Could not find renamed file: ${newPath}`);
|
||||
return renamedFile;
|
||||
}
|
||||
|
||||
async statFromNative(file: FSAPIFile): Promise<UXStat> {
|
||||
// Refresh stat from the file handle
|
||||
try {
|
||||
|
||||
Reference in new issue
Block a user