Simplify hash steps

This commit is contained in:
smitten 2023-12-31 11:14:41 -05:00
parent 327694d4cf
commit 8d6d5923da
No known key found for this signature in database
GPG key ID: 1DDD22F13552A07A

View file

@ -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 });