Skip to content

Commit

Permalink
Stop deleting non-existing old image in res. upda.
Browse files Browse the repository at this point in the history
[Re #1543]

We were not checking if we had a previous image before trying to delete
it in the case of replacing the image of a resource by a nil value. Now
we do it.
  • Loading branch information
joseAyudarte91 committed Aug 28, 2023
1 parent 7d9795b commit 3640d9a
Showing 1 changed file with 14 additions and 8 deletions.
22 changes: 14 additions & 8 deletions backend/src/gpml/handler/detail.clj
Original file line number Diff line number Diff line change
Expand Up @@ -607,14 +607,20 @@

(defn update-blank-resource-image
[config conn resource-type resource-id file-id-key old-file-id]
(let [result (srv.file/delete-file config conn {:id old-file-id})]
(if (:success? result)
(db.detail/update-resource-table
conn
{:table resource-type
:id resource-id
:updates {file-id-key nil}})
(throw (ex-info "Failed to delete old resource image file" {:result result})))))
(if old-file-id
(let [result (srv.file/delete-file config conn {:id old-file-id})]
(if (:success? result)
(db.detail/update-resource-table
conn
{:table resource-type
:id resource-id
:updates {file-id-key nil}})
(throw (ex-info "Failed to delete old resource image file" {:result result}))))
(db.detail/update-resource-table
conn
{:table resource-type
:id resource-id
:updates {file-id-key nil}})))

(defn- update-resource-image**
[config conn resource-type resource-id file-id-key image-payload]
Expand Down

0 comments on commit 3640d9a

Please sign in to comment.