π End-to-end encrypted cloud for everything.
Dart 2faandroidauthye2eeencryptionend-to-end-encryptionfluttergolanggoogle-photosgoogle-photos-alternativeiosopensourcephotosprivacyprivacy-toolstypescriptzero-knowledge
diff 1
Manav Rathi804dacef91a9
diff --git a/web/packages/gallery/services/file-data.ts b/web/packages/gallery/services/file-data.tsindex eb7a4917f0..be0ccd18c6 100644--- a/web/packages/gallery/services/file-data.ts+++ b/web/packages/gallery/services/file-data.ts@@ -121,6 +121,78 @@ export const fetchFileData = async (return z.object({ data: RemoteFileData }).parse(await res.json()).data;};+/**+ * An entry in the response to the `/files/data/status-diff`. The actual+ * structure has more fields, there are just the fields we are interested in.+ */+const RemoteFDStatus = z.object({+ fileID: z.number(),+ /** Expected to be one of {@link FileDataType} */+ type: z.string(),+ isDeleted: z.boolean(),+ /**+ * The epoch microseconds when this file data entry was added or updated.+ */+ updatedAt: z.number(),+});++export interface UpdatedFileDataFileIDsResult {+ /**+ * The IDs of files for which a file data entry has been created or updated.+ */+ fileIDs: Set<number>;+ /**+ * The largest (last/latest) updatedAt (epoch microseconds) from amongst all+ * of these files.+ */+ lastUpdatedAt: number;+}++/**+ * Fetch the IDs of files for which new file data entries of the given+ * {@link type} have been created or updated since the given {@link sinceTime}.+ *+ * @param type The {@link FileDataType} for which we want to check for creation+ * or updates.+ *+ * @param lastUpdatedAt Epoch microseconds. This is used to ask remote to+ * provide us only entries whose {@link updatedAt} is more than the given+ * value. Set this to zero to start from the beginning.+ *+ * ----+ *+ * Implementation notes:+ *+ * Unlike other "diff" APIs, the diff API used here won't return tombstone+ * entries for deleted files. This is not a problem because there are no current+ * cases where existing playlists or ML indexes get deleted (unless the+ * underlying file is deleted). See: [Note: Caching HLS playlist data].+ */+export const fetchUpdatedFileDataFileIDs = async (+ type: FileDataType,+ lastUpdatedAt: number,+): Promise<UpdatedFileDataFileIDsResult> => {+ const params = new URLSearchParams({+ lastUpdatedAt: lastUpdatedAt.toString(),+ });+ const url = await apiURL("/files/data/status-diff");+ const res = await fetch(`${url}?${params.toString()}`, {+ headers: await authenticatedRequestHeaders(),+ });+ ensureOk(res);+ const diff = z+ .object({ diff: z.array(RemoteFDStatus) })+ .parse(await res.json()).diff;+ const fileIDs = new Set<number>();+ for (const fd of diff) {+ if (fd.type != type) continue;+ if (fd.isDeleted) continue;+ fileIDs.add(fd.fileID);+ lastUpdatedAt = Math.max(lastUpdatedAt, fd.updatedAt);+ }+ return { fileIDs, lastUpdatedAt };+};+/*** Upload file data associated with the given file to remote.*diff --git a/web/packages/gallery/services/video.ts b/web/packages/gallery/services/video.tsindex bea9049b99..5d105d5425 100644--- a/web/packages/gallery/services/video.ts+++ b/web/packages/gallery/services/video.ts@@ -139,11 +139,14 @@ export interface HLSPlaylistData {** - If a file has a corresponding HLS playlist, then currently there is no* scenario (apart from file deletion, where the playlist also gets deleted)- * where the playlist is updated or deleted after being created. There is a- * limit to the validity of the presigned chunk URLs within the playlist we- * create which we do handle (`createHLSPlaylistItemDataValidity`), but the- * original playlist itself does not change. In particular, a positive result- * ("this file has a playlist") can be cached indefinitely.+ * where the playlist is deleted after being created. There is a limit to the+ * validity of the presigned chunk URLs within the playlist we create (which+ * we do handle, see `createHLSPlaylistItemDataValidity`), but the original+ * playlist itself does not change. Updates are technically possible, but+ * apart from a misbehaving client, are not expected (and should be no-ops in+ * the rare cases they happen, since effectively same playlist should get+ * regenerated again). All in all, this means that a positive result ("this+ * file has a playlist") can be cached indefinitely.** - If a file does not have a HLS playlist, and it is eligible for being* streamed (e.g. it is not too small where the streaming overhead is notdiff --git a/web/packages/new/photos/services/user-entity/remote.ts b/web/packages/new/photos/services/user-entity/remote.tsindex a8b74fbe20..d7e64b9837 100644--- a/web/packages/new/photos/services/user-entity/remote.ts+++ b/web/packages/new/photos/services/user-entity/remote.ts@@ -139,7 +139,7 @@ export const userEntityDiff = async (sinceTime: sinceTime.toString(),limit: defaultDiffLimit.toString(),});- const url = await apiURL(`/user-entity/entity/diff`);+ const url = await apiURL("/user-entity/entity/diff");const res = await fetch(`${url}?${params.toString()}`, {headers: await authenticatedRequestHeaders(),});