Skip to content

Commit

Permalink
cmd/gc: fix the issue that objects may be deleted by mistake in large…
Browse files Browse the repository at this point in the history
… systems (#5068)
  • Loading branch information
SandyXSD committed Aug 27, 2024
1 parent b56edd3 commit d65df61
Showing 1 changed file with 10 additions and 10 deletions.
20 changes: 10 additions & 10 deletions cmd/gc.go
Original file line number Diff line number Diff line change
Expand Up @@ -110,6 +110,16 @@ func gc(ctx *cli.Context) error {
if (delete || compact) && threads <= 0 {
logger.Fatal("threads should be greater than 0 to delete or compact objects")
}
maxMtime := time.Now().Add(time.Hour * -1)
strDuration := os.Getenv("JFS_GC_SKIPPEDTIME")
if strDuration != "" {
iDuration, err := strconv.Atoi(strDuration)
if err == nil {
maxMtime = time.Now().Add(time.Second * -1 * time.Duration(iDuration))
} else {
logger.Errorf("parse JFS_GC_SKIPPEDTIME=%s: %s", strDuration, err)
}
}

var wg sync.WaitGroup
var delSpin *utils.Bar
Expand Down Expand Up @@ -262,16 +272,6 @@ func gc(ctx *cli.Context) error {
compacted := progress.AddDoubleSpinnerTwo("Compacted objects", "Compacted data")
leaked := progress.AddDoubleSpinnerTwo("Leaked objects", "Leaked data")
skipped := progress.AddDoubleSpinnerTwo("Skipped objects", "Skipped data")
maxMtime := time.Now().Add(time.Hour * -1)
strDuration := os.Getenv("JFS_GC_SKIPPEDTIME")
if strDuration != "" {
iDuration, err := strconv.Atoi(strDuration)
if err == nil {
maxMtime = time.Now().Add(time.Second * -1 * time.Duration(iDuration))
} else {
logger.Errorf("parse JFS_GC_SKIPPEDTIME=%s: %s", strDuration, err)
}
}

var leakedObj = make(chan string, 10240)
for i := 0; i < threads; i++ {
Expand Down

0 comments on commit d65df61

Please sign in to comment.