mirror of
https://github.com/gilbertchen/duplicacy
synced 2025-12-18 09:13:17 +00:00
The cat command doesn't need to load the entire file into memory
It can print out the chunk as soon as a chunk is retrieved. This avoids reconstructing the file in the memory which can be an issue with large files.
This commit is contained in:
@@ -1285,15 +1285,14 @@ func (manager *SnapshotManager) PrintFile(snapshotID string, revision int, path
|
|||||||
}
|
}
|
||||||
|
|
||||||
file := manager.FindFile(snapshot, path, false)
|
file := manager.FindFile(snapshot, path, false)
|
||||||
var content []byte
|
if !manager.RetrieveFile(snapshot, file, func(chunk []byte) {
|
||||||
if !manager.RetrieveFile(snapshot, file, func(chunk []byte) { content = append(content, chunk...) }) {
|
fmt.Printf("%s", chunk)
|
||||||
|
}) {
|
||||||
LOG_ERROR("SNAPSHOT_RETRIEVE", "File %s is corrupted in snapshot %s at revision %d",
|
LOG_ERROR("SNAPSHOT_RETRIEVE", "File %s is corrupted in snapshot %s at revision %d",
|
||||||
path, snapshot.ID, snapshot.Revision)
|
path, snapshot.ID, snapshot.Revision)
|
||||||
return false
|
return false
|
||||||
}
|
}
|
||||||
|
|
||||||
fmt.Printf("%s", string(content))
|
|
||||||
|
|
||||||
return true
|
return true
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user