fix: preserve snapshot symlinks and guard incomplete upgrade copies
This commit is contained in:
@@ -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"
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user