Ensure connection on persisting pointers

This commit is contained in:
Andrey Antukh 2024-02-14 17:36:13 +01:00
parent ba55d657a4
commit 8981e57deb

View file

@ -81,14 +81,15 @@
"Given a database connection and the final file-id, persist all "Given a database connection and the final file-id, persist all
pointers to the underlying storage (the database)." pointers to the underlying storage (the database)."
[system file-id] [system file-id]
(doseq [[id item] @pmap/*tracked*] (let [conn (db/get-connection system)]
(when (pmap/modified? item) (doseq [[id item] @pmap/*tracked*]
(l/trc :hint "persist pointer" :file-id (str file-id) :id (str id)) (when (pmap/modified? item)
(let [content (-> item deref blob/encode)] (l/trc :hint "persist pointer" :file-id (str file-id) :id (str id))
(db/insert! system :file-data-fragment (let [content (-> item deref blob/encode)]
{:id id (db/insert! conn :file-data-fragment
:file-id file-id {:id id
:content content}))))) :file-id file-id
:content content}))))))
(defn process-pointers (defn process-pointers
"Apply a function to all pointers on the file. Usuly used for "Apply a function to all pointers on the file. Usuly used for