mirror of
https://github.com/seaweedfs/seaweedfs.git
synced 2025-12-17 17:51:20 +08:00
grpc send error via response instead of grpc error
This commit is contained in:
@@ -132,27 +132,31 @@ func (fs *FilerServer) LookupVolume(ctx context.Context, req *filer_pb.LookupVol
|
||||
|
||||
func (fs *FilerServer) CreateEntry(ctx context.Context, req *filer_pb.CreateEntryRequest) (resp *filer_pb.CreateEntryResponse, err error) {
|
||||
|
||||
resp = &filer_pb.CreateEntryResponse{}
|
||||
|
||||
fullpath := filer2.FullPath(filepath.ToSlash(filepath.Join(req.Directory, req.Entry.Name)))
|
||||
chunks, garbages := filer2.CompactFileChunks(req.Entry.Chunks)
|
||||
|
||||
if req.Entry.Attributes == nil {
|
||||
glog.V(3).Infof("CreateEntry %s: nil attributes", filepath.Join(req.Directory, req.Entry.Name))
|
||||
return nil, fmt.Errorf("can not create entry with empty attributes")
|
||||
resp.Error = fmt.Sprintf("can not create entry with empty attributes")
|
||||
return
|
||||
}
|
||||
|
||||
err = fs.filer.CreateEntry(ctx, &filer2.Entry{
|
||||
createErr := fs.filer.CreateEntry(ctx, &filer2.Entry{
|
||||
FullPath: fullpath,
|
||||
Attr: filer2.PbToEntryAttribute(req.Entry.Attributes),
|
||||
Chunks: chunks,
|
||||
}, req.OExcl)
|
||||
|
||||
if err == nil {
|
||||
if createErr == nil {
|
||||
fs.filer.DeleteChunks(garbages)
|
||||
} else {
|
||||
glog.V(3).Infof("CreateEntry %s: %v", filepath.Join(req.Directory, req.Entry.Name), err)
|
||||
glog.V(3).Infof("CreateEntry %s: %v", filepath.Join(req.Directory, req.Entry.Name), createErr)
|
||||
resp.Error = createErr.Error()
|
||||
}
|
||||
|
||||
return &filer_pb.CreateEntryResponse{}, err
|
||||
return
|
||||
}
|
||||
|
||||
func (fs *FilerServer) UpdateEntry(ctx context.Context, req *filer_pb.UpdateEntryRequest) (*filer_pb.UpdateEntryResponse, error) {
|
||||
|
||||
@@ -155,7 +155,7 @@ func (fs *WebDavFileSystem) Mkdir(ctx context.Context, fullDirPath string, perm
|
||||
}
|
||||
|
||||
glog.V(1).Infof("mkdir: %v", request)
|
||||
if _, err := client.CreateEntry(ctx, request); err != nil {
|
||||
if err := filer_pb.CreateEntry(ctx, client, request); err != nil {
|
||||
return fmt.Errorf("mkdir %s/%s: %v", dir, name, err)
|
||||
}
|
||||
|
||||
@@ -187,7 +187,7 @@ func (fs *WebDavFileSystem) OpenFile(ctx context.Context, fullFilePath string, f
|
||||
|
||||
dir, name := filer2.FullPath(fullFilePath).DirAndName()
|
||||
err = fs.WithFilerClient(ctx, func(client filer_pb.SeaweedFilerClient) error {
|
||||
if _, err := client.CreateEntry(ctx, &filer_pb.CreateEntryRequest{
|
||||
if err := filer_pb.CreateEntry(ctx, client, &filer_pb.CreateEntryRequest{
|
||||
Directory: dir,
|
||||
Entry: &filer_pb.Entry{
|
||||
Name: name,
|
||||
|
||||
Reference in New Issue
Block a user