Compare commits
1
Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
c0b9c37726 |
@@ -1793,6 +1793,53 @@ describe("backup album folders", () => {
|
|||||||
]);
|
]);
|
||||||
});
|
});
|
||||||
|
|
||||||
|
// A title of 255 bytes is the longest file name allowed, and an album
|
||||||
|
// name of 250 bytes the longest whose JSON name fits; both are kept as
|
||||||
|
// they are. A name one byte longer gets the ID and is cut short. "é"
|
||||||
|
// takes two bytes, and in both names the room left ends inside one, so
|
||||||
|
// the cut falls before it, one byte short of the room.
|
||||||
|
it("keeps a name at the byte limit and adds the ID to one a byte over it", async () => {
|
||||||
|
const outDir = join(root, "backup");
|
||||||
|
const album = "A".repeat(250);
|
||||||
|
const title = `${"t".repeat(251)}.jpg`;
|
||||||
|
const longAlbum = `${"é".repeat(125)}B`;
|
||||||
|
const longTitle = `${"é".repeat(126)}.jpg`;
|
||||||
|
const lib = libraryOf([
|
||||||
|
{
|
||||||
|
collection: collection(10, album),
|
||||||
|
files: [file(1, 10, title), file(2, 10, longTitle)],
|
||||||
|
},
|
||||||
|
{
|
||||||
|
collection: collection(11, longAlbum),
|
||||||
|
files: [file(3, 11, "c.jpg")],
|
||||||
|
},
|
||||||
|
]);
|
||||||
|
|
||||||
|
const result = await runBackup(lib, { downloadDirectory: outDir });
|
||||||
|
|
||||||
|
const folder = `${"é".repeat(122)} (11)`;
|
||||||
|
const link = `${"é".repeat(123)} (2).jpg`;
|
||||||
|
expect(Buffer.byteLength(`${album}.json`)).toBe(255);
|
||||||
|
expect(Buffer.byteLength(title)).toBe(255);
|
||||||
|
expect(Buffer.byteLength(longAlbum)).toBe(251);
|
||||||
|
expect(Buffer.byteLength(longTitle)).toBe(256);
|
||||||
|
expect(Buffer.byteLength(`${folder}.json`)).toBe(254);
|
||||||
|
expect(Buffer.byteLength(link)).toBe(254);
|
||||||
|
expect(result.failed).toBe(0);
|
||||||
|
expect(result.failedAlbums).toEqual([]);
|
||||||
|
expect(tree(outDir)).toEqual([
|
||||||
|
`${album}/`,
|
||||||
|
`${album}/${title} -> ${linkTo("1.jpg")}`,
|
||||||
|
`${album}/${link} -> ${linkTo("2.jpg")}`,
|
||||||
|
`${album}.json`,
|
||||||
|
`${folder}/`,
|
||||||
|
`${folder}/c.jpg -> ${linkTo("3.jpg")}`,
|
||||||
|
`${folder}.json`,
|
||||||
|
]);
|
||||||
|
expect(albumID(outDir, `${album}.json`)).toBe(10);
|
||||||
|
expect(albumID(outDir, `${folder}.json`)).toBe(11);
|
||||||
|
});
|
||||||
|
|
||||||
it("changes nothing on a second run over an unchanged account", async () => {
|
it("changes nothing on a second run over an unchanged account", async () => {
|
||||||
const outDir = join(root, "backup");
|
const outDir = join(root, "backup");
|
||||||
const lib = libraryOf([
|
const lib = libraryOf([
|
||||||
|
|||||||
Reference in New Issue
Block a user