aboutsummaryrefslogtreecommitdiff
path: root/repo.go
diff options
context:
space:
mode:
authorn-peugnet <n.peugnet@free.fr>2021-09-22 21:06:18 +0200
committern-peugnet <n.peugnet@free.fr>2021-09-22 21:07:07 +0200
commitdb5b7303c254af467a6458d9025f825ab50b452e (patch)
treebe317ffc762c854fc05c25ea2c03b9fe9ba56784 /repo.go
parentcce3365003dba7c3ac2905f71aa284caf63a1c78 (diff)
downloaddna-backup-db5b7303c254af467a6458d9025f825ab50b452e.tar.gz
dna-backup-db5b7303c254af467a6458d9025f825ab50b452e.zip
export unprefix in utils and fix error msg
Diffstat (limited to 'repo.go')
-rw-r--r--repo.go10
1 files changed, 4 insertions, 6 deletions
diff --git a/repo.go b/repo.go
index f36bb65..dc61d01 100644
--- a/repo.go
+++ b/repo.go
@@ -38,7 +38,6 @@ import (
"os"
"path/filepath"
"reflect"
- "strings"
"sync"
"github.com/chmduquesne/rollinghash/rabinkarp64"
@@ -215,15 +214,14 @@ func listFiles(path string) []File {
}
func unprefixFiles(files []File, prefix string) (ret []File) {
+ var err error
ret = make([]File, len(files))
- preSize := len(prefix)
for i, f := range files {
- if !strings.HasPrefix(f.Path, prefix) {
- logger.Warning(f.Path, "is not prefixed by", prefix)
+ if f.Path, err = utils.Unprefix(f.Path, prefix); err != nil {
+ logger.Warning(err)
} else {
- f.Path = f.Path[preSize:]
+ ret[i] = f
}
- ret[i] = f
}
return
}