mirror of
https://github.com/gilbertchen/duplicacy
synced 2025-12-15 07:43:21 +00:00
restored original stats output, enabled option to switch to tabular
This commit is contained in:
@@ -896,8 +896,67 @@ func (manager *SnapshotManager) CheckSnapshots(snapshotID string, revisionsToChe
|
|||||||
snapshotIDIndex += 1
|
snapshotIDIndex += 1
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if showTabular {
|
||||||
|
manager.ShowStatisticsTabular(snapshotMap, chunkSizeMap, chunkUniqueMap, chunkSnapshotMap)
|
||||||
|
} else if showStatistics {
|
||||||
|
manager.ShowStatistics(snapshotMap, chunkSizeMap, chunkUniqueMap, chunkSnapshotMap)
|
||||||
|
}
|
||||||
|
|
||||||
if showStatistics {
|
return true
|
||||||
|
}
|
||||||
|
|
||||||
|
// Print snapshot and revision statistics
|
||||||
|
func (manager *SnapshotManager) ShowStatistics(snapshotMap map[string] [] *Snapshot, chunkSizeMap map[string]int64, chunkUniqueMap map[string]bool,
|
||||||
|
chunkSnapshotMap map[string]int) {
|
||||||
|
for snapshotID, snapshotList := range snapshotMap {
|
||||||
|
|
||||||
|
snapshotChunks := make(map[string]bool)
|
||||||
|
|
||||||
|
for _, snapshot := range snapshotList {
|
||||||
|
|
||||||
|
chunks := make(map[string]bool)
|
||||||
|
for _, chunkID := range manager.GetSnapshotChunks(snapshot) {
|
||||||
|
chunks[chunkID] = true
|
||||||
|
snapshotChunks[chunkID] = true
|
||||||
|
}
|
||||||
|
|
||||||
|
var totalChunkSize int64
|
||||||
|
var uniqueChunkSize int64
|
||||||
|
|
||||||
|
for chunkID, _ := range chunks {
|
||||||
|
chunkSize := chunkSizeMap[chunkID]
|
||||||
|
totalChunkSize += chunkSize
|
||||||
|
if chunkUniqueMap[chunkID] {
|
||||||
|
uniqueChunkSize += chunkSize
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
files := ""
|
||||||
|
if snapshot.FileSize != 0 && snapshot.NumberOfFiles != 0 {
|
||||||
|
files = fmt.Sprintf("%d files (%s bytes), ", snapshot.NumberOfFiles, PrettyNumber(snapshot.FileSize))
|
||||||
|
}
|
||||||
|
LOG_INFO("SNAPSHOT_CHECK", "Snapshot %s at revision %d: %s%s total chunk bytes, %s unique chunk bytes",
|
||||||
|
snapshot.ID, snapshot.Revision, files, PrettyNumber(totalChunkSize), PrettyNumber(uniqueChunkSize))
|
||||||
|
}
|
||||||
|
|
||||||
|
var totalChunkSize int64
|
||||||
|
var uniqueChunkSize int64
|
||||||
|
for chunkID, _ := range snapshotChunks {
|
||||||
|
chunkSize := chunkSizeMap[chunkID]
|
||||||
|
totalChunkSize += chunkSize
|
||||||
|
|
||||||
|
if chunkSnapshotMap[chunkID] != -1 {
|
||||||
|
uniqueChunkSize += chunkSize
|
||||||
|
}
|
||||||
|
}
|
||||||
|
LOG_INFO("SNAPSHOT_CHECK", "Snapshot %s all revisions: %s total chunk bytes, %s unique chunk bytes",
|
||||||
|
snapshotID, PrettyNumber(totalChunkSize), PrettyNumber(uniqueChunkSize))
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// Print snapshot and revision statistics in tabular format
|
||||||
|
func (manager *SnapshotManager) ShowStatisticsTabular(snapshotMap map[string] [] *Snapshot, chunkSizeMap map[string]int64, chunkUniqueMap map[string]bool,
|
||||||
|
chunkSnapshotMap map[string]int) {
|
||||||
tableBuffer := new(bytes.Buffer)
|
tableBuffer := new(bytes.Buffer)
|
||||||
tableWriter := tabwriter.NewWriter(tableBuffer, 0, 0, 1, ' ', tabwriter.AlignRight|tabwriter.Debug)
|
tableWriter := tabwriter.NewWriter(tableBuffer, 0, 0, 1, ' ', tabwriter.AlignRight|tabwriter.Debug)
|
||||||
|
|
||||||
@@ -976,10 +1035,6 @@ func (manager *SnapshotManager) CheckSnapshots(snapshotID string, revisionsToChe
|
|||||||
}
|
}
|
||||||
tableWriter.Flush()
|
tableWriter.Flush()
|
||||||
LOG_INFO("SNAPSHOT_CHECK", tableBuffer.String())
|
LOG_INFO("SNAPSHOT_CHECK", tableBuffer.String())
|
||||||
}
|
|
||||||
|
|
||||||
return true
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// ConvertSequence converts a sequence of chunk hashes into a sequence of chunk ids.
|
// ConvertSequence converts a sequence of chunk hashes into a sequence of chunk ids.
|
||||||
|
|||||||
Reference in New Issue
Block a user