Skip to content

Commit

Permalink
fix crash when push is a relative path
Browse files Browse the repository at this point in the history
  • Loading branch information
poolpOrg committed Oct 4, 2023
1 parent c2a0ce9 commit 99d878d
Showing 1 changed file with 10 additions and 1 deletion.
11 changes: 10 additions & 1 deletion cmd/plakar/cmd_push.go
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,9 @@ import (
"fmt"
"log"
"os"
"path"
"runtime"
"strings"

"github.com/google/uuid"
"github.com/poolpOrg/plakar/logger"
Expand Down Expand Up @@ -70,7 +72,14 @@ func cmd_push(ctx Plakar, repository *storage.Repository, args []string) int {
if flags.NArg() == 0 {
err = snap.Push(dir, opt_progress)
} else if flags.NArg() == 1 {
err = snap.Push(flags.Arg(0), opt_progress)
var cleanPath string

if !strings.HasPrefix(flags.Arg(0), "/") {
cleanPath = path.Clean(dir + "/" + flags.Arg(0))
} else {
cleanPath = path.Clean(flags.Arg(0))
}
err = snap.Push(cleanPath, opt_progress)
} else {
log.Fatal("only one directory pushable")
}
Expand Down

0 comments on commit 99d878d

Please sign in to comment.