diff --git a/weed/filer/filer_delete_entry.go b/weed/filer/filer_delete_entry.go index cfe07ec5a..8b90f8c00 100644 --- a/weed/filer/filer_delete_entry.go +++ b/weed/filer/filer_delete_entry.go @@ -53,7 +53,11 @@ func (f *Filer) DeleteEntryMetaAndData(ctx context.Context, p util.FullPath, isR } if shouldDeleteChunks && !isDeleteCollection { - f.DeleteChunks(ctx, p, entry.GetChunks()) + if len(entry.HardLinkId) != 0 && entry.HardLinkCounter > 1 { + // if the file is a hard link and there are other hard links, do not delete the chunks + } else { + f.DeleteChunks(ctx, p, entry.GetChunks()) + } } if isDeleteCollection { diff --git a/weed/mount/weedfs_file_mkrm.go b/weed/mount/weedfs_file_mkrm.go index 5734e9df8..4fcaea4fa 100644 --- a/weed/mount/weedfs_file_mkrm.go +++ b/weed/mount/weedfs_file_mkrm.go @@ -140,8 +140,9 @@ func (wfs *WFS) Unlink(cancel <-chan struct{}, header *fuse.InHeader, name strin // first, ensure the filer store can correctly delete glog.V(3).Infof("remove file: %v", entryFullPath) - isDeleteData := entry != nil && entry.HardLinkCounter <= 1 - err := filer_pb.Remove(context.Background(), wfs, string(dirFullPath), name, isDeleteData, false, false, false, []int32{wfs.signature}) + // Always let the filer decide whether to delete chunks based on its authoritative data. + // The filer has the correct hard link count and will only delete chunks when appropriate. + err := filer_pb.Remove(context.Background(), wfs, string(dirFullPath), name, true, false, false, false, []int32{wfs.signature}) if err != nil { glog.V(0).Infof("remove %s: %v", entryFullPath, err) return fuse.OK