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 totalUploadedFileChunkLength int64 // total length of uploaded file chunks
|
||||||
var totalUploadedFileChunkBytes int64 // how many actual bytes have been uploaded
|
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 totalUploadedSnapshotChunkLength int64 // size of uploaded snapshot chunks
|
||||||
var totalUploadedSnapshotChunkBytes int64 // how many actual bytes have been uploaded
|
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())
|
LOG_DEBUG("CHUNK_CACHE", "Skipped chunk %s in cache", chunk.GetID())
|
||||||
} else {
|
} else {
|
||||||
if uploadSize > 0 {
|
if uploadSize > 0 {
|
||||||
numberOfNewFileChunks++
|
atomic.AddInt64(&numberOfNewFileChunks, 1)
|
||||||
totalUploadedFileChunkLength += int64(chunkSize)
|
atomic.AddInt64(&totalUploadedFileChunkLength, int64(chunkSize))
|
||||||
totalUploadedFileChunkBytes += int64(uploadSize)
|
atomic.AddInt64(&totalUploadedFileChunkBytes, int64(uploadSize))
|
||||||
action = "Uploaded"
|
action = "Uploaded"
|
||||||
} else {
|
} else {
|
||||||
LOG_DEBUG("CHUNK_EXIST", "Skipped chunk %s in the storage", chunk.GetID())
|
LOG_DEBUG("CHUNK_EXIST", "Skipped chunk %s in the storage", chunk.GetID())
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
uploadedModifiedFileSize += int64(chunkSize)
|
uploadedModifiedFileSize := atomic.AddInt64(&uploadedModifiedFileSize, int64(chunkSize))
|
||||||
|
|
||||||
if IsTracing() || showStatistics {
|
if IsTracing() || showStatistics {
|
||||||
now := time.Now().Unix()
|
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
|
// This function is called when a new file is needed
|
||||||
entry := fileReader.CurrentEntry
|
entry := fileReader.CurrentEntry
|
||||||
entry.Hash = hash
|
entry.Hash = hash
|
||||||
if entry.Size != fileSize {
|
entry.Size = fileSize
|
||||||
totalModifiedFileSize += fileSize - entry.Size
|
|
||||||
entry.Size = fileSize
|
|
||||||
}
|
|
||||||
uploadedEntries = append(uploadedEntries, entry)
|
uploadedEntries = append(uploadedEntries, entry)
|
||||||
|
|
||||||
if !showStatistics || IsTracing() || RunInBackground {
|
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",
|
LOG_INFO("BACKUP_STATS", "All chunks: %d total, %s bytes; %d new, %s bytes, %s bytes uploaded",
|
||||||
len(localSnapshot.ChunkHashes) + totalSnapshotChunks,
|
len(localSnapshot.ChunkHashes) + totalSnapshotChunks,
|
||||||
PrettyNumber(totalFileChunkLength + totalSnapshotChunkLength),
|
PrettyNumber(totalFileChunkLength + totalSnapshotChunkLength),
|
||||||
numberOfNewFileChunks + numberOfNewSnapshotChunks,
|
int(numberOfNewFileChunks) + numberOfNewSnapshotChunks,
|
||||||
PrettyNumber(totalUploadedFileChunkLength + totalUploadedSnapshotChunkLength),
|
PrettyNumber(totalUploadedFileChunkLength + totalUploadedSnapshotChunkLength),
|
||||||
PrettyNumber(totalUploadedFileChunkBytes + totalUploadedSnapshotChunkBytes))
|
PrettyNumber(totalUploadedFileChunkBytes + totalUploadedSnapshotChunkBytes))
|
||||||
|
|
||||||
|
|||||||
@@ -149,6 +149,7 @@ func LoadIncompleteSnapshot() (snapshot *Snapshot) {
|
|||||||
snapshotFile := path.Join(GetDuplicacyPreferencePath(), "incomplete")
|
snapshotFile := path.Join(GetDuplicacyPreferencePath(), "incomplete")
|
||||||
description, err := ioutil.ReadFile(snapshotFile)
|
description, err := ioutil.ReadFile(snapshotFile)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
LOG_DEBUG("INCOMPLETE_LOCATE", "Failed to locate incomplete snapshot: %v", err)
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -156,6 +157,7 @@ func LoadIncompleteSnapshot() (snapshot *Snapshot) {
|
|||||||
|
|
||||||
err = json.Unmarshal(description, &incompleteSnapshot)
|
err = json.Unmarshal(description, &incompleteSnapshot)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
LOG_DEBUG("INCOMPLETE_PARSE", "Failed to parse incomplete snapshot: %v", err)
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -163,6 +165,7 @@ func LoadIncompleteSnapshot() (snapshot *Snapshot) {
|
|||||||
for _, chunkHash := range incompleteSnapshot.ChunkHashes {
|
for _, chunkHash := range incompleteSnapshot.ChunkHashes {
|
||||||
hash, err := hex.DecodeString(chunkHash)
|
hash, err := hex.DecodeString(chunkHash)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
LOG_DEBUG("INCOMPLETE_DECODE", "Failed to decode incomplete snapshot: %v", err)
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
chunkHashes = append(chunkHashes, string(hash))
|
chunkHashes = append(chunkHashes, string(hash))
|
||||||
@@ -181,7 +184,8 @@ func LoadIncompleteSnapshot() (snapshot *Snapshot) {
|
|||||||
func SaveIncompleteSnapshot(snapshot *Snapshot) {
|
func SaveIncompleteSnapshot(snapshot *Snapshot) {
|
||||||
var files []*Entry
|
var files []*Entry
|
||||||
for _, file := range snapshot.Files {
|
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
|
file.Attributes = nil
|
||||||
files = append(files, file)
|
files = append(files, file)
|
||||||
} else {
|
} else {
|
||||||
@@ -199,7 +203,7 @@ func SaveIncompleteSnapshot(snapshot *Snapshot) {
|
|||||||
ChunkLengths: snapshot.ChunkLengths,
|
ChunkLengths: snapshot.ChunkLengths,
|
||||||
}
|
}
|
||||||
|
|
||||||
description, err := json.Marshal(incompleteSnapshot)
|
description, err := json.MarshalIndent(incompleteSnapshot, "", " ")
|
||||||
if err != nil {
|
if err != nil {
|
||||||
LOG_WARN("INCOMPLETE_ENCODE", "Failed to encode the incomplete snapshot: %v", err)
|
LOG_WARN("INCOMPLETE_ENCODE", "Failed to encode the incomplete snapshot: %v", err)
|
||||||
return
|
return
|
||||||
|
|||||||
Reference in New Issue
Block a user