Chris Lu
4 years ago
17 changed files with 28 additions and 131 deletions
-
1weed/command/mount_std.go
-
6weed/filer/reader_at.go
-
5weed/filesys/dir.go
-
5weed/filesys/file.go
-
6weed/filesys/filehandle.go
-
13weed/filesys/wfs.go
-
84weed/filesys/wfs_deletion.go
-
7weed/filesys/wfs_filer_client.go
-
5weed/filesys/wfs_write.go
-
4weed/messaging/broker/broker_append.go
-
3weed/operation/delete_content.go
-
1weed/pb/filer_pb/filer_client.go
-
3weed/replication/sink/filersink/fetch_write.go
-
4weed/replication/source/filer_source.go
-
3weed/s3api/s3api_handlers.go
-
5weed/server/webdav_server.go
-
4weed/shell/commands.go
@ -1,84 +0,0 @@ |
|||
package filesys |
|||
|
|||
import ( |
|||
"context" |
|||
|
|||
"google.golang.org/grpc" |
|||
|
|||
"github.com/chrislusf/seaweedfs/weed/filer" |
|||
"github.com/chrislusf/seaweedfs/weed/glog" |
|||
"github.com/chrislusf/seaweedfs/weed/operation" |
|||
"github.com/chrislusf/seaweedfs/weed/pb/filer_pb" |
|||
) |
|||
|
|||
func (wfs *WFS) deleteFileChunks(chunks []*filer_pb.FileChunk) { |
|||
if len(chunks) == 0 { |
|||
return |
|||
} |
|||
|
|||
var fileIds []string |
|||
for _, chunk := range chunks { |
|||
if !chunk.IsChunkManifest { |
|||
fileIds = append(fileIds, chunk.GetFileIdString()) |
|||
continue |
|||
} |
|||
dataChunks, manifestResolveErr := filer.ResolveOneChunkManifest(filer.LookupFn(wfs), chunk) |
|||
if manifestResolveErr != nil { |
|||
glog.V(0).Infof("failed to resolve manifest %s: %v", chunk.FileId, manifestResolveErr) |
|||
} |
|||
for _, dChunk := range dataChunks { |
|||
fileIds = append(fileIds, dChunk.GetFileIdString()) |
|||
} |
|||
fileIds = append(fileIds, chunk.GetFileIdString()) |
|||
} |
|||
|
|||
wfs.WithFilerClient(func(client filer_pb.SeaweedFilerClient) error { |
|||
wfs.deleteFileIds(wfs.option.GrpcDialOption, client, fileIds) |
|||
return nil |
|||
}) |
|||
} |
|||
|
|||
func (wfs *WFS) deleteFileIds(grpcDialOption grpc.DialOption, client filer_pb.SeaweedFilerClient, fileIds []string) error { |
|||
|
|||
var vids []string |
|||
for _, fileId := range fileIds { |
|||
vids = append(vids, filer.VolumeId(fileId)) |
|||
} |
|||
|
|||
lookupFunc := func(vids []string) (map[string]operation.LookupResult, error) { |
|||
|
|||
m := make(map[string]operation.LookupResult) |
|||
|
|||
glog.V(4).Infof("deleteFileIds lookup volume id locations: %v", vids) |
|||
resp, err := client.LookupVolume(context.Background(), &filer_pb.LookupVolumeRequest{ |
|||
VolumeIds: vids, |
|||
}) |
|||
if err != nil { |
|||
return m, err |
|||
} |
|||
|
|||
for _, vid := range vids { |
|||
lr := operation.LookupResult{ |
|||
VolumeId: vid, |
|||
Locations: nil, |
|||
} |
|||
locations, found := resp.LocationsMap[vid] |
|||
if !found { |
|||
continue |
|||
} |
|||
for _, loc := range locations.Locations { |
|||
lr.Locations = append(lr.Locations, operation.Location{ |
|||
Url: wfs.AdjustedUrl(loc), |
|||
PublicUrl: loc.PublicUrl, |
|||
}) |
|||
} |
|||
m[vid] = lr |
|||
} |
|||
|
|||
return m, err |
|||
} |
|||
|
|||
_, err := operation.DeleteFilesWithLookupVolumeId(grpcDialOption, fileIds, lookupFunc) |
|||
|
|||
return err |
|||
} |
Write
Preview
Loading…
Cancel
Save
Reference in new issue