diff --git a/src/lib b/src/lib index 6972cf4..6c2a72d 160000 --- a/src/lib +++ b/src/lib @@ -1 +1 @@ -Subproject commit 6972cf45b3e60e04d52e1185c3c5451c8ccb8aa5 +Subproject commit 6c2a72d9cc4d467cf6f3dab75f04e54782db0373 diff --git a/src/modules/core/ModuleFileHandler.ts b/src/modules/core/ModuleFileHandler.ts index ca48540..909b670 100644 --- a/src/modules/core/ModuleFileHandler.ts +++ b/src/modules/core/ModuleFileHandler.ts @@ -94,10 +94,14 @@ export class ModuleFileHandler extends AbstractModule { let readFile: UXFileInfo | undefined = undefined; if (!shouldApplied) { readFile = await this.readFileFromStub(file); + if (!readFile) { + this._log(`File ${file.path} is not exist on the storage`, LOG_LEVEL_NOTICE); + return false; + } if (await isDocContentSame(getDocDataAsArray(entry.data), readFile.body)) { // Timestamp is different but the content is same. therefore, two timestamps should be handled as same. // So, mark the changes are same. - markChangesAreSame(file, file.stat.mtime, entry.mtime); + markChangesAreSame(readFile, readFile.stat.mtime, entry.mtime); } else { shouldApplied = true; } diff --git a/src/modules/coreObsidian/ModuleFileAccessObsidian.ts b/src/modules/coreObsidian/ModuleFileAccessObsidian.ts index b884c09..75f1469 100644 --- a/src/modules/coreObsidian/ModuleFileAccessObsidian.ts +++ b/src/modules/coreObsidian/ModuleFileAccessObsidian.ts @@ -222,6 +222,7 @@ export class ModuleFileAccessObsidian extends AbstractObsidianModule implements return null; } } + async readStubContent(stub: UXFileInfoStub): Promise { const file = this.vaultAccess.getAbstractFileByPath(stub.path); if (!(file instanceof TFile)) { @@ -231,6 +232,7 @@ export class ModuleFileAccessObsidian extends AbstractObsidianModule implements const data = await this.vaultAccess.vaultReadAuto(file); return { ...stub, + ...TFileToUXFileInfoStub(file), body: createBlob(data), }; } diff --git a/src/modules/coreObsidian/storageLib/StorageEventManager.ts b/src/modules/coreObsidian/storageLib/StorageEventManager.ts index ab977a7..5f7f327 100644 --- a/src/modules/coreObsidian/storageLib/StorageEventManager.ts +++ b/src/modules/coreObsidian/storageLib/StorageEventManager.ts @@ -295,7 +295,7 @@ export class StorageEventManagerObsidian extends StorageEventManager { concurrentProcessing = Semaphore(5); waitedSince = new Map(); async startStandingBy(filename: FilePath) { - // If waited, cancel previous waiting. + // If waited, no need to start again (looping inside the function) await skipIfDuplicated(`storage-event-manager-${filename}`, async () => { Logger(`Processing ${filename}: Starting`, LOG_LEVEL_DEBUG); const release = await this.concurrentProcessing.acquire(); @@ -315,6 +315,7 @@ export class StorageEventManagerObsidian extends StorageEventManager { // continue; // } const type = target.type; + // If already cancelled by other operation, skip this. if (target.cancelled) { Logger(`Processing ${filename}: Cancelled (scheduled): ${operationType}`, LOG_LEVEL_DEBUG); this.cancelStandingBy(target);