From 8016ad6961eaafe339ad3f376b6e9387b5687cef Mon Sep 17 00:00:00 2001 From: Chris Lu Date: Mon, 9 Feb 2026 13:09:57 -0800 Subject: [PATCH] fix issue #8230: volume.fsck deletion logic to respect purgeAbsent flag This commit fixes two issues in volume.fsck: 1. Missing chunks in existing volumes are now deleted if -reallyDeleteFilerEntries is set. 2. Missing volumes are now properly handled when a -volumeId filter is specified, allowing deletion of filer entries for those volumes. --- weed/shell/command_volume_fsck.go | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/weed/shell/command_volume_fsck.go b/weed/shell/command_volume_fsck.go index e9b2d1521..d7dae202a 100644 --- a/weed/shell/command_volume_fsck.go +++ b/weed/shell/command_volume_fsck.go @@ -198,7 +198,7 @@ func (c *commandVolumeFsck) Do(args []string, commandEnv *CommandEnv, writer io. } for dataNodeId, volumeIdToVInfo := range dataNodeVolumeIdToVInfo { // for each volume, check filer file ids - if err = c.findFilerChunksMissingInVolumeServers(volumeIdToVInfo, dataNodeId, *applyPurging); err != nil { + if err = c.findFilerChunksMissingInVolumeServers(volumeIdToVInfo, dataNodeId, *applyPurging || *purgeAbsent); err != nil { return fmt.Errorf("findFilerChunksMissingInVolumeServers: %w", err) } } @@ -284,9 +284,15 @@ func (c *commandVolumeFsck) collectFilerFileIdAndPaths(dataNodeVolumeIdToVInfo m if _, err := f.Write([]byte(i.path)); err != nil { return err } - } else if *c.findMissingChunksInFiler && len(c.volumeIds) == 0 { + } else if *c.findMissingChunksInFiler { fmt.Fprintf(c.writer, "%d,%x%08x %s volume not found\n", i.vid, i.fileKey, i.cookie, i.path) if purgeAbsent { + // check if the volume matches the filter + if len(c.volumeIds) > 0 { + if _, ok := c.volumeIds[i.vid]; !ok { + continue + } + } fmt.Printf("deleting path %s after volume not found", i.path) c.httpDelete(i.path) }