mirror of
https://github.com/gilbertchen/duplicacy
synced 2025-12-06 00:03:38 +00:00
Fixed incorrect stats during backup; also check in files missing from last commit
This commit is contained in:
@@ -259,11 +259,10 @@ func (manager *BackupManager) Backup(top string, quickMode bool, threads int, ta
|
||||
|
||||
}
|
||||
|
||||
var numberOfNewFileChunks int // number of new file chunks
|
||||
var numberOfNewFileChunks int64 // number of new file chunks
|
||||
var totalUploadedFileChunkLength int64 // total length of uploaded file chunks
|
||||
var totalUploadedFileChunkBytes int64 // how many actual bytes have been uploaded
|
||||
|
||||
var numberOfNewSnapshotChunks int // number of new snapshot chunks
|
||||
var totalUploadedSnapshotChunkLength int64 // size of uploaded snapshot chunks
|
||||
var totalUploadedSnapshotChunkBytes int64 // how many actual bytes have been uploaded
|
||||
|
||||
@@ -447,16 +446,16 @@ func (manager *BackupManager) Backup(top string, quickMode bool, threads int, ta
|
||||
LOG_DEBUG("CHUNK_CACHE", "Skipped chunk %s in cache", chunk.GetID())
|
||||
} else {
|
||||
if uploadSize > 0 {
|
||||
numberOfNewFileChunks++
|
||||
totalUploadedFileChunkLength += int64(chunkSize)
|
||||
totalUploadedFileChunkBytes += int64(uploadSize)
|
||||
atomic.AddInt64(&numberOfNewFileChunks, 1)
|
||||
atomic.AddInt64(&totalUploadedFileChunkLength, int64(chunkSize))
|
||||
atomic.AddInt64(&totalUploadedFileChunkBytes, int64(uploadSize))
|
||||
action = "Uploaded"
|
||||
} else {
|
||||
LOG_DEBUG("CHUNK_EXIST", "Skipped chunk %s in the storage", chunk.GetID())
|
||||
}
|
||||
}
|
||||
|
||||
uploadedModifiedFileSize += int64(chunkSize)
|
||||
uploadedModifiedFileSize := atomic.AddInt64(&uploadedModifiedFileSize, int64(chunkSize))
|
||||
|
||||
if IsTracing() || showStatistics {
|
||||
now := time.Now().Unix()
|
||||
@@ -527,10 +526,7 @@ func (manager *BackupManager) Backup(top string, quickMode bool, threads int, ta
|
||||
// This function is called when a new file is needed
|
||||
entry := fileReader.CurrentEntry
|
||||
entry.Hash = hash
|
||||
if entry.Size != fileSize {
|
||||
totalModifiedFileSize += fileSize - entry.Size
|
||||
entry.Size = fileSize
|
||||
}
|
||||
entry.Size = fileSize
|
||||
uploadedEntries = append(uploadedEntries, entry)
|
||||
|
||||
if !showStatistics || IsTracing() || RunInBackground {
|
||||
@@ -659,7 +655,7 @@ func (manager *BackupManager) Backup(top string, quickMode bool, threads int, ta
|
||||
LOG_INFO("BACKUP_STATS", "All chunks: %d total, %s bytes; %d new, %s bytes, %s bytes uploaded",
|
||||
len(localSnapshot.ChunkHashes) + totalSnapshotChunks,
|
||||
PrettyNumber(totalFileChunkLength + totalSnapshotChunkLength),
|
||||
numberOfNewFileChunks + numberOfNewSnapshotChunks,
|
||||
int(numberOfNewFileChunks) + numberOfNewSnapshotChunks,
|
||||
PrettyNumber(totalUploadedFileChunkLength + totalUploadedSnapshotChunkLength),
|
||||
PrettyNumber(totalUploadedFileChunkBytes + totalUploadedSnapshotChunkBytes))
|
||||
|
||||
|
||||
@@ -149,6 +149,7 @@ func LoadIncompleteSnapshot() (snapshot *Snapshot) {
|
||||
snapshotFile := path.Join(GetDuplicacyPreferencePath(), "incomplete")
|
||||
description, err := ioutil.ReadFile(snapshotFile)
|
||||
if err != nil {
|
||||
LOG_DEBUG("INCOMPLETE_LOCATE", "Failed to locate incomplete snapshot: %v", err)
|
||||
return nil
|
||||
}
|
||||
|
||||
@@ -156,6 +157,7 @@ func LoadIncompleteSnapshot() (snapshot *Snapshot) {
|
||||
|
||||
err = json.Unmarshal(description, &incompleteSnapshot)
|
||||
if err != nil {
|
||||
LOG_DEBUG("INCOMPLETE_PARSE", "Failed to parse incomplete snapshot: %v", err)
|
||||
return nil
|
||||
}
|
||||
|
||||
@@ -163,6 +165,7 @@ func LoadIncompleteSnapshot() (snapshot *Snapshot) {
|
||||
for _, chunkHash := range incompleteSnapshot.ChunkHashes {
|
||||
hash, err := hex.DecodeString(chunkHash)
|
||||
if err != nil {
|
||||
LOG_DEBUG("INCOMPLETE_DECODE", "Failed to decode incomplete snapshot: %v", err)
|
||||
return nil
|
||||
}
|
||||
chunkHashes = append(chunkHashes, string(hash))
|
||||
@@ -181,7 +184,8 @@ func LoadIncompleteSnapshot() (snapshot *Snapshot) {
|
||||
func SaveIncompleteSnapshot(snapshot *Snapshot) {
|
||||
var files []*Entry
|
||||
for _, file := range snapshot.Files {
|
||||
if file.EndChunk >= 0 {
|
||||
// All unprocessed files will have a size of -1
|
||||
if file.Size >= 0 {
|
||||
file.Attributes = nil
|
||||
files = append(files, file)
|
||||
} else {
|
||||
@@ -199,7 +203,7 @@ func SaveIncompleteSnapshot(snapshot *Snapshot) {
|
||||
ChunkLengths: snapshot.ChunkLengths,
|
||||
}
|
||||
|
||||
description, err := json.Marshal(incompleteSnapshot)
|
||||
description, err := json.MarshalIndent(incompleteSnapshot, "", " ")
|
||||
if err != nil {
|
||||
LOG_WARN("INCOMPLETE_ENCODE", "Failed to encode the incomplete snapshot: %v", err)
|
||||
return
|
||||
|
||||
Reference in New Issue
Block a user