From 9dd09bbb332e5e12d7a20df560edafb7c800ddc9 Mon Sep 17 00:00:00 2001 From: Chris Lu Date: Thu, 24 Jun 2021 17:22:53 -0700 Subject: [PATCH] refactor --- weed/shell/command_volume_fsck.go | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/weed/shell/command_volume_fsck.go b/weed/shell/command_volume_fsck.go index 1fbc9ad35..d6c9e796f 100644 --- a/weed/shell/command_volume_fsck.go +++ b/weed/shell/command_volume_fsck.go @@ -92,6 +92,12 @@ func (c *commandVolumeFsck) Do(args []string, commandEnv *CommandEnv, writer io. } // volume file ids substract filer file ids + err = c.findExtraChunksInVolumeServers(volumeIdToVInfo, tempFolder, writer, verbose, applyPurging) + + return err +} + +func (c *commandVolumeFsck) findExtraChunksInVolumeServers(volumeIdToVInfo map[uint32]VInfo, tempFolder string, writer io.Writer, verbose *bool, applyPurging *bool) (error) { var totalInUseCount, totalOrphanChunkCount, totalOrphanDataSize uint64 for volumeId, vinfo := range volumeIdToVInfo { inUseCount, orphanFileIds, orphanDataSize, checkErr := c.oneVolumeFileIdsSubtractFilerFileIds(tempFolder, volumeId, writer, *verbose) @@ -112,7 +118,7 @@ func (c *commandVolumeFsck) Do(args []string, commandEnv *CommandEnv, writer io. if vinfo.isEcVolume { fmt.Fprintf(writer, "Skip purging for Erasure Coded volumes.\n") } - if err = c.purgeFileIdsForOneVolume(volumeId, orphanFileIds, writer); err != nil { + if err := c.purgeFileIdsForOneVolume(volumeId, orphanFileIds, writer); err != nil { return fmt.Errorf("purge for volume %d: %v\n", volumeId, err) } } @@ -130,7 +136,6 @@ func (c *commandVolumeFsck) Do(args []string, commandEnv *CommandEnv, writer io. fmt.Fprintf(writer, "This could be normal if multiple filers or no filers are used.\n") } - return nil }