Browse Source

error checking for remove

pull/1255/head
Chris Lu 5 years ago
parent
commit
712720864d
  1. 7
      weed/pb/filer_pb/filer_client.go

7
weed/pb/filer_pb/filer_client.go

@ -2,6 +2,7 @@ package filer_pb
import ( import (
"context" "context"
"errors"
"fmt" "fmt"
"io" "io"
"math" "math"
@ -207,7 +208,7 @@ func MkFile(filerClient FilerClient, parentDirectoryPath string, fileName string
func Remove(filerClient FilerClient, parentDirectoryPath string, name string, isDeleteData, isRecursive, ignoreRecursiveErr bool) error { func Remove(filerClient FilerClient, parentDirectoryPath string, name string, isDeleteData, isRecursive, ignoreRecursiveErr bool) error {
return filerClient.WithFilerClient(func(client SeaweedFilerClient) error { return filerClient.WithFilerClient(func(client SeaweedFilerClient) error {
if _, err := client.DeleteEntry(context.Background(), &DeleteEntryRequest{
if resp, err := client.DeleteEntry(context.Background(), &DeleteEntryRequest{
Directory: parentDirectoryPath, Directory: parentDirectoryPath,
Name: name, Name: name,
IsDeleteData: isDeleteData, IsDeleteData: isDeleteData,
@ -215,6 +216,10 @@ func Remove(filerClient FilerClient, parentDirectoryPath string, name string, is
IgnoreRecursiveError: ignoreRecursiveErr, IgnoreRecursiveError: ignoreRecursiveErr,
}); err != nil { }); err != nil {
return err return err
} else {
if resp.Error != "" {
return errors.New(resp.Error)
}
} }
return nil return nil

Loading…
Cancel
Save