mirror of
https://github.com/restic/restic.git
synced 2025-08-13 16:16:11 +00:00
snapshot: Do not modify slice of paths
This commit is contained in:
@@ -30,14 +30,18 @@ type Snapshot struct {
|
|||||||
// NewSnapshot returns an initialized snapshot struct for the current user and
|
// NewSnapshot returns an initialized snapshot struct for the current user and
|
||||||
// time.
|
// time.
|
||||||
func NewSnapshot(paths []string, tags []string, hostname string, time time.Time) (*Snapshot, error) {
|
func NewSnapshot(paths []string, tags []string, hostname string, time time.Time) (*Snapshot, error) {
|
||||||
for i, path := range paths {
|
absPaths := make([]string, 0, len(paths))
|
||||||
if p, err := filepath.Abs(path); err == nil {
|
for _, path := range paths {
|
||||||
paths[i] = p
|
p, err := filepath.Abs(path)
|
||||||
|
if err == nil {
|
||||||
|
absPaths = append(absPaths, p)
|
||||||
|
} else {
|
||||||
|
absPaths = append(absPaths, path)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
sn := &Snapshot{
|
sn := &Snapshot{
|
||||||
Paths: paths,
|
Paths: absPaths,
|
||||||
Time: time,
|
Time: time,
|
||||||
Tags: tags,
|
Tags: tags,
|
||||||
Hostname: hostname,
|
Hostname: hostname,
|
||||||
|
Reference in New Issue
Block a user