π End-to-end encrypted cloud for everything.
Dart 2faandroidauthye2eeencryptionend-to-end-encryptionfluttergolanggoogle-photosgoogle-photos-alternativeiosopensourcephotosprivacyprivacy-toolstypescriptzero-knowledge
Outline
Manav Rathiea0cc47c9c12
diff --git a/web/packages/new/photos/services/exif-update.ts b/web/packages/new/photos/services/exif-update.tsindex 208c3a661f..ed7fc74ead 100644--- a/web/packages/new/photos/services/exif-update.ts+++ b/web/packages/new/photos/services/exif-update.ts@@ -51,17 +51,14 @@ export const updateExifIfNeededAndPossible = async (return updatedBlob.stream();} catch (e) {log.error(`Failed to modify Exif date for ${fileName}`, e);- // We used the file's extension to determine if this was a JPEG, but- // this is not a guarantee. Misnamed files, while rare, do exist. So if- // that is the error thrown by the underlying library, fallback to the- // original instead of causing the entire download or export to fail.- if (- e instanceof Error &&- e.message.endsWith("Given file is neither JPEG nor TIFF.")- ) {- return blob.stream();- }- throw e;+ // Ignore errors and use the original - we don't want to block the whole+ // download or export for an errant file. TODO: This is not always going+ // to be the correct choice, but instead trying further hack around with+ // the Exif modifications (and all the caveats that come with it), a+ // more principled approach is to put our metadata in a sidecar and+ // never touch the original. We can then and provide additional tools to+ // update the original if the user so wishes from the sidecar.+ return blob.stream();}};diff --git a/web/packages/new/photos/services/exif.ts b/web/packages/new/photos/services/exif.tsindex 69c3b4d577..c522c7a6f1 100644--- a/web/packages/new/photos/services/exif.ts+++ b/web/packages/new/photos/services/exif.ts@@ -2,7 +2,32 @@ import ExifReader from "exifreader";import type { EnteFile } from "../types/file";/**- * Index Exif in the given file.+ * Extract Exif and other metadata from the given file.+ *+ * [Note: Exif]+ *+ * Exif is a standard for metadata embedded in photos. Exif tags arise from the+ * TIFF specification but now can be found in other file formats, notably JPG,+ * PNG, AVI, MOV, TIFF-based RAW images (and TIFF itself)+ *+ * The standard uses "Exif" (not "EXIF") to refer to itself. We do the same.+ *+ * Exif is now commonly used as a synedoche for all forms of metadata that gets+ * embedded in a file, and this is also how we use the term. So these functions+ * extract and operate on not just Exif tags, but also XMP (XML metadata+ * embedded in images) and IPTC (another metadat standard) tags.+ *+ * The de facto reference for Exif (in its general form) is exiftool.+ * https://exiftool.org/TagNames+ *+ * The library we use is https://github.com/mattiasw/ExifReader.+ */++// eslint-disable-next-line @typescript-eslint/no-empty-function+export const extractExif = () => {};++/**+ * Index Exif in the given {@link EnteFile}.** This function is invoked as part of the ML indexing pipeline, which is why it* uses the same "index" nomenclature. But what it does is more of an extraction@@ -18,11 +43,8 @@ import type { EnteFile } from "../types/file";* @param blob A {@link Blob} containing the {@link enteFile}'s data. This is* where we extract the Exif from.*- * [Note: Exif not EXIF]- *- * The standard uses "Exif" (not "EXIF") to refer to itself. We do the same.*/-export const indexExif = async (_enteFile: EnteFile, blob: Blob) => {+export const indexExif = async (enteFile: EnteFile, blob: Blob) => {// [Note: Defining "raw" Exif]//// Our goal is to get a "raw" JSON representing all the Exif data associated@@ -71,7 +93,7 @@ export const indexExif = async (_enteFile: EnteFile, blob: Blob) => {//// So this is not really "raw" Exif. But with that caveat out of the way,// practically this should be raw enough given the tradeoffs mentioned- // above, and consuming this JSON should be reasonable enough for arbitrary+ // above, and consuming this JSON should be easy enough for arbitrary// clients without needing to know about ExifReader specifically.const tags = await ExifReader.load(await blob.arrayBuffer(), {async: true,@@ -104,5 +126,12 @@ export const indexExif = async (_enteFile: EnteFile, blob: Blob) => {// while the actual value doesn't have it).delete (tags.xmp as Partial<typeof tags.xmp>)?._raw;+ backfill(enteFile, tags);+return tags;};++// eslint-disable-next-line @typescript-eslint/no-unused-vars+const backfill = (_enteFile: EnteFile, _tags: ExifReader.ExpandedTags) => {+ // const date =+};