Inline
This commit is contained in:
parent
cf889b24af
commit
96ea996401
2 changed files with 24 additions and 27 deletions
|
@ -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<string>();
|
||||
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)
|
||||
);
|
||||
}
|
||||
|
|
|
@ -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<string>();
|
||||
return files.filter((file) => {
|
||||
if (!isSystemFile(file) && !isSyncedOrIgnoredFile(file, mapping)) {
|
||||
if (!uniqueFilePaths.has(file.path)) {
|
||||
uniqueFilePaths.add(file.path);
|
||||
return true;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
});
|
||||
}
|
Loading…
Add table
Reference in a new issue