π End-to-end encrypted cloud for everything.
Dart 2faandroidauthye2eeencryptionend-to-end-encryptionfluttergolanggoogle-photosgoogle-photos-alternativeiosopensourcephotosprivacyprivacy-toolstypescriptzero-knowledge
Support syncing watch folders to hidden albums
Anand Baburajanb4c8ca421fef
diff --git a/web/apps/photos/src/components/Upload.tsx b/web/apps/photos/src/components/Upload.tsxindex 58029cdf07..7e6a28a087 100644--- a/web/apps/photos/src/components/Upload.tsx+++ b/web/apps/photos/src/components/Upload.tsx@@ -64,7 +64,7 @@ import type { RemotePullOpts } from "ente-new/photos/components/gallery";import { downloadAppDialogAttributes } from "ente-new/photos/components/utils/download";import {createAlbum,- isHiddenCollection,+ savedAllCollections,savedNormalCollections,} from "ente-new/photos/services/collection";import { redirectToCustomerPortal } from "ente-new/photos/services/user-details";@@ -541,13 +541,17 @@ export const Upload: React.FC<UploadProps> = ({if (isPendingDesktopUpload.current) {isPendingDesktopUpload.current = false;if (pendingDesktopUploadCollectionName.current) {+ // Include hidden collections so watch folder syncs add+ // files to existing hidden albums instead of creating new+ // visible ones.uploadFilesToNewCollections("root",pendingDesktopUploadCollectionName.current,+ true,);pendingDesktopUploadCollectionName.current = undefined;} else {- uploadFilesToNewCollections("parent");+ uploadFilesToNewCollections("parent", undefined, true);}return;}@@ -631,6 +635,7 @@ export const Upload: React.FC<UploadProps> = ({const uploadFilesToNewCollections = async (mapping: CollectionMapping,collectionName?: string,+ includeHiddenCollections?: boolean,) => {preCollectionCreationAction();let uploadItemsWithCollection: UploadItemWithCollection[] = [];@@ -654,7 +659,12 @@ export const Upload: React.FC<UploadProps> = ({const collections: Collection[] = [];try {await onRemoteFilesPull!();- const existingCollections = await savedNormalCollections();+ // Include hidden collections when syncing from watch folders so+ // that new files go to the existing hidden album instead of+ // creating a new visible album with the same name.+ const existingCollections = includeHiddenCollections+ ? await savedAllCollections()+ : await savedNormalCollections();let index = 0;for (const [collectionName,@@ -1053,8 +1063,6 @@ const matchExistingOrCreateAlbum = async ((collection.type == "album" ||collection.type == "folder" ||collection.type == "uncategorized") &&- // Not hidden- !isHiddenCollection(collection) &&// Not a quicklinkcollection.magicMetadata?.data.subType !=CollectionSubType.quicklink &&diff --git a/web/apps/photos/src/services/watch.ts b/web/apps/photos/src/services/watch.tsindex bbf200e978..999069703b 100644--- a/web/apps/photos/src/services/watch.ts+++ b/web/apps/photos/src/services/watch.ts@@ -17,7 +17,7 @@ import type { UploadAsset } from "ente-gallery/services/upload/upload-service";import { groupFilesByCollectionID } from "ente-gallery/utils/file";import type { EnteFile } from "ente-media/file";import { removeFromOwnCollection } from "ente-new/photos/services/collection";-import { computeNormalCollectionFilesFromSaved } from "ente-new/photos/services/file";+import { computeAllCollectionFilesFromSaved } from "ente-new/photos/services/file";import { ensureString } from "ente-utils/ensure";import { type UploadItemWithCollection, uploadManager } from "./upload-manager";@@ -570,7 +570,9 @@ class FolderWatcher {for (const file of syncedFiles)syncedFileForID.set(file.uploadedFileID, file);- const files = await computeNormalCollectionFilesFromSaved();+ // Use all collection files (including hidden) so that files removed+ // from the watch folder are also removed from hidden albums.+ const files = await computeAllCollectionFilesFromSaved();const filesToTrash = files.filter((file) => {const correspondingSyncedFile = syncedFileForID.get(file.id);if (diff --git a/web/packages/new/photos/services/collection.ts b/web/packages/new/photos/services/collection.tsindex 0b3cc1d0d0..a00097017b 100644--- a/web/packages/new/photos/services/collection.ts+++ b/web/packages/new/photos/services/collection.ts@@ -458,6 +458,13 @@ const clearCachedThumbnailIfContentChanged = async (}};+/**+ * Return all collections (both normal and hidden) that are present in our+ * local database.+ */+export const savedAllCollections = (): Promise<Collection[]> =>+ savedCollections();+/*** Return all normal (non-hidden) collections that are present in our local* database.diff --git a/web/packages/new/photos/services/file.ts b/web/packages/new/photos/services/file.tsindex 2c62346027..0f962f9eba 100644--- a/web/packages/new/photos/services/file.ts+++ b/web/packages/new/photos/services/file.ts@@ -52,6 +52,13 @@ export const batched = async <T, U>(return result;};+/**+ * Return all files (from both normal and hidden collections) present in our+ * local database.+ */+export const computeAllCollectionFilesFromSaved = async () =>+ savedCollectionFiles();+/*** Return all normal (non-hidden) files present in our local database.*