Skip to content

Commit

Permalink
sync command scan log fix (#2348)
Browse files Browse the repository at this point in the history
  • Loading branch information
souravgupta-msft authored Aug 25, 2023
1 parent f8b3875 commit 77fcf6f
Showing 1 changed file with 17 additions and 12 deletions.
29 changes: 17 additions & 12 deletions cmd/syncComparator.go
Original file line number Diff line number Diff line change
Expand Up @@ -29,13 +29,13 @@ import (
)

const (
syncSkipReasonTime = "the source has an older LMT than the destination"
syncSkipReasonMissingHash = "the source lacks an associated hash; please upload with --put-md5"
syncSkipReasonSameHash = "the source has the same hash"
syncSkipReasonTime = "the source has an older LMT than the destination"
syncSkipReasonMissingHash = "the source lacks an associated hash; please upload with --put-md5"
syncSkipReasonSameHash = "the source has the same hash"
syncOverwriteReasonNewerHash = "the source has a differing hash"
syncOverwriteResaonNewerLMT = "the source is more recent than the destination"
syncStatusSkipped = "skipped"
syncStatusOverwritten = "overwritten"
syncOverwriteReasonNewerLMT = "the source is more recent than the destination"
syncStatusSkipped = "skipped"
syncStatusOverwritten = "overwritten"
)

func syncComparatorLog(fileName, status, skipReason string, stdout bool) {
Expand Down Expand Up @@ -65,7 +65,7 @@ type syncDestinationComparator struct {

comparisonHashType common.SyncHashType

preferSMBTime bool
preferSMBTime bool
disableComparison bool
}

Expand All @@ -90,6 +90,7 @@ func (f *syncDestinationComparator) processIfNecessary(destinationObject StoredO
defer delete(f.sourceIndex.indexMap, destinationObject.relativePath)

if f.disableComparison {
syncComparatorLog(sourceObjectInMap.relativePath, syncStatusOverwritten, syncOverwriteReasonNewerHash, false)
return f.copyTransferScheduler(sourceObjectInMap)
}

Expand All @@ -114,10 +115,13 @@ func (f *syncDestinationComparator) processIfNecessary(destinationObject StoredO
syncComparatorLog(sourceObjectInMap.relativePath, syncStatusSkipped, syncSkipReasonSameHash, false)
return nil
} else if sourceObjectInMap.isMoreRecentThan(destinationObject, f.preferSMBTime) {
// if destination is stale, schedule source
syncComparatorLog(sourceObjectInMap.relativePath, syncStatusOverwritten, syncOverwriteReasonNewerLMT, false)
return f.copyTransferScheduler(sourceObjectInMap)
}

syncComparatorLog(sourceObjectInMap.relativePath, syncStatusOverwritten, syncOverwriteResaonNewerLMT, false)
// skip if dest is more recent
syncComparatorLog(sourceObjectInMap.relativePath, syncStatusSkipped, syncSkipReasonTime, false)
} else {
// purposefully ignore the error from destinationCleaner
// it's a tolerable error, since it just means some extra destination object might hang around a bit longer
Expand All @@ -139,7 +143,7 @@ type syncSourceComparator struct {

comparisonHashType common.SyncHashType

preferSMBTime bool
preferSMBTime bool
disableComparison bool
}

Expand All @@ -165,8 +169,9 @@ func (f *syncSourceComparator) processIfNecessary(sourceObject StoredObject) err
if present {
defer delete(f.destinationIndex.indexMap, relPath)

// if destination is stale, schedule source for transfer
// if destination is stale, schedule source for transfer
if f.disableComparison {
syncComparatorLog(sourceObject.relativePath, syncStatusOverwritten, syncOverwriteReasonNewerHash, false)
return f.copyTransferScheduler(sourceObject)
}

Expand All @@ -191,12 +196,12 @@ func (f *syncSourceComparator) processIfNecessary(sourceObject StoredObject) err
return nil
} else if sourceObject.isMoreRecentThan(destinationObjectInMap, f.preferSMBTime) {
// if destination is stale, schedule source
syncComparatorLog(sourceObject.relativePath, syncStatusOverwritten, syncOverwriteResaonNewerLMT, false)
syncComparatorLog(sourceObject.relativePath, syncStatusOverwritten, syncOverwriteReasonNewerLMT, false)
return f.copyTransferScheduler(sourceObject)
}

syncComparatorLog(sourceObject.relativePath, syncStatusSkipped, syncSkipReasonTime, false)
// skip if dest is more recent
syncComparatorLog(sourceObject.relativePath, syncStatusSkipped, syncSkipReasonTime, false)
return nil
}

Expand Down

0 comments on commit 77fcf6f

Please sign in to comment.