diff --git a/weed/command/filer_remote_sync_dir.go b/weed/command/filer_remote_sync_dir.go index 7c040b575..1bf864f30 100644 --- a/weed/command/filer_remote_sync_dir.go +++ b/weed/command/filer_remote_sync_dir.go @@ -460,10 +460,8 @@ func isFailedPrecondition(err error) bool { if err == nil { return false } - if st, ok := status.FromError(err); ok && st.Code() == codes.FailedPrecondition { - return true - } - return strings.Contains(err.Error(), "precondition failed") + st, ok := status.FromError(err) + return ok && st.Code() == codes.FailedPrecondition } func isMultipartUploadFile(dir string, name string) bool { diff --git a/weed/command/filer_remote_sync_dir_test.go b/weed/command/filer_remote_sync_dir_test.go index 733b07719..5d45c0428 100644 --- a/weed/command/filer_remote_sync_dir_test.go +++ b/weed/command/filer_remote_sync_dir_test.go @@ -839,7 +839,7 @@ func TestIsFailedPrecondition(t *testing.T) { {"nil", nil, false}, {"status", refused, true}, {"wrapped status", fmt.Errorf("update entry: %w", refused), true}, - {"message only", errors.New("rpc error: code = FailedPrecondition desc = precondition failed: /f"), true}, + {"message only", errors.New("rpc error: code = FailedPrecondition desc = precondition failed: /f"), false}, {"other", status.Error(codes.Unavailable, "filer down"), false}, } for _, c := range cases {