File tree Expand file tree Collapse file tree 2 files changed +28
-3
lines changed Expand file tree Collapse file tree 2 files changed +28
-3
lines changed Original file line number Diff line number Diff line change @@ -702,6 +702,31 @@ func (c *HTTPClient) fetchFileWithBuf(
702
702
return
703
703
}
704
704
705
+ func (c * HTTPClient ) Gc (
706
+ ctx context.Context ,
707
+ manager * storage.Manager ,
708
+ files map [string ]* StorageFileInfo ,
709
+ ) error {
710
+ errs := make ([]error , len (manager .Storages ))
711
+ var wg sync.WaitGroup
712
+ for i , s := range manager .Storages {
713
+ wg .Add (1 )
714
+ go func (i int , s storage.Storage ) {
715
+ defer wg .Done ()
716
+ errs [i ] = s .WalkDir (func (hash string , size int64 ) error {
717
+ info , ok := files [hash ]
718
+ ok = ok && slices .Contains (info .Storages , s )
719
+ if ! ok {
720
+ s .Remove (hash )
721
+ }
722
+ return nil
723
+ })
724
+ }(i , s )
725
+ }
726
+ wg .Wait ()
727
+ return errors .Join (errs ... )
728
+ }
729
+
705
730
func getHashMethod (l int ) (hashMethod crypto.Hash , err error ) {
706
731
switch l {
707
732
case 32 :
Original file line number Diff line number Diff line change @@ -543,9 +543,9 @@ func (r *Runner) InitSynchronizer(ctx context.Context) {
543
543
}
544
544
go r .UpdateFileRecords (fileMap , nil )
545
545
546
- // if !r.Config.Advanced.NoGC {
547
- // go r.cluster .Gc()
548
- // }
546
+ if ! r .Config .Advanced .NoGC {
547
+ go r .client .Gc (context . TODO (), r . storageManager , fileMap )
548
+ }
549
549
}
550
550
// else if fl != nil {
551
551
// if err := r.cluster.SetFilesetByExists(ctx, fl); err != nil {
You can’t perform that action at this time.
0 commit comments