From 3aff83f0aaf9b537701059ec0e9021ff4e8568b7 Mon Sep 17 00:00:00 2001 From: Sourav Gupta Date: Wed, 23 Aug 2023 19:25:03 +0530 Subject: [PATCH 1/2] sync scan log fix --- cmd/syncComparator.go | 25 ++++++++++++++----------- 1 file changed, 14 insertions(+), 11 deletions(-) diff --git a/cmd/syncComparator.go b/cmd/syncComparator.go index 4b0e69793..5a3e19f40 100644 --- a/cmd/syncComparator.go +++ b/cmd/syncComparator.go @@ -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) { @@ -65,7 +65,7 @@ type syncDestinationComparator struct { comparisonHashType common.SyncHashType - preferSMBTime bool + preferSMBTime bool disableComparison bool } @@ -114,10 +114,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 @@ -139,7 +142,7 @@ type syncSourceComparator struct { comparisonHashType common.SyncHashType - preferSMBTime bool + preferSMBTime bool disableComparison bool } @@ -165,7 +168,7 @@ 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 { return f.copyTransferScheduler(sourceObject) } @@ -191,7 +194,7 @@ 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) } From fc3b05dd04c3e022db87558537a89115ef89bc1f Mon Sep 17 00:00:00 2001 From: Sourav Gupta Date: Thu, 24 Aug 2023 15:09:22 +0530 Subject: [PATCH 2/2] review comment --- cmd/syncComparator.go | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/cmd/syncComparator.go b/cmd/syncComparator.go index 5a3e19f40..8ac125042 100644 --- a/cmd/syncComparator.go +++ b/cmd/syncComparator.go @@ -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) } @@ -170,6 +171,7 @@ func (f *syncSourceComparator) processIfNecessary(sourceObject StoredObject) err // if destination is stale, schedule source for transfer if f.disableComparison { + syncComparatorLog(sourceObject.relativePath, syncStatusOverwritten, syncOverwriteReasonNewerHash, false) return f.copyTransferScheduler(sourceObject) } @@ -198,8 +200,8 @@ func (f *syncSourceComparator) processIfNecessary(sourceObject StoredObject) err return f.copyTransferScheduler(sourceObject) } - syncComparatorLog(sourceObject.relativePath, syncStatusSkipped, syncSkipReasonTime, false) // skip if dest is more recent + syncComparatorLog(sourceObject.relativePath, syncStatusSkipped, syncSkipReasonTime, false) return nil }