Skip to content

armgit / ente

Public Imported from GitHub
0

πŸ’š End-to-end encrypted cloud for everything.

Disentagle map from modifications

Manav Rathi46d67f0c49dd
diff --git a/desktop/src/main/services/watch.ts b/desktop/src/main/services/watch.ts
index e8e3803902..ca550a787b 100644
--- a/desktop/src/main/services/watch.ts
+++ b/desktop/src/main/services/watch.ts
@@ -73,7 +73,7 @@ export const watchAdd = async (
) => {
const watches = folderWatches();
- if (!fsIsDir(folderPath))
+ if (!(await fsIsDir(folderPath)))
throw new Error(
`Attempting to add a folder watch for a folder path ${folderPath} that is not an existing directory`,
);
@@ -97,7 +97,7 @@ export const watchAdd = async (
return watches;
};
-export const watchRemove = async (watcher: FSWatcher, folderPath: string) => {
+export const watchRemove = (watcher: FSWatcher, folderPath: string) => {
const watches = folderWatches();
const filtered = watches.filter((watch) => watch.folderPath != folderPath);
if (watches.length == filtered.length)
diff --git a/desktop/src/main/stores/watch.ts b/desktop/src/main/stores/watch.ts
index 6006c28ac6..59032c9acd 100644
--- a/desktop/src/main/stores/watch.ts
+++ b/desktop/src/main/stores/watch.ts
@@ -3,7 +3,7 @@ import { type FolderWatch } from "../../types/ipc";
import log from "../log";
interface WatchStore {
- mappings: FolderWatchWithLegacyFields[];
+ mappings?: FolderWatchWithLegacyFields[];
}
type FolderWatchWithLegacyFields = FolderWatch & {
@@ -54,7 +54,8 @@ export const watchStore = new Store({
*/
export const migrateLegacyWatchStoreIfNeeded = () => {
let needsUpdate = false;
- const watches = watchStore.get("mappings").map((watch) => {
+ const updatedWatches = [];
+ for (const watch of watchStore.get("mappings") ?? []) {
let collectionMapping = watch.collectionMapping;
// The required type defines the latest schema, but before migration
// this'll be undefined, so tell ESLint to calm down.
@@ -67,10 +68,10 @@ export const migrateLegacyWatchStoreIfNeeded = () => {
delete watch.rootFolderName;
needsUpdate = true;
}
- return { ...watch, collectionMapping };
- });
+ updatedWatches.push({ ...watch, collectionMapping });
+ }
if (needsUpdate) {
- watchStore.set("mappings", watches);
+ watchStore.set("mappings", updatedWatches);
log.info("Migrated legacy watch store data to new schema");
}
};