From 8d6d5923daff95b484a4d9ad92d0c43e6ac9ec96 Mon Sep 17 00:00:00 2001 From: smitten Date: Sun, 31 Dec 2023 11:14:41 -0500 Subject: [PATCH] Simplify hash steps --- .../src/queue/processors/ImportNotesProcessorService.ts | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/packages/backend/src/queue/processors/ImportNotesProcessorService.ts b/packages/backend/src/queue/processors/ImportNotesProcessorService.ts index 40aa7ffc18..a49e0d4dde 100644 --- a/packages/backend/src/queue/processors/ImportNotesProcessorService.ts +++ b/packages/backend/src/queue/processors/ImportNotesProcessorService.ts @@ -471,9 +471,8 @@ export class ImportNotesProcessorService { for await (const file of post.object.attachment) { const slashdex = file.url.lastIndexOf('/'); const filename = file.url.substring(slashdex + 1); - const hash = crypto.createHash('md5'); - const urlHash = hash.update(file.url).digest('base64url'); - const name = `${urlHash}-${filename}`; + const hash = crypto.createHash('md5').update(file.url).digest('base64url'); + const name = `${hash}-${filename}`; const [filePath, cleanup] = await createTemp(); const exists = await this.driveFilesRepository.findOneBy({ name: name, userId: user.id }) ?? await this.driveFilesRepository.findOneBy({ name: name, userId: user.id, folderId: pleroFolder?.id });