From fa4f438bc1988ba06785398526d650a5f2aabc77 Mon Sep 17 00:00:00 2001 From: Alexander Neumann Date: Wed, 3 Jan 2018 22:10:20 +0100 Subject: [PATCH] snapshot: Do not modify slice of paths --- internal/restic/snapshot.go | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/internal/restic/snapshot.go b/internal/restic/snapshot.go index 2eace5cfd..61467013a 100644 --- a/internal/restic/snapshot.go +++ b/internal/restic/snapshot.go @@ -30,14 +30,18 @@ type Snapshot struct { // NewSnapshot returns an initialized snapshot struct for the current user and // time. func NewSnapshot(paths []string, tags []string, hostname string, time time.Time) (*Snapshot, error) { - for i, path := range paths { - if p, err := filepath.Abs(path); err == nil { - paths[i] = p + absPaths := make([]string, 0, len(paths)) + for _, path := range paths { + p, err := filepath.Abs(path) + if err == nil { + absPaths = append(absPaths, p) + } else { + absPaths = append(absPaths, path) } } sn := &Snapshot{ - Paths: paths, + Paths: absPaths, Time: time, Tags: tags, Hostname: hostname,