Skip to content

Commit

Permalink
sync: add dummy transfers for skipped files
Browse files Browse the repository at this point in the history
  • Loading branch information
Michal-Leszczynski committed Nov 21, 2023
1 parent c807a75 commit 39b1bed
Showing 1 changed file with 14 additions and 5 deletions.
19 changes: 14 additions & 5 deletions fs/sync/sync.go
Original file line number Diff line number Diff line change
Expand Up @@ -288,9 +288,10 @@ func (s *syncCopyMove) processError(err error) {
}

// Returns the current error (if any) in the order of precedence
// fatalErr
// normal error
// noRetryErr
//
// fatalErr
// normal error
// noRetryErr
func (s *syncCopyMove) currentError() error {
s.errorMu.Lock()
defer s.errorMu.Unlock()
Expand All @@ -317,6 +318,7 @@ func (s *syncCopyMove) pairChecker(in *pipe, out *pipe, fraction int, wg *sync.W
var err error
tr := accounting.Stats(s.ctx).NewCheckingTransfer(src)
// Check to see if can store this
ok = false
if src.Storable() {
NoNeedTransfer, err := operations.CompareOrCopyDest(s.ctx, s.fdst, pair.Dst, pair.Src, s.compareCopyDest, s.backupDir)
if err != nil {
Expand Down Expand Up @@ -361,6 +363,10 @@ 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)
}
tr.Done(s.ctx, err)
}
}
Expand Down Expand Up @@ -829,11 +835,11 @@ func (s *syncCopyMove) tryRename(src fs.Object) bool {

// Syncs fsrc into fdst
//
// If paths is provided then only those paths will be synced
// # If paths is provided then only those paths will be synced
//
// If Delete is true then it deletes any files in fdst that aren't in fsrc
//
// If DoMove is true then files will be moved instead of copied
// # If DoMove is true then files will be moved instead of copied
//
// dir is the start directory, "" for root
func (s *syncCopyMove) run() error {
Expand Down Expand Up @@ -1005,6 +1011,9 @@ func (s *syncCopyMove) SrcOnly(src fs.DirEntry) (recurse bool) {
if !ok {
return
}
} else {
// Record dummy transfer for calculating skipped bytes of skipped files
accounting.Stats(s.ctx).NewTransfer(x).Done(s.ctx, err)
}
}
case fs.Directory:
Expand Down

0 comments on commit 39b1bed

Please sign in to comment.