mirror of
https://github.com/penpot/penpot.git
synced 2025-04-13 07:21:40 -05:00
🐛 Fix issues on deleting library which is in use by deleted files
This commit is contained in:
parent
11018581ed
commit
ce7eed5ea0
3 changed files with 21 additions and 22 deletions
|
@ -23,6 +23,8 @@
|
|||
- Fix unexpected layers ungrouping on moving it [Taiga #3932](https://tree.taiga.io/project/penpot/issue/3932) by @andrewzhurov
|
||||
- Fix artboards moving with comment tool selected [Taiga #3938](https://tree.taiga.io/project/penpot/issue/3938)
|
||||
- Fix undo on delete page does not preserve its order [Taiga #3375](https://tree.taiga.io/project/penpot/issue/3375)
|
||||
- Fix unexpected 404 on deleting library that is used by deleted files
|
||||
- Fix inconsistent message on deleting library when a library is linked from deleted files
|
||||
|
||||
### :arrow_up: Deps updates
|
||||
### :heart: Community contributions by (Thank you!)
|
||||
|
|
|
@ -162,25 +162,21 @@
|
|||
"Find all files using a shared library, and absorb all library assets
|
||||
into the file local libraries"
|
||||
[conn {:keys [id] :as params}]
|
||||
(let [library (->> (db/get-by-id conn :file id)
|
||||
(files/decode-row)
|
||||
(pmg/migrate-file))]
|
||||
(let [library (db/get-by-id conn :file id)]
|
||||
(when (:is-shared library)
|
||||
(let [process-file
|
||||
(fn [row]
|
||||
(let [ts (dt/now)
|
||||
file (->> (db/get-by-id conn :file (:file-id row))
|
||||
(files/decode-row)
|
||||
(pmg/migrate-file))
|
||||
updated-data (ctf/absorb-assets (:data file) (:data library))]
|
||||
|
||||
(db/update! conn :file
|
||||
{:revn (inc (:revn file))
|
||||
:data (blob/encode updated-data)
|
||||
:modified-at ts}
|
||||
{:id (:id file)})))]
|
||||
|
||||
(run! process-file (db/query conn :file-library-rel {:library-file-id id}))))))
|
||||
(let [ldata (-> library files/decode-row pmg/migrate-file :data)]
|
||||
(->> (db/query conn :file-library-rel {:library-file-id id})
|
||||
(keep (fn [{:keys [file-id]}]
|
||||
(some->> (db/get-by-id conn :file file-id {:check-not-found false})
|
||||
(files/decode-row)
|
||||
(pmg/migrate-file))))
|
||||
(run! (fn [{:keys [id data revn] :as file}]
|
||||
(let [data (ctf/absorb-assets data ldata)]
|
||||
(db/update! conn :file
|
||||
{:revn (inc revn)
|
||||
:data (blob/encode data)
|
||||
:modified-at (dt/now)}
|
||||
{:id id})))))))))
|
||||
|
||||
;; --- Mutation: Link file to library
|
||||
|
||||
|
|
|
@ -488,11 +488,12 @@
|
|||
;; --- Query: Files that use this File library
|
||||
|
||||
(def ^:private sql:library-using-files
|
||||
"SELECT f.id,
|
||||
"SELECT f.id,
|
||||
f.name
|
||||
FROM file_library_rel AS flr
|
||||
INNER JOIN file AS f ON f.id = flr.file_id
|
||||
WHERE flr.library_file_id = ?;")
|
||||
FROM file_library_rel AS flr
|
||||
JOIN file AS f ON (f.id = flr.file_id)
|
||||
WHERE flr.library_file_id = ?
|
||||
AND (f.deleted_at IS NULL OR f.deleted_at > now())")
|
||||
|
||||
(s/def ::library-using-files
|
||||
(s/keys :req-un [::profile-id ::file-id]))
|
||||
|
|
Loading…
Add table
Reference in a new issue