Merge pull request #701 from ente-io/fix-watch-folder-issues
Fix watch folder issues
This commit is contained in:
commit
fba2908466
|
@ -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
|
||||
|
|
|
@ -33,6 +33,7 @@ export default function WatchFolder({ open, onClose }: Iprops) {
|
|||
appContext.watchFolderFiles.length > 0
|
||||
) {
|
||||
handleFolderDrop(appContext.watchFolderFiles);
|
||||
appContext.setWatchFolderFiles(null);
|
||||
}
|
||||
}, [appContext.watchFolderFiles]);
|
||||
|
||||
|
|
|
@ -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) {
|
|||
<HorizontalFlex>
|
||||
{mapping &&
|
||||
mapping.uploadStrategy === UPLOAD_STRATEGY.SINGLE_COLLECTION ? (
|
||||
<FolderOpenIcon />
|
||||
<Tooltip title={constants.UPLOADED_TO_SINGLE_COLLECTION}>
|
||||
<FolderOpenIcon />
|
||||
</Tooltip>
|
||||
) : (
|
||||
<FolderCopyOutlinedIcon />
|
||||
<Tooltip title={constants.UPLOADED_TO_SEPARATE_COLLECTIONS}>
|
||||
<FolderCopyOutlinedIcon />
|
||||
</Tooltip>
|
||||
)}
|
||||
<EntryContainer>
|
||||
<EntryHeading mapping={mapping} />
|
||||
|
|
|
@ -11,16 +11,16 @@ export function NoMappingsContent() {
|
|||
<Typography variant="h4" fontWeight={'bold'} mb={2}>
|
||||
{constants.NO_FOLDERS_ADDED}
|
||||
</Typography>
|
||||
<Typography mb={1} variant="caption" color="text.secondary">
|
||||
<Typography mb={1} variant={'body2'} color="text.secondary">
|
||||
{constants.FOLDERS_AUTOMATICALLY_MONITORED}
|
||||
</Typography>
|
||||
<Typography mb={1} variant="caption" color="text.secondary">
|
||||
<Typography mb={1} variant={'body2'} color="text.secondary">
|
||||
<FlexWrapper gap={1}>
|
||||
<CheckmarkIcon />
|
||||
{constants.UPLOAD_NEW_FILES_TO_ENTE}
|
||||
</FlexWrapper>
|
||||
</Typography>
|
||||
<Typography mb={1} variant="caption" color="text.secondary">
|
||||
<Typography mb={1} variant={'body2'} color="text.secondary">
|
||||
<FlexWrapper gap={1}>
|
||||
<CheckmarkIcon />
|
||||
{constants.REMOVE_DELETED_FILES_FROM_ENTE}
|
||||
|
|
|
@ -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)();
|
||||
}
|
||||
|
|
|
@ -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;
|
||||
|
|
|
@ -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);
|
||||
});
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue