mirror of
https://github.com/kopia/kopia.git
synced 2026-10-27 08:38:55 -04:00
b2: fixed handling of 'no_such_file' to indicate NOT_FOUND (#646)
Fixes #645
This commit is contained in:
1 parent
1636071f6b
commit
fd24227379
3 files changed
+15
-10
No files matched your search
@@ -32,6 +32,10 @@ func VerifyStorage(ctx context.Context, t testingT, r blob.Storage) {
|
||||
AssertGetBlobNotFound(ctx, t, r, b.blk)
|
||||
}
|
||||
|
||||
if err := r.DeleteBlob(ctx, "no-such-blob"); err != nil && !errors.Is(err, blob.ErrBlobNotFound) {
|
||||
t.Errorf("invalid error when deleting non-existent blob: %v", err)
|
||||
}
|
||||
|
||||
// Now add blocks.
|
||||
for _, b := range blocks {
|
||||
if err := r.PutBlob(ctx, b.blk, gather.FromSlice(b.contents)); err != nil {
|
||||
|
||||
@@ -21,9 +21,10 @@ type RetriableT struct {
|
||||
failedCount int32
|
||||
}
|
||||
|
||||
func (t *RetriableT) maybeSuppressAndSkip(cnt int32) {
|
||||
func (t *RetriableT) maybeSuppressAndSkip(cnt int32, msg string) {
|
||||
if t.suppressErrors {
|
||||
atomic.AddInt32(&t.failedCount, cnt)
|
||||
t.Logf("suppressing failure: %v", msg)
|
||||
t.SkipNow()
|
||||
|
||||
return
|
||||
@@ -33,56 +34,56 @@ func (t *RetriableT) maybeSuppressAndSkip(cnt int32) {
|
||||
// Fail wraps testing.T.Fail().
|
||||
func (t *RetriableT) Fail() {
|
||||
t.T.Helper()
|
||||
t.maybeSuppressAndSkip(1)
|
||||
t.maybeSuppressAndSkip(1, "Fail")
|
||||
t.T.Fail()
|
||||
}
|
||||
|
||||
// FailNow wraps testing.T.FailNow().
|
||||
func (t *RetriableT) FailNow() {
|
||||
t.T.Helper()
|
||||
t.maybeSuppressAndSkip(1)
|
||||
t.maybeSuppressAndSkip(1, "FailNow")
|
||||
t.T.FailNow()
|
||||
}
|
||||
|
||||
// Error wraps testing.T.Error().
|
||||
func (t *RetriableT) Error(args ...interface{}) {
|
||||
t.T.Helper()
|
||||
t.maybeSuppressAndSkip(1)
|
||||
t.maybeSuppressAndSkip(1, fmt.Sprint(args...))
|
||||
t.T.Error(args...)
|
||||
}
|
||||
|
||||
// Errorf wraps testing.T.Errorf().
|
||||
func (t *RetriableT) Errorf(msg string, args ...interface{}) {
|
||||
t.T.Helper()
|
||||
t.maybeSuppressAndSkip(1)
|
||||
t.maybeSuppressAndSkip(1, fmt.Sprintf(msg, args...))
|
||||
t.T.Errorf(msg, args...)
|
||||
}
|
||||
|
||||
// Fatal wraps testing.T.Fatal().
|
||||
func (t *RetriableT) Fatal(args ...interface{}) {
|
||||
t.T.Helper()
|
||||
t.maybeSuppressAndSkip(1)
|
||||
t.maybeSuppressAndSkip(1, fmt.Sprint(args...))
|
||||
t.T.Fatal(args...)
|
||||
}
|
||||
|
||||
// Fatalf wraps testing.T.Fatalf().
|
||||
func (t *RetriableT) Fatalf(msg string, args ...interface{}) {
|
||||
t.T.Helper()
|
||||
t.maybeSuppressAndSkip(1)
|
||||
t.maybeSuppressAndSkip(1, fmt.Sprintf(msg, args...))
|
||||
t.T.Fatalf(msg, args...)
|
||||
}
|
||||
|
||||
// Skip wraps testing.T.Skip().
|
||||
func (t *RetriableT) Skip(args ...interface{}) {
|
||||
t.T.Helper()
|
||||
t.maybeSuppressAndSkip(0)
|
||||
t.maybeSuppressAndSkip(0, fmt.Sprint(args...))
|
||||
t.T.Skip(args...)
|
||||
}
|
||||
|
||||
// Skipf wraps testing.T.Skipf().
|
||||
func (t *RetriableT) Skipf(msg string, args ...interface{}) {
|
||||
t.T.Helper()
|
||||
t.maybeSuppressAndSkip(0)
|
||||
t.maybeSuppressAndSkip(0, fmt.Sprintf(msg, args...))
|
||||
t.T.Skipf(msg, args...)
|
||||
}
|
||||
|
||||
|
||||
@@ -131,7 +131,7 @@ func translateError(err error) error {
|
||||
return blob.ErrBlobNotFound
|
||||
}
|
||||
|
||||
if b2err.Status == http.StatusBadRequest && b2err.Code == "already_hidden" {
|
||||
if b2err.Status == http.StatusBadRequest && (b2err.Code == "already_hidden" || b2err.Code == "no_such_file") {
|
||||
// Special case when hiding a file that is already hidden. It's basically
|
||||
// not found.
|
||||
return blob.ErrBlobNotFound
|
||||
|
||||
Reference in new issue
Block a user