Skip to content

Commit

Permalink
Add skip/process logging
Browse files Browse the repository at this point in the history
  • Loading branch information
adreed-msft committed Jan 11, 2023
1 parent 8eb935e commit 406ff8b
Showing 1 changed file with 12 additions and 1 deletion.
13 changes: 12 additions & 1 deletion cmd/syncComparator.go
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@
package cmd

import (
"fmt"
"github.com/Azure/azure-pipeline-go/pipeline"
"github.com/Azure/azure-storage-azcopy/v10/common"
"reflect"
Expand Down Expand Up @@ -73,15 +74,21 @@ func (f *syncDestinationComparator) processIfNecessary(destinationObject StoredO
switch f.comparisonHashType {
case common.ESyncHashType.MD5():
if !reflect.DeepEqual(sourceObjectInMap.md5, destinationObject.md5) {
azcopyScanningLogger.Log(pipeline.LogDebug, fmt.Sprintf("File %s overwritten due to differing hash.", destinationObject.relativePath))
// hash inequality = source "newer" in this model.
return f.copyTransferScheduler(sourceObjectInMap)
}
default:
panic("sanity check: unsupported hash type " + f.comparisonHashType.String())
}

azcopyScanningLogger.Log(pipeline.LogDebug, fmt.Sprintf("File %s skipped due to same hash.", destinationObject.relativePath))
return nil
} else if sourceObjectInMap.isMoreRecentThan(destinationObject) {
return f.copyTransferScheduler(sourceObjectInMap)
}

azcopyScanningLogger.Log(pipeline.LogDebug, fmt.Sprintf("File %s skipped due to destination being newer", destinationObject.relativePath))
} 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 Down Expand Up @@ -137,17 +144,21 @@ func (f *syncSourceComparator) processIfNecessary(sourceObject StoredObject) err
case common.ESyncHashType.MD5():
if !reflect.DeepEqual(sourceObject.md5, destinationObjectInMap.md5) {
// hash inequality = source "newer" in this model.
azcopyScanningLogger.Log(pipeline.LogDebug, fmt.Sprintf("File %s overwritten due to differing hash.", sourceObject.relativePath))
return f.copyTransferScheduler(sourceObject)
}
default:
panic("sanity check: unsupported hash type " + f.comparisonHashType.String())
}

azcopyScanningLogger.Log(pipeline.LogDebug, fmt.Sprintf("File %s skipped due to same hash.", sourceObject.relativePath))
return nil
} else if sourceObject.isMoreRecentThan(destinationObjectInMap) {
// if destination is stale, schedule source
return f.copyTransferScheduler(sourceObject)
}

azcopyScanningLogger.Log(pipeline.LogDebug, "Object "+sourceObject.name+" skipped")
azcopyScanningLogger.Log(pipeline.LogDebug, fmt.Sprintf("File %s skipped due to destination being newer", sourceObject.relativePath))
// skip if dest is more recent
return nil
}
Expand Down

0 comments on commit 406ff8b

Please sign in to comment.