minor refactoring
This commit is contained in:
parent
3dcf337f6c
commit
05faaeb0c9
|
@ -2,7 +2,10 @@ import { EnteFile } from 'types/file';
|
|||
import { handleUploadError, CustomError } from 'utils/error';
|
||||
import { decryptFile } from 'utils/file';
|
||||
import { logError } from 'utils/sentry';
|
||||
import { fileAlreadyInCollection } from 'utils/upload';
|
||||
import {
|
||||
fileAlreadyInCollection,
|
||||
shouldDedupleAcrossCollection,
|
||||
} from 'utils/upload';
|
||||
import UploadHttpClient from './uploadHttpClient';
|
||||
import UIService from './uiService';
|
||||
import UploadService from './uploadService';
|
||||
|
@ -53,11 +56,12 @@ export default async function uploader(
|
|||
// This change allow users to export by albums, upload to ente. And export all photos -> upload files which are not already uploaded
|
||||
// as part of the albums
|
||||
if (
|
||||
(fileWithCollection.collection?.name ?? '') ===
|
||||
'iCloud Photos Dedupe' &&
|
||||
shouldDedupleAcrossCollection(
|
||||
fileWithCollection.collection?.name
|
||||
) &&
|
||||
fileAlreadyInCollection(existingFiles, metadata)
|
||||
) {
|
||||
logUploadInfo(`skipped upload for ${fileNameSize}`);
|
||||
logUploadInfo(`deduped upload for ${fileNameSize}`);
|
||||
return { fileUploadResult: FileUploadResults.ALREADY_UPLOADED };
|
||||
}
|
||||
logUploadInfo(`reading asset ${fileNameSize}`);
|
||||
|
|
|
@ -5,6 +5,7 @@ import { formatDateTime } from 'utils/file';
|
|||
import { getLogs, saveLogLine } from 'utils/storage';
|
||||
|
||||
const TYPE_JSON = 'json';
|
||||
const DEDUPE_COLLECTION = new Set(['icloud library', 'icloudlibrary']);
|
||||
|
||||
export function fileAlreadyInCollection(
|
||||
existingFilesInCollection: EnteFile[],
|
||||
|
@ -17,6 +18,14 @@ export function fileAlreadyInCollection(
|
|||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
export function shouldDedupleAcrossCollection(
|
||||
collectionName?: string
|
||||
): boolean {
|
||||
// using set to avoid unncessary regex for removing spaces for each upload
|
||||
return DEDUPE_COLLECTION.has((collectionName ?? '').toLocaleLowerCase());
|
||||
}
|
||||
|
||||
export function areFilesSame(
|
||||
existingFile: Metadata,
|
||||
newFile: Metadata
|
||||
|
|
Loading…
Reference in a new issue