diff --git a/web/apps/photos/src/services/watchFolder/watchFolderService.ts b/web/apps/photos/src/services/watchFolder/watchFolderService.ts index 386b3efa6..e039eb3de 100644 --- a/web/apps/photos/src/services/watchFolder/watchFolderService.ts +++ b/web/apps/photos/src/services/watchFolder/watchFolderService.ts @@ -12,7 +12,7 @@ import { WatchMappingSyncedFile, } from "types/watchFolder"; import { groupFilesBasedOnCollectionID } from "utils/file"; -import { getValidFilesToUpload } from "utils/watch"; +import { isSystemFile } from "utils/upload"; import { removeFromCollection } from "../collectionService"; import { getLocalFiles } from "../fileService"; @@ -713,3 +713,26 @@ async function diskFolderRemovedCallback(folderPath: string) { log.error("error while calling diskFolderRemovedCallback", e); } } + +export function getValidFilesToUpload( + files: ElectronFile[], + mapping: WatchMapping, +) { + const uniqueFilePaths = new Set(); + return files.filter((file) => { + if (!isSystemFile(file) && !isSyncedOrIgnoredFile(file, mapping)) { + if (!uniqueFilePaths.has(file.path)) { + uniqueFilePaths.add(file.path); + return true; + } + } + return false; + }); +} + +function isSyncedOrIgnoredFile(file: ElectronFile, mapping: WatchMapping) { + return ( + mapping.ignoredFiles.includes(file.path) || + mapping.syncedFiles.find((f) => f.path === file.path) + ); +} diff --git a/web/apps/photos/src/utils/watch/index.ts b/web/apps/photos/src/utils/watch/index.ts deleted file mode 100644 index eb16780dd..000000000 --- a/web/apps/photos/src/utils/watch/index.ts +++ /dev/null @@ -1,26 +0,0 @@ -import { ElectronFile } from "types/upload"; -import { WatchMapping } from "types/watchFolder"; -import { isSystemFile } from "utils/upload"; - -function isSyncedOrIgnoredFile(file: ElectronFile, mapping: WatchMapping) { - return ( - mapping.ignoredFiles.includes(file.path) || - mapping.syncedFiles.find((f) => f.path === file.path) - ); -} - -export function getValidFilesToUpload( - files: ElectronFile[], - mapping: WatchMapping, -) { - const uniqueFilePaths = new Set(); - return files.filter((file) => { - if (!isSystemFile(file) && !isSyncedOrIgnoredFile(file, mapping)) { - if (!uniqueFilePaths.has(file.path)) { - uniqueFilePaths.add(file.path); - return true; - } - } - return false; - }); -}