Save session rootPath to handle sessions from anywhere, relative or absolute

This commit is contained in:
Harshavardhana
2015-06-29 13:41:59 -07:00
parent 91fbce7fa5
commit d76cdd35d6
4 changed files with 21 additions and 5 deletions
+1
View File
@@ -244,6 +244,7 @@ func runCopyCmd(ctx *cli.Context) {
})
}
s.CommandType = "cp"
s.RootPath, _ = os.Getwd()
// extract URLs.
s.URLs, err = args2URLs(ctx.Args())
+18 -5
View File
@@ -186,7 +186,7 @@ func runSessionCmd(ctx *cli.Context) {
if err := createSessionDir(); err != nil {
console.Fatals(ErrorMessage{
Message: "Failed with",
Error: iodine.ToError(err),
Error: iodine.New(err, nil),
})
}
}
@@ -197,7 +197,7 @@ func runSessionCmd(ctx *cli.Context) {
if err != nil {
console.Fatals(ErrorMessage{
Message: "Failed with",
Error: iodine.ToError(err),
Error: iodine.New(err, nil),
})
}
case "resume":
@@ -212,9 +212,20 @@ func runSessionCmd(ctx *cli.Context) {
if err != nil {
console.Fatals(ErrorMessage{
Message: "Failed with",
Error: iodine.ToError(err),
Error: iodine.New(err, nil),
})
}
savedCwd, err := os.Getwd()
if err != nil {
console.Fatals(ErrorMessage{
Message: "Failed with",
Error: iodine.New(err, nil),
})
}
if s.RootPath != "" {
// chdir to RootPath
os.Chdir(s.RootPath)
}
var bar barSend
// set up progress bar
if !globalQuietFlag {
@@ -226,9 +237,11 @@ func runSessionCmd(ctx *cli.Context) {
if err := clearSession(sid); err != nil {
console.Fatals(ErrorMessage{
Message: "Failed with",
Error: iodine.ToError(err),
Error: iodine.New(err, nil),
})
}
// change dir back
os.Chdir(savedCwd)
}
// purge a requested pending session, if "*" purge everything
case "clear":
@@ -241,7 +254,7 @@ func runSessionCmd(ctx *cli.Context) {
if err := clearSession(strings.TrimSpace(ctx.Args().Tail().First())); err != nil {
console.Fatals(ErrorMessage{
Message: "Failed with",
Error: iodine.ToError(err),
Error: iodine.New(err, nil),
})
}
default:
+1
View File
@@ -246,6 +246,7 @@ func runSyncCmd(ctx *cli.Context) {
})
}
s.CommandType = "sync"
s.RootPath, _ = os.Getwd()
// extract URLs.
s.URLs, err = args2URLs(ctx.Args())
+1
View File
@@ -34,6 +34,7 @@ type sessionV1 struct {
Started time.Time `json:"started"`
CommandType string `json:"command-type"`
SessionID string `json:"session-id"`
RootPath string `json:"root-path"`
URLs []string `json:"args"`
Files map[string]bool `json:"files"`