feat(android): sync device albums with a server album

Add phone album sync to the Android client: MediaStore source (device
albums), a Room index with upload provenance, on-device previews, and a
mixed server + device album list where a linked pair collapses into a
single device card with a link indicator and mode label.

Three modes over one pipeline: A (off), B (upload copies, originals stay
local), C (upload originals and offload them locally to previews). The
sync engine tracks device changes (add/remove/rename/move/content), matches
assets to server photos by sha256 content hash, deletes only this client's
uploads, and reflects server changes without touching local originals.
Offload is automatic; the zoomed viewer pulls the server original.

Backend: expose the original content checksum in photo data (Postgres and
SQLite), additive with no migration.

Also anchor the `.gitignore` `data/` rule to `/data/` so the Android
`com.galo.android.data` package is tracked, and add the halo launcher icon.
This commit is contained in:
iu
2026-10-13 17:10:47 +03:00
parent b7316f9e00
commit 38b5b03f59
102 changed files with 7199 additions and 153 deletions
@@ -494,6 +494,43 @@ func testPhotos(t *testing.T, ctx context.Context, r Repos) {
t.Fatalf("album should exist")
}
// The original object's content checksum is exposed so clients can match a
// local file against a server photo. Identical content yields identical
// checksums.
csObjA := &photos.Object{ID: newID(), StorageKey: "objects/" + newID(), MimeType: "image/jpeg", Checksum: "sha256-same", State: photos.ObjectPending}
csA := &models.Photo{ID: newID(), AlbumID: a.ID, UploaderID: owner.ID, OriginalFilename: "checksum-a.jpg"}
if err := r.Photos.CreateWithOriginal(ctx, csA, csObjA); err != nil {
t.Fatalf("create checksum photo: %v", err)
}
if err := r.Photos.ActivateObject(ctx, csObjA.ID); err != nil {
t.Fatalf("activate checksum object: %v", err)
}
csObjB := &photos.Object{ID: newID(), StorageKey: "objects/" + newID(), MimeType: "image/jpeg", Checksum: "sha256-same", State: photos.ObjectPending}
csB := &models.Photo{ID: newID(), AlbumID: a.ID, UploaderID: owner.ID, OriginalFilename: "checksum-b.jpg"}
if err := r.Photos.CreateWithOriginal(ctx, csB, csObjB); err != nil {
t.Fatalf("create checksum photo 2: %v", err)
}
if err := r.Photos.ActivateObject(ctx, csObjB.ID); err != nil {
t.Fatalf("activate checksum object 2: %v", err)
}
checked, err := r.Photos.GetByID(ctx, csA.ID, "")
if err != nil || checked.OriginalChecksum != "sha256-same" {
t.Fatalf("original checksum via get = %q err=%v", checked.OriginalChecksum, err)
}
byList, err := r.Photos.List(ctx, photos.ListParams{AlbumID: a.ID, Limit: 10})
if err != nil {
t.Fatalf("list with checksums: %v", err)
}
same := 0
for _, ph := range byList {
if ph.OriginalChecksum == "sha256-same" {
same++
}
}
if same != 2 {
t.Fatalf("photos with identical content checksum in list = %d, want 2", same)
}
if err := r.Photos.HardDelete(ctx, p.ID); err != nil {
t.Fatalf("hard delete: %v", err)
}