Skip to content

Commit

Permalink
sync: update skipped bytes on skipped files
Browse files Browse the repository at this point in the history
  • Loading branch information
Michal-Leszczynski committed Nov 22, 2023
1 parent 39b1bed commit 5ef09c5
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 9 deletions.
7 changes: 7 additions & 0 deletions fs/accounting/stats.go
Original file line number Diff line number Diff line change
Expand Up @@ -625,6 +625,13 @@ func (s *StatsInfo) DoneTransferring(remote string, ok bool) {
}
}

// UpdateSkipped marks file bytes as skipped in oldTransfers.
func (s *StatsInfo) UpdateSkipped(size int64) {
s.mu.Lock()
s.oldTransfers.Skipped += size
s.mu.Unlock()
}

// SetCheckQueue sets the number of queued checks
func (s *StatsInfo) SetCheckQueue(n int, size int64) {
s.mu.Lock()
Expand Down
7 changes: 2 additions & 5 deletions fs/accounting/transfer.go
Original file line number Diff line number Diff line change
Expand Up @@ -47,14 +47,11 @@ func (ai *AggregatedTransferInfo) update(t *Transfer) {
b, s = t.acc.progress()
}
ai.Size += s
switch {
case t.err != nil:
if t.err != nil {
ai.Failed += s
ai.Error = errors.Join(ai.Error, t.err)

Check failure on line 52 in fs/accounting/transfer.go

View workflow job for this annotation

GitHub Actions / go1.13

undefined: "errors".Join

Check failure on line 52 in fs/accounting/transfer.go

View workflow job for this annotation

GitHub Actions / other_os

undefined: "errors".Join

Check failure on line 52 in fs/accounting/transfer.go

View workflow job for this annotation

GitHub Actions / go1.14

undefined: "errors".Join

Check failure on line 52 in fs/accounting/transfer.go

View workflow job for this annotation

GitHub Actions / linux

undefined: "errors".Join

Check failure on line 52 in fs/accounting/transfer.go

View workflow job for this annotation

GitHub Actions / windows_386

undefined: "errors".Join

Check failure on line 52 in fs/accounting/transfer.go

View workflow job for this annotation

GitHub Actions / windows_amd64

undefined: "errors".Join

Check failure on line 52 in fs/accounting/transfer.go

View workflow job for this annotation

GitHub Actions / other_os

undefined: "errors".Join

Check failure on line 52 in fs/accounting/transfer.go

View workflow job for this annotation

GitHub Actions / go1.13

undefined: "errors".Join

Check failure on line 52 in fs/accounting/transfer.go

View workflow job for this annotation

GitHub Actions / linux

undefined: "errors".Join

Check failure on line 52 in fs/accounting/transfer.go

View workflow job for this annotation

GitHub Actions / go1.14

undefined: "errors".Join

Check failure on line 52 in fs/accounting/transfer.go

View workflow job for this annotation

GitHub Actions / windows_amd64

undefined: "errors".Join

Check failure on line 52 in fs/accounting/transfer.go

View workflow job for this annotation

GitHub Actions / windows_386

undefined: "errors".Join
case b > 0:
} else {
ai.Uploaded += b
default:
ai.Skipped += s
}
}

Expand Down
8 changes: 4 additions & 4 deletions fs/sync/sync.go
Original file line number Diff line number Diff line change
Expand Up @@ -364,8 +364,7 @@ func (s *syncCopyMove) pairChecker(in *pipe, out *pipe, fraction int, wg *sync.W
}
}
if !ok {
// Record dummy transfer for calculating skipped bytes of skipped files
accounting.Stats(s.ctx).NewTransfer(src).Done(s.ctx, err)
accounting.Stats(s.ctx).UpdateSkipped(tr.Snapshot().Size)
}
tr.Done(s.ctx, err)
}
Expand All @@ -387,6 +386,8 @@ func (s *syncCopyMove) pairRenamer(in *pipe, out *pipe, fraction int, wg *sync.W
if !ok {
return
}
} else {
accounting.Stats(s.ctx).UpdateSkipped(src.Size())
}
}
}
Expand Down Expand Up @@ -1012,8 +1013,7 @@ func (s *syncCopyMove) SrcOnly(src fs.DirEntry) (recurse bool) {
return
}
} else {
// Record dummy transfer for calculating skipped bytes of skipped files
accounting.Stats(s.ctx).NewTransfer(x).Done(s.ctx, err)
accounting.Stats(s.ctx).UpdateSkipped(x.Size())
}
}
case fs.Directory:
Expand Down

0 comments on commit 5ef09c5

Please sign in to comment.