Date download() and backup by the album copy photo.savePath uses

Export `representative` from records.ts: the album's copy of a file that
its record is read from. `store.getFileByID` now returns that copy, so
`download()` writes under the date `photo.savePath` names. `lib.backup()`
takes each file's copy by the same rule from all of its albums, and every
album links that one path. Tests cover one file in two albums whose copies
carry different edited dates, for `download()` and for `lib.backup()`.

Model: opus-5-5
This commit is contained in:
2026-10-01 20:56:39 +00:00
parent 2323da4727
commit 8992c7c5a9
6 changed files with 99 additions and 17 deletions
+7 -1
View File
@@ -416,7 +416,7 @@ describe("Photo save path, local copy, content and EXIF", () => {
await lib.close();
});
it("dates the save path by the membership its takenAt comes from", async () => {
it("dates the save path and download() by the membership its takenAt comes from", async () => {
// One file in two albums. The date edited in Ente has reached album 2's
// copy, synced later, but album 1 still has an earlier edit.
const older = file(1, 1);
@@ -457,6 +457,12 @@ describe("Photo save path, local copy, content and EXIF", () => {
"2026-04-15.1.jpg",
),
);
// download() writes to that same path, so the photo is then local.
const saved = await photo.download();
expect(saved.path).toBe(photo.savePath);
expect(photo.isLocal).toBe(true);
expect(existsSync(join(root, "backup", "2026", "2026-02"))).toBe(false);
await lib.close();
});