fix: preserve snapshot symlinks and guard incomplete upgrade copies

This commit is contained in:
2026-10-18 10:12:53 +08:00
parent 1c244e135f
commit ed72985e7b
8 changed files with 192 additions and 45 deletions
+13
View File
@@ -74,6 +74,19 @@ func (a *API) recordSnapshot(i store.Instance, id, version, image string) error
func (a *API) snapshotCompatibility(i store.Instance, id string) (version, image, reason string) {
var exists int
if err := a.s.DB.QueryRow("SELECT count(*) FROM sqlite_master WHERE type='table' AND name='snapshot_copy_state'").Scan(&exists); err != nil {
return "", "", "snapshot completion metadata unavailable"
}
if exists != 0 {
var ready int
err := a.s.DB.QueryRow("SELECT ready FROM snapshot_copy_state WHERE instance_id=? AND id=?", i.ID, id).Scan(&ready)
if err != nil && !errors.Is(err, sql.ErrNoRows) {
return "", "", "snapshot completion metadata unavailable"
}
if err == nil && ready != 1 {
return "", "", "snapshot copy incomplete"
}
}
if err := a.s.DB.QueryRow("SELECT count(*) FROM sqlite_master WHERE type='table' AND name='snapshot_metadata'").Scan(&exists); err != nil {
return "", "", "snapshot metadata unavailable"
}