E1: le copie della cartella generale tornano con l'account, un rifiuto per ogni CHECK (#58)
verifica / controlli (push) Successful in 28s
verifica / prove (push) Successful in 26m53s
verifica / installatore (push) Successful in 2m13s
verifica / immagine (push) Successful in 20m12s

La seconda revisione ha trovato che le copie della cartella generale di un account
rimosso e aggiunto di nuovo restavano orfane per sempre: una «Tolto» o «Superato»
senza file da adottare si sarebbe ricopiata da sola, contro §4.10.

- export_copy tiene identificativo Instagram e nome dell'account rimosso, solo sulle
  copie orfane (CHECK, ix_export_copy_orphan); AccountStore.DeleteAsync li scrive.
- RelinkOrphanCopiesAsync ridà all'account le sue copie della cartella generale, per
  identificativo o, se la copia non lo ha, per nome; AddAsync, UpdateAsync e
  RenameAsync lo chiamano nella loro transazione. La cartella propria resta ad
  AttachDestinationAsync.
- Ogni CHECK della 0003 ha una prova di rifiuto su una riga valida per tutti gli
  altri; ambito, variante e formato sconosciuti si controllano anche sullo schema.
- SPECIFICA §4.10 e §8.3, decisioni.md e stato.md aggiornati.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
Alby96andClaude Opus 5.5 committed 2026-11-26 20:32:40 +01:00
1 parent ea4666d49b
commit 980212fb50
10 files changed
+470 -32

No files matched your search

+22 -7
View File
@@ -1,9 +1,10 @@
-- Febe, schema version 3: export (tappa E1 of 0.3.0, issue #58; spec §4.10, §8.3).
-- Run by the migration runner inside a transaction; PRAGMA user_version is set by the runner.
-- Only new tables and indexes: no column or index of the existing tables changes. The only existing path that touches
-- the new tables is AccountStore.DeleteAsync, which disables the account's destinations and keeps its user name on them
-- before deleting the account (nothing to do while there are no destinations); nothing else reads or writes them yet
-- (tappa E1: no behaviour change). Times are UTC Unix milliseconds; enumerations are their English names,
-- Only new tables and indexes: no column or index of the existing tables changes. The only existing paths that touch
-- the new tables are in AccountStore: DeleteAsync disables the account's destinations and keeps its user name on them,
-- and keeps its Instagram id and user name on its copies, before deleting the account; AddAsync, UpdateAsync and
-- RenameAsync give the account back its orphan copies of the general folder (nothing to do while there are no
-- destinations and no copies); nothing else reads or writes them yet (tappa E1: no behaviour change). Times are UTC Unix milliseconds; enumerations are their English names,
-- checked here. Paths in a destination are relative to its root, '/' separated, NFC; paths of converted library files
-- are relative to the account folder, like media.relative_path. Every foreign key has an index on its child column.
@@ -82,9 +83,18 @@ CREATE TABLE export_copy (
id INTEGER PRIMARY KEY,
destination_id INTEGER NOT NULL REFERENCES export_destination (id) ON DELETE RESTRICT,
-- Effective account: the account segment in the general folder, or the account of its own folder. NULL only after
-- the account was removed («orphan»): the store never writes NULL, and re-links an orphan row when its file is
-- adopted again or its destination is attached to the account again.
-- the account was removed («orphan»): only AccountStore.DeleteAsync writes NULL, with the two columns below, in the
-- transaction that deletes the account (ON DELETE SET NULL then finds nothing left to clear).
account_id INTEGER REFERENCES account (id) ON DELETE SET NULL,
-- Instagram id and user name of the account when it was removed, on orphan rows only, so the account added again
-- (a new account id) finds its copies again: those of the general folder come back by themselves, any state, when
-- the account is added or its id or name written (by Instagram id when both have one, else by user name, only for a
-- row without one); those of its own folder when the folder is attached to it again; any row when its file is
-- adopted again by path. Both NULL on an orphan whose account is unknown (a raw delete): it comes back only by
-- adoption. Without them a Removed or Superseded row of the general folder, which has no file to adopt, would be
-- lost to the account added again and its file copied again by itself (spec §4.10).
removed_account_instagram_id TEXT CHECK (removed_account_instagram_id IS NULL OR length(removed_account_instagram_id) > 0),
removed_account_username TEXT COLLATE NOCASE CHECK (removed_account_username IS NULL OR length(removed_account_username) > 0),
media_id INTEGER REFERENCES media (id) ON DELETE SET NULL,
source_sha256 TEXT NOT NULL CHECK (length(source_sha256) = 64),
variant TEXT NOT NULL CHECK (variant IN ('Whole', 'Converted', 'Frame')),
@@ -115,7 +125,9 @@ CREATE TABLE export_copy (
CHECK (copy_sha256 IS NULL OR (variant = 'Whole') = (copy_sha256 = source_sha256)),
CHECK (state <> 'Superseded' OR superseded_by_sha256 IS NOT NULL),
CHECK (superseded_by_sha256 IS NULL OR state IN ('Superseded', 'Removed')),
CHECK (superseded_by_sha256 IS NULL OR superseded_by_sha256 <> source_sha256)
CHECK (superseded_by_sha256 IS NULL OR superseded_by_sha256 <> source_sha256),
-- The removed account is remembered only while the row has no account: re-linking clears it.
CHECK (account_id IS NULL OR (removed_account_instagram_id IS NULL AND removed_account_username IS NULL))
);
-- The copy identity: one current row (Copied or Failed) per identity. NULL account_id (orphan) is distinct.
@@ -141,6 +153,9 @@ CREATE INDEX ix_export_copy_superseded_by ON export_copy (superseded_by_sha256,
-- Foreign keys with SET NULL.
CREATE INDEX ix_export_copy_media ON export_copy (media_id) WHERE media_id IS NOT NULL;
CREATE INDEX ix_export_copy_account ON export_copy (account_id) WHERE account_id IS NOT NULL;
-- The orphan copies of a removed account, by its Instagram id, or by its user name for rows without one (re-linking).
CREATE INDEX ix_export_copy_orphan ON export_copy (removed_account_instagram_id, removed_account_username)
WHERE account_id IS NULL;
-- An export job (on the model of import_run): «Copia in…», the automatic export, «Riconosci le copie già presenti».
-- Interrupted (Febe closed) and Paused (destination not reachable) runs resume from their pending items.