From 7a3da0d3df66deca2651031dc0f29d49990a818b Mon Sep 17 00:00:00 2001 From: Abhinav Date: Wed, 7 Sep 2022 19:09:15 +0530 Subject: [PATCH 1/5] clear watchFolderFiles after use --- src/components/WatchFolder/index.tsx | 1 + 1 file changed, 1 insertion(+) diff --git a/src/components/WatchFolder/index.tsx b/src/components/WatchFolder/index.tsx index ff5ca59aa..a3a93c2c1 100644 --- a/src/components/WatchFolder/index.tsx +++ b/src/components/WatchFolder/index.tsx @@ -33,6 +33,7 @@ export default function WatchFolder({ open, onClose }: Iprops) { appContext.watchFolderFiles.length > 0 ) { handleFolderDrop(appContext.watchFolderFiles); + appContext.setWatchFolderFiles(null); } }, [appContext.watchFolderFiles]); From bd4b456bd1b466a4be9b5f8b75e536090d778fbe Mon Sep 17 00:00:00 2001 From: Abhinav Date: Wed, 7 Sep 2022 20:50:35 +0530 Subject: [PATCH 2/5] fix NoMappingsContent font sizes --- .../mappingList/noMappingsContent/noMappingsContent.tsx | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/components/WatchFolder/mappingList/noMappingsContent/noMappingsContent.tsx b/src/components/WatchFolder/mappingList/noMappingsContent/noMappingsContent.tsx index 335057465..12b5a2d62 100644 --- a/src/components/WatchFolder/mappingList/noMappingsContent/noMappingsContent.tsx +++ b/src/components/WatchFolder/mappingList/noMappingsContent/noMappingsContent.tsx @@ -11,16 +11,16 @@ export function NoMappingsContent() { {constants.NO_FOLDERS_ADDED} - + {constants.FOLDERS_AUTOMATICALLY_MONITORED} - + {constants.UPLOAD_NEW_FILES_TO_ENTE} - + {constants.REMOVE_DELETED_FILES_FROM_ENTE} From 2df32ba7f3a726d1db8bb52fb94d4cbef551e8c5 Mon Sep 17 00:00:00 2001 From: Abhinav Date: Wed, 7 Sep 2022 20:56:18 +0530 Subject: [PATCH 3/5] add Tooltip to watch mapping icon --- src/components/WatchFolder/mappingEntry/index.tsx | 10 +++++++--- src/utils/strings/englishConstants.tsx | 2 ++ 2 files changed, 9 insertions(+), 3 deletions(-) diff --git a/src/components/WatchFolder/mappingEntry/index.tsx b/src/components/WatchFolder/mappingEntry/index.tsx index ec8e360b8..c1251f5ba 100644 --- a/src/components/WatchFolder/mappingEntry/index.tsx +++ b/src/components/WatchFolder/mappingEntry/index.tsx @@ -1,6 +1,6 @@ import { EntryContainer } from '../styledComponents'; import React from 'react'; -import { Typography } from '@mui/material'; +import { Tooltip, Typography } from '@mui/material'; import { HorizontalFlex, SpaceBetweenFlex } from 'components/Container'; import { WatchMapping } from 'types/watchFolder'; import { AppContext } from 'pages/_app'; @@ -44,9 +44,13 @@ export function MappingEntry({ mapping, handleRemoveMapping }: Iprops) { {mapping && mapping.uploadStrategy === UPLOAD_STRATEGY.SINGLE_COLLECTION ? ( - + + + ) : ( - + + + )} diff --git a/src/utils/strings/englishConstants.tsx b/src/utils/strings/englishConstants.tsx index de47f5d2f..8ca1d1d82 100644 --- a/src/utils/strings/englishConstants.tsx +++ b/src/utils/strings/englishConstants.tsx @@ -813,6 +813,8 @@ const englishConstants = { ), AUTHENTICATE: 'Authenticate', + UPLOADED_TO_SINGLE_COLLECTION: 'Uploaded to single collection', + UPLOADED_TO_SEPARATE_COLLECTIONS: 'Uploaded to separate collections', }; export default englishConstants; From 45eabbf0c20228fe2f89aac8b9123271387ed41e Mon Sep 17 00:00:00 2001 From: Abhinav Date: Fri, 9 Sep 2022 09:23:01 +0530 Subject: [PATCH 4/5] use push event helper instead of directly added event to queue --- src/services/watchFolder/watchFolderService.ts | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-) diff --git a/src/services/watchFolder/watchFolderService.ts b/src/services/watchFolder/watchFolderService.ts index 04f77c095..b80b44bd5 100644 --- a/src/services/watchFolder/watchFolderService.ts +++ b/src/services/watchFolder/watchFolderService.ts @@ -94,8 +94,6 @@ class watchFolderService { this.uploadDiffOfFiles(mapping, filesOnDisk); this.trashDiffOfFiles(mapping, filesOnDisk); } - - await this.runNextEvent(); } catch (e) { logError(e, 'error while getting and syncing diff of files'); } @@ -128,7 +126,7 @@ class watchFolderService { folderPath: mapping.folderPath, files: [file], }; - this.eventQueue.push(event); + this.pushEvent(event); } } } @@ -154,7 +152,7 @@ class watchFolderService { folderPath: mapping.folderPath, paths: [file.path], }; - this.eventQueue.push(event); + this.pushEvent(event); } } } @@ -176,7 +174,7 @@ class watchFolderService { return notDeletedMappings; } - async pushEvent(event: EventQueueItem) { + pushEvent(event: EventQueueItem) { this.eventQueue.push(event); debounce(this.runNextEvent.bind(this), 300)(); } From cf914d975c9f2ed039e00a72f25d11d2bf655d5b Mon Sep 17 00:00:00 2001 From: Abhinav Date: Fri, 9 Sep 2022 10:47:04 +0530 Subject: [PATCH 5/5] ignore system files during uploads --- src/components/Upload/Uploader.tsx | 7 +++++++ src/utils/upload/index.ts | 23 +++++++++++++++++++++++ 2 files changed, 30 insertions(+) diff --git a/src/components/Upload/Uploader.tsx b/src/components/Upload/Uploader.tsx index cb497a6f0..dcbf86302 100644 --- a/src/components/Upload/Uploader.tsx +++ b/src/components/Upload/Uploader.tsx @@ -43,6 +43,7 @@ import importService from 'services/importService'; import { getDownloadAppMessage } from 'utils/ui'; import UploadTypeSelector from './UploadTypeSelector'; import { + filterOutSystemFiles, getImportSuggestion, groupFilesBasedOnParentFolder, } from 'utils/upload'; @@ -217,6 +218,12 @@ export default function Uploader(props: Props) { toUploadFiles.current = electronFiles; setElectronFiles([]); } + + toUploadFiles.current = filterOutSystemFiles(toUploadFiles.current); + if (toUploadFiles.current.length === 0) { + return; + } + const importSuggestion = getImportSuggestion( pickedUploadType.current, toUploadFiles.current diff --git a/src/utils/upload/index.ts b/src/utils/upload/index.ts index 8244321ab..201413d41 100644 --- a/src/utils/upload/index.ts +++ b/src/utils/upload/index.ts @@ -17,6 +17,15 @@ import isElectron from 'is-electron'; const TYPE_JSON = 'json'; const DEDUPE_COLLECTION = new Set(['icloud library', 'icloudlibrary']); +const SYSTEM_FILES = [ + '.DS_Store', + 'Thumbs.db', + 'desktop.ini', + '._.DS_Store', + '._.Thumbs.db', + '._.desktop.ini', +]; + export function findMatchingExistingFiles( existingFiles: EnteFile[], newFileMetadata: Metadata @@ -189,3 +198,17 @@ export function groupFilesBasedOnParentFolder( } return collectionNameToFilesMap; } + +export function filterOutSystemFiles(files: File[] | ElectronFile[]) { + if (files[0] instanceof File) { + const browserFiles = files as File[]; + return browserFiles.filter((file) => { + return !SYSTEM_FILES.includes(file.name); + }); + } else { + const electronFiles = files as ElectronFile[]; + return electronFiles.filter((file) => { + return !SYSTEM_FILES.includes(file.name); + }); + } +}