Skip to content

Commit

Permalink
Allow two copy-compatible storages to have different compression levels
Browse files Browse the repository at this point in the history
This is useful for upgrading an existing storage to zstd compression or others.
Chunks need to be decompressed and re-compressed during copy anyway.  Only
the bit-identical option requires the same compression level

Also fix a typo: compatiable -> compatible
  • Loading branch information
gilbertchen committed Sep 18, 2023
1 parent cc482be commit 4e9d2c4
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 5 deletions.
2 changes: 1 addition & 1 deletion src/duplicacy_backupmanager.go
Expand Up @@ -1558,7 +1558,7 @@ func (manager *BackupManager) RestoreFile(chunkDownloader *ChunkDownloader, chun
func (manager *BackupManager) CopySnapshots(otherManager *BackupManager, snapshotID string,
revisionsToBeCopied []int, uploadingThreads int, downloadingThreads int) bool {

if !manager.config.IsCompatiableWith(otherManager.config) {
if !manager.config.IsCompatibleWith(otherManager.config) {
LOG_ERROR("CONFIG_INCOMPATIBLE", "Two storages are not compatible for the copy operation")
return false
}
Expand Down
8 changes: 4 additions & 4 deletions src/duplicacy_config.go
Expand Up @@ -169,10 +169,9 @@ func (config *Config) UnmarshalJSON(description []byte) (err error) {
return nil
}

func (config *Config) IsCompatiableWith(otherConfig *Config) bool {
func (config *Config) IsCompatibleWith(otherConfig *Config) bool {

return config.CompressionLevel == otherConfig.CompressionLevel &&
config.AverageChunkSize == otherConfig.AverageChunkSize &&
return config.AverageChunkSize == otherConfig.AverageChunkSize &&
config.MaximumChunkSize == otherConfig.MaximumChunkSize &&
config.MinimumChunkSize == otherConfig.MinimumChunkSize &&
bytes.Equal(config.ChunkSeed, otherConfig.ChunkSeed) &&
Expand Down Expand Up @@ -255,7 +254,6 @@ func CreateConfigFromParameters(compressionLevel int, averageChunkSize int, maxi
}

if copyFrom != nil {
config.CompressionLevel = copyFrom.CompressionLevel

config.AverageChunkSize = copyFrom.AverageChunkSize
config.MaximumChunkSize = copyFrom.MaximumChunkSize
Expand All @@ -265,6 +263,8 @@ func CreateConfigFromParameters(compressionLevel int, averageChunkSize int, maxi
config.HashKey = copyFrom.HashKey

if bitCopy {
config.CompressionLevel = copyFrom.CompressionLevel

config.IDKey = copyFrom.IDKey
config.ChunkKey = copyFrom.ChunkKey
config.FileKey = copyFrom.FileKey
Expand Down

3 comments on commit 4e9d2c4

@gilbertchen
Copy link
Owner Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This commit has been mentioned on Duplicacy Forum. There might be relevant details there:

https://forum.duplicacy.com/t/migrating-to-zstd/7957/3

@gilbertchen
Copy link
Owner Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This commit has been mentioned on Duplicacy Forum. There might be relevant details there:

https://forum.duplicacy.com/t/cli-release-3-2-0-is-now-available/7952/8

@gilbertchen
Copy link
Owner Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This commit has been mentioned on Duplicacy Forum. There might be relevant details there:

https://forum.duplicacy.com/t/duplicacy-cli-3-2-2-release/8019/1

Please sign in to comment.