Browse Source

consolidate file chunks during create

pull/747/head
Chris Lu 6 years ago
parent
commit
13d6a74eb2
  1. 13
      weed/server/filer_grpc_server.go

13
weed/server/filer_grpc_server.go

@ -125,10 +125,19 @@ 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) {
fullpath := filer2.FullPath(filepath.Join(req.Directory, req.Entry.Name))
chunks, garbages := filer2.CompactFileChunks(req.Entry.Chunks)
for _, garbage := range garbages {
glog.V(0).Infof("deleting %s garbage chunk: %v, [%d, %d)", fullpath, garbage.FileId, garbage.Offset, garbage.Offset+int64(garbage.Size))
fs.filer.DeleteFileByFileId(garbage.FileId)
}
err = fs.filer.CreateEntry(&filer2.Entry{
FullPath: filer2.FullPath(filepath.Join(req.Directory, req.Entry.Name)),
FullPath: fullpath,
Attr: filer2.PbToEntryAttribute(req.Entry.Attributes),
Chunks: req.Entry.Chunks,
Chunks: chunks,
})
if err == nil {

Loading…
Cancel
Save