diff --git a/web/apps/photos/src/services/watch.ts b/web/apps/photos/src/services/watch.ts index 1d581b701..3c9f79eea 100644 --- a/web/apps/photos/src/services/watch.ts +++ b/web/apps/photos/src/services/watch.ts @@ -4,7 +4,6 @@ */ import { ensureElectron } from "@/next/electron"; -import { nameAndExtension } from "@/next/file"; import log from "@/next/log"; import type { CollectionMapping, @@ -18,7 +17,7 @@ import { Collection } from "types/collection"; import { EncryptedEnteFile } from "types/file"; import { ElectronFile, FileWithCollection } from "types/upload"; import { groupFilesBasedOnCollectionID } from "utils/file"; -import { isSystemFile } from "utils/upload"; +import { isHiddenFile, isSystemFile } from "utils/upload"; import { removeFromCollection } from "./collectionService"; import { getLocalFiles } from "./fileService"; @@ -711,7 +710,7 @@ const deduceEvents = async ( const paths = (await electron.watch.findFiles(folderPath)) // Filter out hidden files (files whose names begins with a dot) - .filter((path) => !nameAndExtension(path)[0].startsWith(".")); + .filter((path) => !isHiddenFile(path)); // Files that are on disk but not yet synced. const pathsToUpload = paths.filter( diff --git a/web/apps/photos/src/utils/upload/index.ts b/web/apps/photos/src/utils/upload/index.ts index 0f3ceb684..ca4f5fb22 100644 --- a/web/apps/photos/src/utils/upload/index.ts +++ b/web/apps/photos/src/utils/upload/index.ts @@ -1,4 +1,4 @@ -import { directoryNameFromPOSIXPath } from "@/next/file"; +import { directoryNameFromPOSIXPath, fileNameFromPOSIXPath } from "@/next/file"; import { FILE_TYPE } from "constants/file"; import { A_SEC_IN_MICROSECONDS, @@ -219,3 +219,11 @@ export function filterOutSystemFiles(files: File[] | ElectronFile[]) { export function isSystemFile(file: File | ElectronFile) { return file.name.startsWith("."); } + +/** + * Return true if the file at the given {@link path} is hidden. + * + * Hidden files are those whose names begin with a "." (dot). + */ +export const isHiddenFile = (path: string) => + fileNameFromPOSIXPath(path).startsWith(".");