From c2e6566152f085ffb36751dc53e017d59c15cb51 Mon Sep 17 00:00:00 2001 From: Robert Sesek Date: Mon, 4 Oct 2010 10:18:10 -0400 Subject: [PATCH] Implement the back-end of the Move operation. --- src/paths.go | 12 ++++++++++++ src/server.go | 12 ++++++++++++ 2 files changed, 24 insertions(+) diff --git a/src/paths.go b/src/paths.go index 1229b0e..8125bf3 100644 --- a/src/paths.go +++ b/src/paths.go @@ -69,3 +69,15 @@ func Remove(the_path string) os.Error { } return os.RemoveAll(full_path) } + +func Move(source string, target string) os.Error { + source = canonicalizePath(source) + target = canonicalizePath(target) + if !checkInJail(source) { + return os.NewError("Source outside of jail") + } + if !checkInJail(target) { + return os.NewError("Target outside of jail") + } + return os.Rename(source, target) +} diff --git a/src/server.go b/src/server.go index aceb130..6a02f37 100644 --- a/src/server.go +++ b/src/server.go @@ -56,6 +56,18 @@ func serviceHandler(connection *http.Conn, request *http.Request) { } okResponse(connection, response) } + case "move": + source := request.FormValue("source") + target := request.FormValue("target") + err := paths.Move(source, target) + if err != nil { + errorResponse(connection, err.String()) + } else { + response := map[string] string { + "path" : target, + } + okResponse(connection, response) + } default: errorResponse(connection, "Unhandled action") } -- 2.43.5