Skip to content

Commit

Permalink
Prevent files deletes in tx (#795)
Browse files Browse the repository at this point in the history
  • Loading branch information
nezaj authored Feb 3, 2025
1 parent fa4eff9 commit d3897e1
Showing 1 changed file with 9 additions and 9 deletions.
18 changes: 9 additions & 9 deletions server/src/instant/db/transaction.clj
Original file line number Diff line number Diff line change
Expand Up @@ -125,9 +125,9 @@
app-id
[{:message (format "You can't make updates to this app.")}])))

(defn prevent-$files-add-retract! [op attrs triples]
(doseq [t triples
:let [etype (let [[_eid aid] t]
(defn prevent-$files-add-retract! [op attrs tx-steps]
(doseq [t tx-steps
:let [etype (let [[_op _eid aid] t]
(-> (attr-model/seek-by-id aid attrs)
attr-model/fwd-etype))]
:when (= etype "$files")]
Expand All @@ -136,9 +136,9 @@
[op t]
[{:message (format "update or merge is not allowed on $files in transact.")}])))

(defn prevent-$files-deletes! [op triples]
(doseq [t triples
:let [[_eid etype] t]
(defn prevent-$files-deletes! [op tx-steps]
(doseq [t tx-steps
:let [[_op _eid etype] t]
:when (= etype "$files")]
(ex/throw-validation-err!
:tx-step
Expand All @@ -151,13 +151,13 @@
[attrs grouped-tx-steps opts]
(when (not (:allow-$files-update? opts))
(doseq [batch grouped-tx-steps
:let [[op & triples] batch]]
:let [[op tx-steps] batch]]
(case op
(:add-triple :deep-merge-triple :retract-triple)
(prevent-$files-add-retract! op attrs triples)
(prevent-$files-add-retract! op attrs tx-steps)

:delete-entity
(prevent-$files-deletes! op triples)
(prevent-$files-deletes! op tx-steps)

nil))))

Expand Down

0 comments on commit d3897e1

Please sign in to comment.