From 9be475f876c0f4eab9cea7fa0b356d927d1628f9 Mon Sep 17 00:00:00 2001 From: Gilbert Chen Date: Fri, 6 Jan 2023 23:02:48 -0500 Subject: [PATCH] Fix another chunk leak in listing files in a revision. This bug leaks a chunk every time files in a revision are listed. Not a big deal for backup and restore, but it becomes problematic when listing files in many revisions for commands such check and history. --- src/duplicacy_snapshot.go | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/src/duplicacy_snapshot.go b/src/duplicacy_snapshot.go index e7511b6..efac81d 100644 --- a/src/duplicacy_snapshot.go +++ b/src/duplicacy_snapshot.go @@ -120,6 +120,12 @@ func (snapshot *Snapshot)ListRemoteFiles(config *Config, chunkOperator *ChunkOpe return chunk.GetBytes() }) + defer func() { + if chunk != nil { + config.PutChunk(chunk) + } + } () + // Normally if Version is 0 then the snapshot is created by CLI v2 but unfortunately CLI 3.0.1 does not set the // version bit correctly when copying old backups. So we need to check the first byte -- if it is '[' then it is // the old format. The new format starts with a string encoded in msgpack and the first byte can't be '['.