aboutsummaryrefslogtreecommitdiff
path: root/repo.go
diff options
context:
space:
mode:
authorn-peugnet <n.peugnet@free.fr>2021-09-22 21:14:55 +0200
committern-peugnet <n.peugnet@free.fr>2021-09-22 21:14:55 +0200
commit237f6af4dc74183cf76898ff8f471ab3cb786116 (patch)
tree547bf4b937141b632e3288f886fe2a208c3f6345 /repo.go
parentdb5b7303c254af467a6458d9025f825ab50b452e (diff)
downloaddna-backup-237f6af4dc74183cf76898ff8f471ab3cb786116.tar.gz
dna-backup-237f6af4dc74183cf76898ff8f471ab3cb786116.zip
fix calling with source "."
Diffstat (limited to 'repo.go')
-rw-r--r--repo.go12
1 files changed, 10 insertions, 2 deletions
diff --git a/repo.go b/repo.go
index dc61d01..d58eebb 100644
--- a/repo.go
+++ b/repo.go
@@ -104,7 +104,12 @@ type File struct {
}
func NewRepo(path string) *Repo {
- err := os.MkdirAll(path, 0775)
+ var err error
+ path, err = filepath.Abs(path)
+ if err != nil {
+ logger.Fatal(err)
+ }
+ err = os.MkdirAll(path, 0775)
if err != nil {
logger.Panic(err)
}
@@ -139,7 +144,10 @@ func (r *Repo) Patcher() Patcher {
}
func (r *Repo) Commit(source string) {
- source = utils.TrimTrailingSeparator(source)
+ source, err := filepath.Abs(source)
+ if err != nil {
+ logger.Fatal(err)
+ }
versions := r.loadVersions()
newVersion := len(versions) // TODO: add newVersion functino
newPath := filepath.Join(r.path, fmt.Sprintf(versionFmt, newVersion))