mirror of
https://github.com/penpot/penpot.git
synced 2025-05-11 18:16:38 +02: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 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 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 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
|
### :arrow_up: Deps updates
|
||||||
### :heart: Community contributions by (Thank you!)
|
### :heart: Community contributions by (Thank you!)
|
||||||
|
|
|
@ -162,25 +162,21 @@
|
||||||
"Find all files using a shared library, and absorb all library assets
|
"Find all files using a shared library, and absorb all library assets
|
||||||
into the file local libraries"
|
into the file local libraries"
|
||||||
[conn {:keys [id] :as params}]
|
[conn {:keys [id] :as params}]
|
||||||
(let [library (->> (db/get-by-id conn :file id)
|
(let [library (db/get-by-id conn :file id)]
|
||||||
(files/decode-row)
|
|
||||||
(pmg/migrate-file))]
|
|
||||||
(when (:is-shared library)
|
(when (:is-shared library)
|
||||||
(let [process-file
|
(let [ldata (-> library files/decode-row pmg/migrate-file :data)]
|
||||||
(fn [row]
|
(->> (db/query conn :file-library-rel {:library-file-id id})
|
||||||
(let [ts (dt/now)
|
(keep (fn [{:keys [file-id]}]
|
||||||
file (->> (db/get-by-id conn :file (:file-id row))
|
(some->> (db/get-by-id conn :file file-id {:check-not-found false})
|
||||||
(files/decode-row)
|
(files/decode-row)
|
||||||
(pmg/migrate-file))
|
(pmg/migrate-file))))
|
||||||
updated-data (ctf/absorb-assets (:data file) (:data library))]
|
(run! (fn [{:keys [id data revn] :as file}]
|
||||||
|
(let [data (ctf/absorb-assets data ldata)]
|
||||||
(db/update! conn :file
|
(db/update! conn :file
|
||||||
{:revn (inc (:revn file))
|
{:revn (inc revn)
|
||||||
:data (blob/encode updated-data)
|
:data (blob/encode data)
|
||||||
:modified-at ts}
|
:modified-at (dt/now)}
|
||||||
{:id (:id file)})))]
|
{:id id})))))))))
|
||||||
|
|
||||||
(run! process-file (db/query conn :file-library-rel {:library-file-id id}))))))
|
|
||||||
|
|
||||||
;; --- Mutation: Link file to library
|
;; --- Mutation: Link file to library
|
||||||
|
|
||||||
|
|
|
@ -488,11 +488,12 @@
|
||||||
;; --- Query: Files that use this File library
|
;; --- Query: Files that use this File library
|
||||||
|
|
||||||
(def ^:private sql:library-using-files
|
(def ^:private sql:library-using-files
|
||||||
"SELECT f.id,
|
"SELECT f.id,
|
||||||
f.name
|
f.name
|
||||||
FROM file_library_rel AS flr
|
FROM file_library_rel AS flr
|
||||||
INNER JOIN file AS f ON f.id = flr.file_id
|
JOIN file AS f ON (f.id = flr.file_id)
|
||||||
WHERE flr.library_file_id = ?;")
|
WHERE flr.library_file_id = ?
|
||||||
|
AND (f.deleted_at IS NULL OR f.deleted_at > now())")
|
||||||
|
|
||||||
(s/def ::library-using-files
|
(s/def ::library-using-files
|
||||||
(s/keys :req-un [::profile-id ::file-id]))
|
(s/keys :req-un [::profile-id ::file-id]))
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue