Compare commits
2
Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
5682918723 | ||
|
|
098ed80990 |
No files matched your search
+3
-1205
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.findSnapshot(snapshotID, opts.LocalOnly)
|
inLocalIndex, err := v.checkSnapshotExists(snapshotID, opts.LocalOnly)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return result, err
|
return result, err
|
||||||
}
|
}
|
||||||
@@ -1540,15 +1540,20 @@ func (v *Vaultik) RemoveSnapshot(
|
|||||||
return result, nil
|
return result, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
// findSnapshot reports whether the local index has a row for
|
// checkSnapshotExists returns errSnapshotNotFound when the local index
|
||||||
// snapshotID, and returns errSnapshotNotFound when there is no row and,
|
// has no row for snapshotID and, unless localOnly is set, the
|
||||||
// unless localOnly is set, no metadata on the destination store either.
|
// destination store has no metadata for it either. inLocalIndex reports
|
||||||
// The destination store is consulted only when the local index has no
|
// whether the local index has that row. The destination store is
|
||||||
// row, so a snapshot in the local index can still be removed from it
|
// consulted only when the local index has no row, so a snapshot in the
|
||||||
// while the destination store is unreachable, and only after
|
// local index can still be removed from it while the destination store
|
||||||
// checkDestinationMarker passes, so an unplugged volume's empty mount
|
// is unreachable, and only after checkDestinationMarker passes, so an
|
||||||
// point is not taken for a store without the snapshot.
|
// unplugged volume's empty mount point is not taken for a store without
|
||||||
func (v *Vaultik) findSnapshot(snapshotID string, localOnly bool) (bool, error) {
|
// the snapshot.
|
||||||
|
//
|
||||||
|
//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 {
|
||||||
@@ -1565,7 +1570,7 @@ func (v *Vaultik) findSnapshot(snapshotID string, localOnly bool) (bool, error)
|
|||||||
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 findSnapshot).
|
// is an error (see checkSnapshotExists).
|
||||||
// - 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.findSnapshot(identifier, false)
|
_, err := v.checkSnapshotExists(identifier, false)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return "", err
|
return "", err
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in new issue
Block a user