0
Fork 0
mirror of https://github.com/penpot/penpot.git synced 2025-03-13 00:01:51 -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 (ns uxbox.services.mutations.profile
(:require (:require
[clojure.spec.alpha :as s] [clojure.spec.alpha :as s]
[clojure.string :as str] [cuerdas.core :as str]
[datoteka.core :as fs] [datoteka.core :as fs]
[promesa.core :as p] [promesa.core :as p]
[promesa.exec :as px] [promesa.exec :as px]
@ -174,8 +174,10 @@
photo (upload-photo conn params)] photo (upload-photo conn params)]
;; Schedule deletion of old photo ;; Schedule deletion of old photo
(when (and (string? (:photo profile))
(not (str/blank? (:photo profile))))
(tasks/schedule! conn {:name "remove-media" (tasks/schedule! conn {:name "remove-media"
:props {:path (:photo profile)}}) :props {:path (:photo profile)}}))
;; Save new photo ;; Save new photo
(update-profile-photo conn profile-id photo)))) (update-profile-photo conn profile-id photo))))

View file

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