From cdf8f5a8575fa50e22cad126a00140e38618b9fc Mon Sep 17 00:00:00 2001 From: Gilbert Chen Date: Sun, 9 Apr 2023 22:11:08 -0400 Subject: [PATCH] Check the length of 'file' before checking if it ends with '/' --- src/duplicacy_snapshotmanager.go | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/duplicacy_snapshotmanager.go b/src/duplicacy_snapshotmanager.go index 9d1d4bc..28ddc58 100644 --- a/src/duplicacy_snapshotmanager.go +++ b/src/duplicacy_snapshotmanager.go @@ -448,7 +448,7 @@ func (manager *SnapshotManager) CleanSnapshotCache(latestSnapshot *Snapshot, all allFiles, _ := manager.ListAllFiles(manager.snapshotCache, chunkDir) for _, file := range allFiles { - if file[len(file)-1] != '/' { + if len(file) > 0 && file[len(file)-1] != '/' { chunkID := strings.Replace(file, "/", "", -1) if _, found := chunks[chunkID]; !found { LOG_DEBUG("SNAPSHOT_CLEAN", "Delete chunk %s from the snapshot cache", chunkID) @@ -2428,7 +2428,7 @@ func (manager *SnapshotManager) pruneSnapshotsExhaustive(referencedFossils map[s allFiles, _ := manager.ListAllFiles(manager.storage, chunkDir) for _, file := range allFiles { - if file[len(file)-1] == '/' { + if len(file) == 0 || file[len(file)-1] == '/' { continue }