Skip to content

Commit

Permalink
CORE-4768: Fixed an issue where a trailing slash was causing a "File not
Browse files Browse the repository at this point in the history
found".
  • Loading branch information
johnworth committed Sep 16, 2013
1 parent 8bae451 commit 7e6b43f
Showing 1 changed file with 28 additions and 27 deletions.
55 changes: 28 additions & 27 deletions src/donkey/services/fileio/actions.clj
Expand Up @@ -77,33 +77,34 @@
(string/join "." (drop-last (string/split (ft/basename tmp-path) #"\."))))

(defn upload
[user tmp-path final-path]
(log/info "In upload for " user tmp-path final-path)
(with-jargon (jargon-cfg) [cm]
(when-not (user-exists? cm user)
(throw+ {:error_code ERR_NOT_A_USER
:user user}))

(when-not (exists? cm final-path)
(throw+ {:error_code ERR_DOES_NOT_EXIST
:id final-path}))

(when-not (is-writeable? cm user final-path)
(throw+ {:error_code ERR_NOT_WRITEABLE
:id final-path}))

(let [new-fname (new-filename tmp-path)
new-path (ft/path-join final-path new-fname)]
(if (exists? cm new-path) (delete cm new-path))
(move cm tmp-path new-path :user user :admin-users (irods-admins) :skip-source-perms? true)
(set-owner cm new-path user)
{:file
{:id new-path
:label (ft/basename new-path)
:permissions (dataobject-perm-map cm user new-path)
:date-created (created-date cm new-path)
:date-modified (lastmod-date cm new-path)
:file-size (str (file-size cm new-path))}})))
[user tmp-path fpath]
(log/info "In upload for " user tmp-path fpath)
(let [final-path (ft/rm-last-slash fpath)]
(with-jargon (jargon-cfg) [cm]
(when-not (user-exists? cm user)
(throw+ {:error_code ERR_NOT_A_USER
:user user}))

(when-not (exists? cm final-path)
(throw+ {:error_code ERR_DOES_NOT_EXIST
:id final-path}))

(when-not (is-writeable? cm user final-path)
(throw+ {:error_code ERR_NOT_WRITEABLE
:id final-path}))

(let [new-fname (new-filename tmp-path)
new-path (ft/path-join final-path new-fname)]
(if (exists? cm new-path) (delete cm new-path))
(move cm tmp-path new-path :user user :admin-users (irods-admins) :skip-source-perms? true)
(set-owner cm new-path user)
{:file
{:id new-path
:label (ft/basename new-path)
:permissions (dataobject-perm-map cm user new-path)
:date-created (created-date cm new-path)
:date-modified (lastmod-date cm new-path)
:file-size (str (file-size cm new-path))}}))))

(defn url-encoded?
[string-to-check]
Expand Down

0 comments on commit 7e6b43f

Please sign in to comment.