1
0
Fork 0
mirror of https://github.com/chrislusf/seaweedfs synced 2024-07-05 08:36:55 +02:00

disable async file deletion

This commit is contained in:
Chris Lu 2019-01-05 22:51:50 -08:00
parent be9a7592a1
commit bd32108a90
3 changed files with 21 additions and 9 deletions

View file

@ -329,7 +329,7 @@ func (dir *Dir) removeOneFile(ctx context.Context, req *fuse.RemoveRequest) erro
return err
}
dir.wfs.asyncDeleteFileChunks(entry.Chunks)
dir.wfs.deleteFileChunks(entry.Chunks)
return dir.wfs.withFilerClient(func(client filer_pb.SeaweedFilerClient) error {

View file

@ -220,7 +220,7 @@ func (fh *FileHandle) Flush(ctx context.Context, req *fuse.FlushRequest) error {
chunks, garbages := filer2.CompactFileChunks(fh.f.entry.Chunks)
fh.f.entry.Chunks = chunks
// fh.f.entryViewCache = nil
fh.f.wfs.asyncDeleteFileChunks(garbages)
fh.f.wfs.deleteFileChunks(garbages)
if _, err := client.CreateEntry(ctx, request); err != nil {
return fmt.Errorf("update fh: %v", err)

View file

@ -35,12 +35,24 @@ func (wfs *WFS) loopProcessingDeletion() {
}
func (wfs *WFS) asyncDeleteFileChunks(chunks []*filer_pb.FileChunk) {
if len(chunks) > 0 {
var fileIds []string
for _, chunk := range chunks {
fileIds = append(fileIds, chunk.FileId)
}
wfs.fileIdsDeletionChan <- fileIds
func (wfs *WFS) deleteFileChunks(chunks []*filer_pb.FileChunk) {
if len(chunks) == 0 {
return
}
var fileIds []string
for _, chunk := range chunks {
fileIds = append(fileIds, chunk.FileId)
}
var async = false
if async {
wfs.fileIdsDeletionChan <- fileIds
return
}
wfs.withFilerClient(func(client filer_pb.SeaweedFilerClient) error {
deleteFileIds(context.Background(), client, fileIds)
return nil
})
}