mirror of
https://github.com/penpot/penpot.git
synced 2025-01-25 07:58:49 -05:00
✨ Parametrice file change snapshoting.
This commit is contained in:
parent
a2dbc40571
commit
f24563503a
2 changed files with 16 additions and 3 deletions
|
@ -52,6 +52,9 @@
|
||||||
:default-blob-version 3
|
:default-blob-version 3
|
||||||
:loggers-zmq-uri "tcp://localhost:45556"
|
:loggers-zmq-uri "tcp://localhost:45556"
|
||||||
|
|
||||||
|
:file-change-snapshot-every 1
|
||||||
|
:file-change-snapshot-timeout "3h"
|
||||||
|
|
||||||
:public-uri "http://localhost:3449"
|
:public-uri "http://localhost:3449"
|
||||||
:redis-uri "redis://redis/0"
|
:redis-uri "redis://redis/0"
|
||||||
|
|
||||||
|
@ -99,6 +102,9 @@
|
||||||
(s/def ::audit-log-archive-uri ::us/string)
|
(s/def ::audit-log-archive-uri ::us/string)
|
||||||
(s/def ::audit-log-gc-max-age ::dt/duration)
|
(s/def ::audit-log-gc-max-age ::dt/duration)
|
||||||
|
|
||||||
|
(s/def ::file-change-snapshot-every ::us/integer)
|
||||||
|
(s/def ::file-change-snapshot-timeout ::dt/duration)
|
||||||
|
|
||||||
(s/def ::secret-key ::us/string)
|
(s/def ::secret-key ::us/string)
|
||||||
(s/def ::allow-demo-users ::us/boolean)
|
(s/def ::allow-demo-users ::us/boolean)
|
||||||
(s/def ::assets-path ::us/string)
|
(s/def ::assets-path ::us/string)
|
||||||
|
@ -195,6 +201,8 @@
|
||||||
::database-username
|
::database-username
|
||||||
::default-blob-version
|
::default-blob-version
|
||||||
::error-report-webhook
|
::error-report-webhook
|
||||||
|
::file-change-snapshot-every
|
||||||
|
::file-change-snapshot-timeout
|
||||||
::user-feedback-destination
|
::user-feedback-destination
|
||||||
::github-client-id
|
::github-client-id
|
||||||
::github-client-secret
|
::github-client-secret
|
||||||
|
|
|
@ -11,6 +11,7 @@
|
||||||
[app.common.pages.migrations :as pmg]
|
[app.common.pages.migrations :as pmg]
|
||||||
[app.common.spec :as us]
|
[app.common.spec :as us]
|
||||||
[app.common.uuid :as uuid]
|
[app.common.uuid :as uuid]
|
||||||
|
[app.config :as cf]
|
||||||
[app.db :as db]
|
[app.db :as db]
|
||||||
[app.metrics :as mtx]
|
[app.metrics :as mtx]
|
||||||
[app.rpc.permissions :as perms]
|
[app.rpc.permissions :as perms]
|
||||||
|
@ -282,9 +283,13 @@
|
||||||
[{:keys [revn modified-at] :as file}]
|
[{:keys [revn modified-at] :as file}]
|
||||||
;; The snapshot will be saved every 20 changes or if the last
|
;; The snapshot will be saved every 20 changes or if the last
|
||||||
;; modification is older than 3 hour.
|
;; modification is older than 3 hour.
|
||||||
(or (zero? (mod revn 20))
|
(let [freq (or (cf/get :file-change-snapshot-every) 20)
|
||||||
(> (inst-ms (dt/diff modified-at (dt/now)))
|
timeout (or (cf/get :file-change-snapshot-timeout)
|
||||||
(inst-ms (dt/duration {:hours 3})))))
|
(dt/duration {:hours 1}))]
|
||||||
|
(or (= 1 freq)
|
||||||
|
(zero? (mod revn freq))
|
||||||
|
(> (inst-ms (dt/diff modified-at (dt/now)))
|
||||||
|
(inst-ms timeout)))))
|
||||||
|
|
||||||
(defn- delete-from-storage
|
(defn- delete-from-storage
|
||||||
[{:keys [storage] :as cfg} file]
|
[{:keys [storage] :as cfg} file]
|
||||||
|
|
Loading…
Add table
Reference in a new issue