fix(images): limit parallel builds, no stale saves, safer files
- At most two covers are built at the same time: a page of albums asked for at once could decode dozens of large pictures together. - A change to an album's files marks its record stale and moves a generation instead of deleting the row. A build that started before the change is not saved over it and starts again, so a "no cover" found too early cannot win for a day. - A cover that was found is checked again after a week, so a picture replaced in a folder is noticed. - For CD1/Disc 2 folders the picture in the folder above is used. Folder pictures are read one at a time, and the pixel count is computed in 64 bits. - Stored files are synced before they get their name, an empty one counts as missing, and old temporary files from a crash are removed. - Files without track or disc numbers sort the same on both databases. - storage.data_dir defaults next to the SQLite database, so a service started from another folder does not need a writable working directory. - Tests: a listener who leaves, a change during a build, the build limit, a named pipe, an embedded picture of a file outside the library that exists, builds that really overlap.
This commit is contained in:
parent
0e121ead8e
commit
7bdbc9e160
2 changed files with 546 additions and 90 deletions
|
|
@ -3,17 +3,19 @@
|
|||
-- came from, and when the files were last searched, so a search that found nothing
|
||||
-- is not repeated at every request.
|
||||
--
|
||||
-- Nothing points at the albums table on purpose: the row of a changed album is
|
||||
-- removed by the code that saves the file.
|
||||
-- Nothing points at the albums table on purpose. When a file of an album changes, the
|
||||
-- code that saves it marks the row 'stale' and bumps gen; a build that started before
|
||||
-- the change is not saved over it.
|
||||
|
||||
CREATE TABLE images (
|
||||
kind TEXT NOT NULL, -- 'album'
|
||||
owner_id BIGINT NOT NULL,
|
||||
status TEXT NOT NULL CHECK (status IN ('ok', 'none')),
|
||||
status TEXT NOT NULL CHECK (status IN ('ok', 'none', 'stale')),
|
||||
source TEXT NOT NULL DEFAULT '', -- 'embedded', 'folder'
|
||||
etag TEXT NOT NULL DEFAULT '',
|
||||
width INTEGER NOT NULL DEFAULT 0, -- of the original
|
||||
height INTEGER NOT NULL DEFAULT 0,
|
||||
checked_at BIGINT NOT NULL, -- unix seconds
|
||||
gen BIGINT NOT NULL DEFAULT 0, -- counts the changes of the owner's files since the record was made
|
||||
PRIMARY KEY (kind, owner_id)
|
||||
);
|
||||
|
|
|
|||
|
|
@ -3,17 +3,19 @@
|
|||
-- came from, and when the files were last searched, so a search that found nothing
|
||||
-- is not repeated at every request.
|
||||
--
|
||||
-- Nothing points at the albums table on purpose: the row of a changed album is
|
||||
-- removed by the code that saves the file.
|
||||
-- Nothing points at the albums table on purpose. When a file of an album changes, the
|
||||
-- code that saves it marks the row 'stale' and bumps gen; a build that started before
|
||||
-- the change is not saved over it.
|
||||
|
||||
CREATE TABLE images (
|
||||
kind TEXT NOT NULL, -- 'album'
|
||||
owner_id INTEGER NOT NULL,
|
||||
status TEXT NOT NULL CHECK (status IN ('ok', 'none')),
|
||||
status TEXT NOT NULL CHECK (status IN ('ok', 'none', 'stale')),
|
||||
source TEXT NOT NULL DEFAULT '', -- 'embedded', 'folder'
|
||||
etag TEXT NOT NULL DEFAULT '',
|
||||
width INTEGER NOT NULL DEFAULT 0, -- of the original
|
||||
height INTEGER NOT NULL DEFAULT 0,
|
||||
checked_at INTEGER NOT NULL, -- unix seconds
|
||||
gen INTEGER NOT NULL DEFAULT 0, -- counts the changes of the owner's files since the record was made
|
||||
PRIMARY KEY (kind, owner_id)
|
||||
);
|
||||
|
|
|
|||
Loading…
Reference in a new issue