Abstraction

This commit is contained in:
Manav Rathi 2024-04-18 14:13:55 +05:30
parent e9e17e6ea3
commit 4fd9ecba56
No known key found for this signature in database
2 changed files with 11 additions and 4 deletions

View file

@ -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(

View file

@ -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(".");