Skip to content

Commit

Permalink
CORE-3733: Added the partial-restore field to the JSON that's returned
Browse files Browse the repository at this point in the history
for the /restore endpoint.
  • Loading branch information
johnworth committed Feb 12, 2013
1 parent 3388066 commit 4dd2a0d
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 6 deletions.
14 changes: 10 additions & 4 deletions docs/restore.md
Expand Up @@ -8,7 +8,7 @@ Error codes: ERR_EXISTS, ERR_DOES_NOT_EXIST, ERR_NOT_A_USER, ERR_NOT_WRITEABLE
Sample Request JSON:

{
"paths" : ["<absolute path to trashed
"paths" : ["<absolute path to trashed file or dir"]
}

Curl Command:
Expand All @@ -21,9 +21,15 @@ Response JSON:
"action" : "restore",
"status" : "success",
"restored" : {
"/iplant/trash/home/proxy-user/johnworth/foo.fq" : "/iplant/home/johnworth/foo.fq",
"/iplant/trash/home/proxy-user/johnworth/foo1.fq" : "/iplant/home/johnworth/foo1.fq"
"/iplant/trash/home/proxy-user/johnworth/foo.fq" : {
"restored-path" : /iplant/home/johnworth/foo.fq",
"partial-restore" : true
},
"/iplant/trash/home/proxy-user/johnworth/foo1.fq" : {
"restored-path" : "/iplant/home/johnworth/foo1.fq"
"partial-restore" : true
}
}
}

The "restored" field contains a map whose keys are the paths in the user's that were restored and whose keys are the paths the files were restored to.
The "restored" field is a map that whose keys are the paths in the trash that were restored. Associated with those paths is a map that contains two entries, "restored-path" that contains the path that the file was restored to, and "partial-restore" which is a boolean that is true if the restoration was to the home directory because there was no alternative and false if the restoration was a full restore.
11 changes: 9 additions & 2 deletions src/nibblonian/irods_actions.clj
Expand Up @@ -876,6 +876,10 @@
(:value (first (get-attribute cm p "ipc-trash-origin")))
(ft/path-join (user-home-dir user) (ft/basename p))))

(defn restore-to-homedir?
[cm p]
(not (attribute? cm p "ipc-trash-origin")))

(defn restoration-path
[cm user path]
(let [user-home (user-home-dir user)
Expand Down Expand Up @@ -911,7 +915,8 @@

(let [retval (atom (hash-map))]
(doseq [path paths]
(let [fully-restored (restoration-path cm user path)]
(let [fully-restored (restoration-path cm user path)
restored-to-homedir (restore-to-homedir? cm path)]
(log/warn "Restoring " path " to " fully-restored)

(validators/path-not-exists cm fully-restored)
Expand All @@ -930,7 +935,9 @@
(move cm path fully-restored :user user :admin-users (irods-admins))
(log/warn "Done moving " path " to " fully-restored)

(reset! retval (assoc @retval path fully-restored))))
(reset! retval
(assoc @retval path {:restored-path fully-restored
:partial-restore restored-to-homedir}))))
{:restored @retval})))

(defn copy-path
Expand Down

0 comments on commit 4dd2a0d

Please sign in to comment.