0
Fork 0
mirror of https://github.com/penpot/penpot.git synced 2025-03-12 07:41:43 -05:00

🐛 Fix media deletion on first profile photo change.

This commit is contained in:
Andrey Antukh 2020-03-26 11:24:35 +01:00
parent 1ed1c95e4d
commit 8d6d839878
2 changed files with 6 additions and 4 deletions

View file

@ -10,7 +10,7 @@
(ns uxbox.services.mutations.profile
(:require
[clojure.spec.alpha :as s]
[clojure.string :as str]
[cuerdas.core :as str]
[datoteka.core :as fs]
[promesa.core :as p]
[promesa.exec :as px]
@ -174,8 +174,10 @@
photo (upload-photo conn params)]
;; Schedule deletion of old photo
(tasks/schedule! conn {:name "remove-media"
:props {:path (:photo profile)}})
(when (and (string? (:photo profile))
(not (str/blank? (:photo profile))))
(tasks/schedule! conn {:name "remove-media"
:props {:path (:photo profile)}}))
;; Save new photo
(update-profile-photo conn profile-id photo))))

View file

@ -18,7 +18,7 @@
[uxbox.util.storage :as ust]
[vertx.util :as vu]))
(s/def ::path ::us/string)
(s/def ::path ::us/not-empty-string)
(s/def ::props
(s/keys :req-un [::path]))