mirror of
https://github.com/octoleo/restic.git
synced 2024-12-26 20:30:19 +00:00
snapshot: Do not modify slice of paths
This commit is contained in:
parent
4e0b2a8e3a
commit
fa4f438bc1
@ -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,
|
||||
|
Loading…
Reference in New Issue
Block a user