aboutsummaryrefslogtreecommitdiff
path: root/weed/shell/command_volume_check_disk.go
diff options
context:
space:
mode:
authorLisandro Pin <lisandro.pin@proton.ch>2025-11-04 22:02:22 +0100
committerGitHub <noreply@github.com>2025-11-04 13:02:22 -0800
commitf466ff1412005f3db10de9dc4939e52cb4a2add8 (patch)
tree13d7a135fc7b20b94c95631b1477ad7b82ca6927 /weed/shell/command_volume_check_disk.go
parentf4f2718ba05b13c51f14a316c48a256da6a77fe8 (diff)
downloadseaweedfs-f466ff1412005f3db10de9dc4939e52cb4a2add8.tar.xz
seaweedfs-f466ff1412005f3db10de9dc4939e52cb4a2add8.zip
Nit: use `time.Duration`s instead of constants in seconds. (#7438)
Nit: use `time.Durations` instead of constants in seconds. Makes for slightly more readable code.
Diffstat (limited to 'weed/shell/command_volume_check_disk.go')
-rw-r--r--weed/shell/command_volume_check_disk.go7
1 files changed, 4 insertions, 3 deletions
diff --git a/weed/shell/command_volume_check_disk.go b/weed/shell/command_volume_check_disk.go
index a8cc72d4d..741df0dd4 100644
--- a/weed/shell/command_volume_check_disk.go
+++ b/weed/shell/command_volume_check_disk.go
@@ -88,7 +88,8 @@ func (c *commandVolumeCheckDisk) eqVolumeFileCount(a, b *VolumeReplica) (bool, b
return fileCountA == fileCountB, fileDeletedCountA == fileDeletedCountB
}
-func (c *commandVolumeCheckDisk) shouldSkipVolume(a, b *VolumeReplica, pulseTimeAtSecond int64, syncDeletions, verbose bool) bool {
+func (c *commandVolumeCheckDisk) shouldSkipVolume(a, b *VolumeReplica, pulseTime time.Time, syncDeletions, verbose bool) bool {
+ pulseTimeAtSecond := pulseTime.Unix()
doSyncDeletedCount := false
if syncDeletions && a.info.DeleteCount != b.info.DeleteCount {
doSyncDeletedCount = true
@@ -135,7 +136,7 @@ func (c *commandVolumeCheckDisk) Do(args []string, commandEnv *CommandEnv, write
c.writer = writer
// collect topology information
- pulseTimeAtSecond := time.Now().Unix() - constants.VolumePulseSeconds*2
+ pulseTime := time.Now().Add(-constants.VolumePulsePeriod * 2)
topologyInfo, _, err := collectTopologyInfo(commandEnv, 0)
if err != nil {
return err
@@ -162,7 +163,7 @@ func (c *commandVolumeCheckDisk) Do(args []string, commandEnv *CommandEnv, write
})
for len(writableReplicas) >= 2 {
a, b := writableReplicas[0], writableReplicas[1]
- if !*slowMode && c.shouldSkipVolume(a, b, pulseTimeAtSecond, *syncDeletions, *verbose) {
+ if !*slowMode && c.shouldSkipVolume(a, b, pulseTime, *syncDeletions, *verbose) {
// always choose the larger volume to be the source
writableReplicas = append(replicas[:1], writableReplicas[2:]...)
continue