From ca0ee2dcded71e69c95b23684e5dc101ad0fb9c3 Mon Sep 17 00:00:00 2001 From: Spoffy <4805393+Spoffy@users.noreply.github.com> Date: Tue, 14 Jan 2025 04:27:13 +0000 Subject: [PATCH] Improves several checks Co-authored-by: Florent --- app/server/lib/AttachmentFileManager.ts | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/app/server/lib/AttachmentFileManager.ts b/app/server/lib/AttachmentFileManager.ts index 0b6e97e308..eeb54c9fe1 100644 --- a/app/server/lib/AttachmentFileManager.ts +++ b/app/server/lib/AttachmentFileManager.ts @@ -53,7 +53,7 @@ export class AttachmentRetrievalError extends Error { constructor(storeId: AttachmentStoreId | null, fileId: string, cause?: any) { const causeError = cause instanceof Error ? cause : undefined; const reason = (causeError ? causeError.message : cause) ?? ""; - const storeName = storeId? `'${storeId}'` : "internal storage"; + const storeName = storeId ? `'${storeId}'` : "internal storage"; super(`Unable to retrieve '${fileId}' from ${storeName} ${reason}`); this.storeId = storeId; this.fileId = fileId; @@ -178,7 +178,7 @@ export class AttachmentFileManager implements IAttachmentFileManager { } const fileIdents = filesToTransfer.map(file => file.ident); - for(const fileIdent of fileIdents) { + for (const fileIdent of fileIdents) { this.startTransferringFileToOtherStore(fileIdent, newStoreId); } } @@ -250,7 +250,7 @@ export class AttachmentFileManager implements IAttachmentFileManager { } private _runTransferJob(): TransferJob { - if (this._transferJob && !this._transferJob.isFinished) { + if (this.transferStatus().isRunning) { return this._transferJob; } const transferPromise = this._performPendingTransfers(); @@ -278,7 +278,7 @@ export class AttachmentFileManager implements IAttachmentFileManager { } finally { // If a transfer request comes in mid-transfer, it will need re-running. - if (this._pendingFileTransfers.get(fileIdent) == targetStoreId) { + if (this._pendingFileTransfers.get(fileIdent) === targetStoreId) { this._pendingFileTransfers.delete(fileIdent); } } @@ -305,7 +305,7 @@ export class AttachmentFileManager implements IAttachmentFileManager { } const fileInfoNoData = await this._docStorage.getFileInfo(fileIdent, false); - const fileExists = fileInfoNoData != null; + const fileExists = fileInfoNoData !== null; if (fileExists) { const isFileInTargetStore = isExternal ?