Skip to content

Conversation

@korjavin
Copy link

Summary

This PR adds a new CLI command to import Google Takeout exports directly to Ente Photos. It preserves metadata (timestamps, location, etc) from Takeout JSON sidecars and includes built-in duplicate detection.

Motivation

Many users manage their media on headless environments like a NAS or a home server. Currently, importing large Google Takeout exports requires a GUI (Desktop/Web client). This command provides a robust, command-line alternative for these environments, allowing for efficient, unattended imports.

Key Implementation Details

Duplicate Detection
Duplicate detection is implemented and enabled by default. It follows the logic used in the web/desktop clients:

Content Hash: Computes a BLAKE2b hash of the file content.
Metadata Comparison: Before uploading, the command fetches existing file metadata from the target album and compares hash + title + fileType.
Efficiency: This ensures that interrupted imports can be resumed without re-uploading existing files, and multiple imports from the same source don't create clusters of duplicates.
Chunked Encryption for Large Files
To ensure compatibility with the web client's decryption process for large files, we've implemented
EncryptChaCha20poly1305Chunked()
. This function encrypts data in 4MB chunks (matching streamEncryptionChunkSize), which resolves "Failed to fetch" errors during playback of large videos.

Testing

Tested on macOS with:

Large-scale collection: Imported a collection of ~6,400 files.
Deduplication reliability: Interrupted and restarted the import multiple times at random intervals; verified that the duplicate detection correctly identified and skipped already-uploaded files, resuming the process seamlessly.
Resilience: Encountered and successfully handled transient 500 errors from the storage provider (Wasabi) via built-in retries, with all files eventually being uploaded correctly.
Media types: Verified playback of 100MB+ videos and visibility of diverse JPG/PNG/HEIC files.
Usage

Basic usage

ente import-google-takeout-folder /path/to/takeout "Album Name"

Enable debug output

ente import-google-takeout-folder /path/to/takeout "Album Name" --debug

Questions for Maintainers

FileType Requirement
While implementing this, I noticed the Zod schema for file metadata seems to require a fileType field (0 for image, 1 for video), otherwise files can remain invisible in the web client. I have implemented this as a requirement in the CLI metadata - could you clarify if this is the intended behavior or if there's a more flexible way to handle this?

Copy link

@chatgpt-codex-connector chatgpt-codex-connector bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: fc3ff7f240

ℹ️ About Codex in GitHub

Codex has been enabled to automatically review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

When you sign up for Codex through ChatGPT, Codex can also answer questions or update the PR, like "@codex address that feedback".

- Use dummyCollectionID for metadata lookup to match key used during scan
- Always set metadata.Title unconditionally for proper duplicate detection
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant