mirror of
https://github.com/gilbertchen/duplicacy
synced 2025-12-15 07:43:21 +00:00
Clear the attributes from last snapshot after loading to save memory
This commit is contained in:
@@ -750,7 +750,7 @@ func (manager *BackupManager) Restore(top string, revision int, inPlace bool, qu
|
|||||||
}
|
}
|
||||||
|
|
||||||
remoteSnapshot := manager.SnapshotManager.DownloadSnapshot(manager.snapshotID, revision)
|
remoteSnapshot := manager.SnapshotManager.DownloadSnapshot(manager.snapshotID, revision)
|
||||||
manager.SnapshotManager.DownloadSnapshotContents(remoteSnapshot, patterns)
|
manager.SnapshotManager.DownloadSnapshotContents(remoteSnapshot, patterns, true)
|
||||||
|
|
||||||
localSnapshot, _, _, err := CreateSnapshotFromDirectory(manager.snapshotID, top)
|
localSnapshot, _, _, err := CreateSnapshotFromDirectory(manager.snapshotID, top)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
|||||||
@@ -269,7 +269,7 @@ func (manager *SnapshotManager) DownloadSequence(sequence []string) (content []b
|
|||||||
return content
|
return content
|
||||||
}
|
}
|
||||||
|
|
||||||
func (manager *SnapshotManager) DownloadSnapshotFileSequence(snapshot *Snapshot, patterns []string) bool {
|
func (manager *SnapshotManager) DownloadSnapshotFileSequence(snapshot *Snapshot, patterns []string, attributesNeeded bool) bool {
|
||||||
|
|
||||||
manager.CreateChunkDownloader()
|
manager.CreateChunkDownloader()
|
||||||
|
|
||||||
@@ -304,7 +304,8 @@ func (manager *SnapshotManager) DownloadSnapshotFileSequence(snapshot *Snapshot,
|
|||||||
return false
|
return false
|
||||||
}
|
}
|
||||||
|
|
||||||
if len(patterns) != 0 && !MatchPath(entry.Path, patterns) {
|
// If we don't need the attributes or the file isn't included we clear the attributes to save memory
|
||||||
|
if !attributesNeeded || (len(patterns) != 0 && !MatchPath(entry.Path, patterns)) {
|
||||||
entry.Attributes = nil
|
entry.Attributes = nil
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -347,9 +348,9 @@ func (manager *SnapshotManager) DownloadSnapshotSequence(snapshot *Snapshot, seq
|
|||||||
// DownloadSnapshotContents loads all chunk sequences in a snapshot. A snapshot, when just created, only contains
|
// DownloadSnapshotContents loads all chunk sequences in a snapshot. A snapshot, when just created, only contains
|
||||||
// some metadata and theree sequence representing files, chunk hashes, and chunk lengths. This function must be called
|
// some metadata and theree sequence representing files, chunk hashes, and chunk lengths. This function must be called
|
||||||
// for the actual content of the snapshot to be usable.
|
// for the actual content of the snapshot to be usable.
|
||||||
func (manager *SnapshotManager) DownloadSnapshotContents(snapshot *Snapshot, patterns []string) bool {
|
func (manager *SnapshotManager) DownloadSnapshotContents(snapshot *Snapshot, patterns []string, attributesNeeded bool) bool {
|
||||||
|
|
||||||
manager.DownloadSnapshotFileSequence(snapshot, patterns)
|
manager.DownloadSnapshotFileSequence(snapshot, patterns, attributesNeeded)
|
||||||
manager.DownloadSnapshotSequence(snapshot, "chunks")
|
manager.DownloadSnapshotSequence(snapshot, "chunks")
|
||||||
manager.DownloadSnapshotSequence(snapshot, "lengths")
|
manager.DownloadSnapshotSequence(snapshot, "lengths")
|
||||||
|
|
||||||
@@ -553,7 +554,7 @@ func (manager *SnapshotManager) downloadLatestSnapshot(snapshotID string) (remot
|
|||||||
}
|
}
|
||||||
|
|
||||||
if remote != nil {
|
if remote != nil {
|
||||||
manager.DownloadSnapshotContents(remote, nil)
|
manager.DownloadSnapshotContents(remote, nil, false)
|
||||||
}
|
}
|
||||||
|
|
||||||
return remote
|
return remote
|
||||||
@@ -679,7 +680,7 @@ func (manager *SnapshotManager) ListSnapshots(snapshotID string, revisionsToList
|
|||||||
}
|
}
|
||||||
|
|
||||||
if showFiles {
|
if showFiles {
|
||||||
manager.DownloadSnapshotFileSequence(snapshot, nil)
|
manager.DownloadSnapshotFileSequence(snapshot, nil, false)
|
||||||
}
|
}
|
||||||
|
|
||||||
if showFiles {
|
if showFiles {
|
||||||
@@ -799,7 +800,7 @@ func (manager *SnapshotManager) CheckSnapshots(snapshotID string, revisionsToChe
|
|||||||
}
|
}
|
||||||
|
|
||||||
if checkFiles {
|
if checkFiles {
|
||||||
manager.DownloadSnapshotContents(snapshot, nil)
|
manager.DownloadSnapshotContents(snapshot, nil, false)
|
||||||
manager.VerifySnapshot(snapshot)
|
manager.VerifySnapshot(snapshot)
|
||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
@@ -1208,7 +1209,8 @@ func (manager *SnapshotManager) PrintFile(snapshotID string, revision int, path
|
|||||||
patterns = []string{path}
|
patterns = []string{path}
|
||||||
}
|
}
|
||||||
|
|
||||||
if !manager.DownloadSnapshotContents(snapshot, patterns) {
|
// If no path is specified, we're printing the snapshot so we need all attributes
|
||||||
|
if !manager.DownloadSnapshotContents(snapshot, patterns, path == "") {
|
||||||
return false
|
return false
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -1268,9 +1270,9 @@ func (manager *SnapshotManager) Diff(top string, snapshotID string, revisions []
|
|||||||
|
|
||||||
if len(filePath) > 0 {
|
if len(filePath) > 0 {
|
||||||
|
|
||||||
manager.DownloadSnapshotContents(leftSnapshot, nil)
|
manager.DownloadSnapshotContents(leftSnapshot, nil, false)
|
||||||
if rightSnapshot != nil && rightSnapshot.Revision != 0 {
|
if rightSnapshot != nil && rightSnapshot.Revision != 0 {
|
||||||
manager.DownloadSnapshotContents(rightSnapshot, nil)
|
manager.DownloadSnapshotContents(rightSnapshot, nil, false)
|
||||||
}
|
}
|
||||||
|
|
||||||
var leftFile []byte
|
var leftFile []byte
|
||||||
@@ -1346,9 +1348,9 @@ func (manager *SnapshotManager) Diff(top string, snapshotID string, revisions []
|
|||||||
}
|
}
|
||||||
|
|
||||||
// We only need to decode the 'files' sequence, not 'chunkhashes' or 'chunklengthes'
|
// We only need to decode the 'files' sequence, not 'chunkhashes' or 'chunklengthes'
|
||||||
manager.DownloadSnapshotFileSequence(leftSnapshot, nil)
|
manager.DownloadSnapshotFileSequence(leftSnapshot, nil, false)
|
||||||
if rightSnapshot != nil && rightSnapshot.Revision != 0 {
|
if rightSnapshot != nil && rightSnapshot.Revision != 0 {
|
||||||
manager.DownloadSnapshotFileSequence(rightSnapshot, nil)
|
manager.DownloadSnapshotFileSequence(rightSnapshot, nil, false)
|
||||||
}
|
}
|
||||||
|
|
||||||
maxSize := int64(9)
|
maxSize := int64(9)
|
||||||
@@ -1452,7 +1454,7 @@ func (manager *SnapshotManager) ShowHistory(top string, snapshotID string, revis
|
|||||||
sort.Ints(revisions)
|
sort.Ints(revisions)
|
||||||
for _, revision := range revisions {
|
for _, revision := range revisions {
|
||||||
snapshot := manager.DownloadSnapshot(snapshotID, revision)
|
snapshot := manager.DownloadSnapshot(snapshotID, revision)
|
||||||
manager.DownloadSnapshotFileSequence(snapshot, nil)
|
manager.DownloadSnapshotFileSequence(snapshot, nil, false)
|
||||||
file := manager.FindFile(snapshot, filePath, true)
|
file := manager.FindFile(snapshot, filePath, true)
|
||||||
|
|
||||||
if file != nil {
|
if file != nil {
|
||||||
|
|||||||
Reference in New Issue
Block a user