E1: le copie della cartella generale tornano con l'account, un rifiuto per ogni CHECK (#58)
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:
1 parent
ea4666d49b
commit
980212fb50
10 files changed
+470
-32
No files matched your search
@@ -301,7 +301,12 @@ internal sealed class AccountStore(FebeDatabase db) : IAccountStore
|
||||
ex);
|
||||
}
|
||||
|
||||
return account with { Id = w.LastInsertRowId(), InstagramId = Normalize(account.InstagramId), Username = NormalizeUsername(account.Username) };
|
||||
var added = account with { Id = w.LastInsertRowId(), InstagramId = Normalize(account.InstagramId), Username = NormalizeUsername(account.Username) };
|
||||
|
||||
// An account removed before and added again (a new id) gets back its copies of the general folder, so
|
||||
// its Removed and Superseded copies are never copied again by themselves (spec §4.10).
|
||||
ExportStore.RelinkOrphanCopies(w, added.Id, added.InstagramId, added.Username);
|
||||
return added;
|
||||
},
|
||||
ct);
|
||||
}
|
||||
@@ -337,6 +342,9 @@ internal sealed class AccountStore(FebeDatabase db) : IAccountStore
|
||||
{
|
||||
throw new DuplicateRecordException("Esiste già un account con lo stesso identificativo Instagram, oppure il profilo «Tu» è già presente.", ex);
|
||||
}
|
||||
|
||||
// The Instagram id may be known only now (an imported account): its copies come back as in AddAsync.
|
||||
ExportStore.RelinkOrphanCopies(w, account.Id, Normalize(account.InstagramId), NormalizeUsername(account.Username));
|
||||
},
|
||||
ct);
|
||||
}
|
||||
@@ -407,7 +415,8 @@ internal sealed class AccountStore(FebeDatabase db) : IAccountStore
|
||||
w =>
|
||||
{
|
||||
string? oldName;
|
||||
using (var r = w.Command("SELECT username, folder FROM account WHERE id = @id").With("@id", accountId).ExecuteReader())
|
||||
string? instagramId;
|
||||
using (var r = w.Command("SELECT username, folder, instagram_id FROM account WHERE id = @id").With("@id", accountId).ExecuteReader())
|
||||
{
|
||||
if (!r.Read())
|
||||
{
|
||||
@@ -415,6 +424,7 @@ internal sealed class AccountStore(FebeDatabase db) : IAccountStore
|
||||
}
|
||||
|
||||
oldName = r.GetString(0);
|
||||
instagramId = r.GetTextOrNull(2);
|
||||
}
|
||||
|
||||
if (string.Equals(oldName, name, StringComparison.Ordinal))
|
||||
@@ -434,6 +444,7 @@ internal sealed class AccountStore(FebeDatabase db) : IAccountStore
|
||||
.With("@renamed", (long)AccountNotices.Renamed)
|
||||
.With("@id", accountId)
|
||||
.ExecuteNonQuery();
|
||||
ExportStore.RelinkOrphanCopies(w, accountId, instagramId, name);
|
||||
},
|
||||
ct);
|
||||
}
|
||||
@@ -478,6 +489,18 @@ internal sealed class AccountStore(FebeDatabase db) : IAccountStore
|
||||
automatic = 0, automatic_since = NULL
|
||||
WHERE account_id = @id
|
||||
""").With("@id", accountId).ExecuteNonQuery();
|
||||
|
||||
// Its copies stay, in every destination and state, without account but with its Instagram id and user
|
||||
// name, so the account added again finds them (ExportStore.RelinkOrphanCopies): a Removed or Superseded
|
||||
// copy of the general folder has no file to adopt again. A CHECK allows them only without account, so
|
||||
// the link is cleared here, not by ON DELETE SET NULL. Job items keep only the SET NULL: they are not
|
||||
// what «già copiato» reads.
|
||||
w.Command("""
|
||||
UPDATE export_copy SET account_id = NULL,
|
||||
removed_account_instagram_id = (SELECT instagram_id FROM account WHERE id = @id),
|
||||
removed_account_username = (SELECT username FROM account WHERE id = @id)
|
||||
WHERE account_id = @id
|
||||
""").With("@id", accountId).ExecuteNonQuery();
|
||||
w.Command("DELETE FROM account WHERE id = @id").With("@id", accountId).ExecuteNonQuery();
|
||||
},
|
||||
ct);
|
||||
|
||||
Reference in new issue
Block a user