update to use the new apis
This commit is contained in:
parent
0e0acdf218
commit
354642c834
|
@ -85,9 +85,7 @@ class watchFolderService {
|
|||
|
||||
for (const mapping of mappings) {
|
||||
const filesOnDisk: ElectronFile[] =
|
||||
await this.ElectronAPIs.getAllFilesFromDir(
|
||||
mapping.folderPath
|
||||
);
|
||||
await this.ElectronAPIs.getDirFiles(mapping.folderPath);
|
||||
|
||||
this.uploadDiffOfFiles(mapping, filesOnDisk);
|
||||
this.trashDiffOfFiles(mapping, filesOnDisk);
|
||||
|
@ -166,11 +164,12 @@ class watchFolderService {
|
|||
const mappingExists = await this.ElectronAPIs.doesFolderExists(
|
||||
mapping.folderPath
|
||||
);
|
||||
if (mappingExists) {
|
||||
if (!mappingExists) {
|
||||
this.ElectronAPIs.removeWatchMapping(mapping.folderPath);
|
||||
} else {
|
||||
notDeletedMappings.push(mapping);
|
||||
}
|
||||
}
|
||||
this.ElectronAPIs.setWatchMappings(notDeletedMappings);
|
||||
return notDeletedMappings;
|
||||
}
|
||||
|
||||
|
@ -325,7 +324,10 @@ class watchFolderService {
|
|||
);
|
||||
if (mapping) {
|
||||
mapping.files = [...mapping.files, ...uploadedFiles];
|
||||
this.ElectronAPIs.setWatchMappings(mappings);
|
||||
this.ElectronAPIs.updateWatchMappingFiles(
|
||||
mapping.folderPath,
|
||||
mapping.files
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -410,7 +412,10 @@ class watchFolderService {
|
|||
mappings[mappingIdx].files = mappings[mappingIdx].files.filter(
|
||||
(file) => !filePathsToRemove.has(file.path)
|
||||
);
|
||||
this.ElectronAPIs.setWatchMappings(mappings);
|
||||
this.ElectronAPIs.updateWatchMappingFiles(
|
||||
mappings[mappingIdx].folderPath,
|
||||
mappings[mappingIdx].files
|
||||
);
|
||||
} catch (e) {
|
||||
logError(e, 'error while running next trash');
|
||||
}
|
||||
|
|
|
@ -36,9 +36,12 @@ export interface ElectronAPIsInterface {
|
|||
filePath: string
|
||||
) => Promise<ElectronFile[]>;
|
||||
setToUploadCollection: (collectionName: string) => void;
|
||||
getAllFilesFromDir: (dirPath: string) => Promise<ElectronFile[]>;
|
||||
getDirFiles: (dirPath: string) => Promise<ElectronFile[]>;
|
||||
getWatchMappings: () => WatchMapping[];
|
||||
setWatchMappings: (watchMappings: WatchMapping[]) => void;
|
||||
updateWatchMappingFiles: (
|
||||
folderPath: string,
|
||||
files: WatchMapping['files']
|
||||
) => void;
|
||||
addWatchMapping: (
|
||||
collectionName: string,
|
||||
folderPath: string,
|
||||
|
|
Loading…
Reference in a new issue