Browse Source

disable async file deletion

pull/816/head
Chris Lu 6 years ago
parent
commit
bd32108a90
  1. 2
      weed/filesys/dir.go
  2. 2
      weed/filesys/filehandle.go
  3. 24
      weed/filesys/wfs_deletion.go

2
weed/filesys/dir.go

@ -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 {

2
weed/filesys/filehandle.go

@ -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)

24
weed/filesys/wfs_deletion.go

@ -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)
}
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
})
}
Loading…
Cancel
Save