Compare commits
1
Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
2564116149 |
No files matched your search
+1205
-3
File diff suppressed because it is too large.
Load diff
@@ -1477,7 +1477,7 @@ func (v *Vaultik) RemoveSnapshot(
|
|||||||
return result, err
|
return result, err
|
||||||
}
|
}
|
||||||
|
|
||||||
inLocalIndex, err := v.checkSnapshotExists(snapshotID, opts.LocalOnly)
|
inLocalIndex, err := v.findSnapshot(snapshotID, opts.LocalOnly)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return result, err
|
return result, err
|
||||||
}
|
}
|
||||||
@@ -1540,20 +1540,15 @@ func (v *Vaultik) RemoveSnapshot(
|
|||||||
return result, nil
|
return result, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
// checkSnapshotExists returns errSnapshotNotFound when the local index
|
// findSnapshot reports whether the local index has a row for
|
||||||
// has no row for snapshotID and, unless localOnly is set, the
|
// snapshotID, and returns errSnapshotNotFound when there is no row and,
|
||||||
// destination store has no metadata for it either. inLocalIndex reports
|
// unless localOnly is set, no metadata on the destination store either.
|
||||||
// whether the local index has that row. The destination store is
|
// The destination store is consulted only when the local index has no
|
||||||
// consulted only when the local index has no row, so a snapshot in the
|
// row, so a snapshot in the local index can still be removed from it
|
||||||
// local index can still be removed from it while the destination store
|
// while the destination store is unreachable, and only after
|
||||||
// is unreachable, and only after checkDestinationMarker passes, so an
|
// checkDestinationMarker passes, so an unplugged volume's empty mount
|
||||||
// unplugged volume's empty mount point is not taken for a store without
|
// point is not taken for a store without the snapshot.
|
||||||
// the snapshot.
|
func (v *Vaultik) findSnapshot(snapshotID string, localOnly bool) (bool, error) {
|
||||||
//
|
|
||||||
//nolint:nonamedreturns // the result name says what the bool means
|
|
||||||
func (v *Vaultik) checkSnapshotExists(
|
|
||||||
snapshotID string, localOnly bool,
|
|
||||||
) (inLocalIndex bool, err error) {
|
|
||||||
if v.Repositories != nil {
|
if v.Repositories != nil {
|
||||||
snap, err := v.Repositories.Snapshots.GetByID(v.ctx, snapshotID)
|
snap, err := v.Repositories.Snapshots.GetByID(v.ctx, snapshotID)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
@@ -1570,7 +1565,7 @@ func (v *Vaultik) checkSnapshotExists(
|
|||||||
errSnapshotNotFound, snapshotID)
|
errSnapshotNotFound, snapshotID)
|
||||||
}
|
}
|
||||||
|
|
||||||
err = v.checkDestinationMarker()
|
err := v.checkDestinationMarker()
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return false, err
|
return false, err
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -30,7 +30,7 @@ var (
|
|||||||
// - A human snapshot ID (hostname_name_timestamp), which a host holding
|
// - A human snapshot ID (hostname_name_timestamp), which a host holding
|
||||||
// the local index has. It is hashed to its remote key. An ID that
|
// the local index has. It is hashed to its remote key. An ID that
|
||||||
// names no snapshot in the local index or on the destination store
|
// names no snapshot in the local index or on the destination store
|
||||||
// is an error (see checkSnapshotExists).
|
// is an error (see findSnapshot).
|
||||||
// - A remote key, or the leading part of one, which is all a host with
|
// - A remote key, or the leading part of one, which is all a host with
|
||||||
// no local index can know — it is exactly what `snapshot list` prints
|
// no local index can know — it is exactly what `snapshot list` prints
|
||||||
// for a remote-only snapshot (see formatRemoteOnlyID). It is resolved
|
// for a remote-only snapshot (see formatRemoteOnlyID). It is resolved
|
||||||
@@ -42,7 +42,7 @@ var (
|
|||||||
// RFC3339 timestamp).
|
// RFC3339 timestamp).
|
||||||
func (v *Vaultik) resolveSnapshotRemoteKey(identifier string) (string, error) {
|
func (v *Vaultik) resolveSnapshotRemoteKey(identifier string) (string, error) {
|
||||||
if !isRemoteKeyOrPrefix(identifier) {
|
if !isRemoteKeyOrPrefix(identifier) {
|
||||||
_, err := v.checkSnapshotExists(identifier, false)
|
_, err := v.findSnapshot(identifier, false)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return "", err
|
return "", err
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in new issue
Block a user