mirror of
https://github.com/penpot/penpot.git
synced 2025-01-09 08:20:45 -05:00
Adapt uxbox backend code to stroage module changes.
This commit is contained in:
parent
6a3d8be32a
commit
b319ee056d
7 changed files with 20 additions and 22 deletions
|
@ -13,7 +13,7 @@
|
|||
[cuerdas.core :as str]
|
||||
[suricatta.core :as sc]
|
||||
[storages.core :as st]
|
||||
[storages.util :as fs]
|
||||
[storages.fs :as fs]
|
||||
[uxbox.config]
|
||||
[uxbox.db :as db]
|
||||
[uxbox.migrations]
|
||||
|
|
|
@ -9,7 +9,7 @@
|
|||
[promesa.core :as p]
|
||||
[catacumba.http :as http]
|
||||
[storages.core :as st]
|
||||
[storages.util :as path]
|
||||
[storages.fs :as fs]
|
||||
[uxbox.media :as media]
|
||||
[uxbox.images :as images]
|
||||
[uxbox.util.spec :as us]
|
||||
|
@ -116,7 +116,7 @@
|
|||
(let [{:keys [file id width height
|
||||
mimetype collection]} (us/conform ::create-image data)
|
||||
id (or id (uuid/random))
|
||||
filename (path/base-name file)
|
||||
filename (fs/base-name file)
|
||||
storage media/images-storage]
|
||||
(letfn [(persist-image-entry [path]
|
||||
(sv/novelty {:id id
|
||||
|
|
|
@ -9,7 +9,7 @@
|
|||
[promesa.core :as p]
|
||||
[catacumba.http :as http]
|
||||
[storages.core :as st]
|
||||
[storages.util :as path]
|
||||
[storages.fs :as fs]
|
||||
[uxbox.media :as media]
|
||||
[uxbox.images :as images]
|
||||
[uxbox.util.spec :as us]
|
||||
|
@ -80,7 +80,7 @@
|
|||
(defn update-photo
|
||||
[{user :identity data :data}]
|
||||
(letfn [(store-photo [file]
|
||||
(let [filename (path/base-name file)
|
||||
(let [filename (fs/base-name file)
|
||||
storage media/images-storage]
|
||||
(st/save storage filename file)))
|
||||
(assign-photo [path]
|
||||
|
|
|
@ -6,9 +6,9 @@
|
|||
|
||||
(ns uxbox.images
|
||||
"Image postprocessing."
|
||||
(:require [storages.core :as st]
|
||||
[storages.util :as path]
|
||||
[clojure.spec :as s]
|
||||
(:require [clojure.spec :as s]
|
||||
[storages.core :as st]
|
||||
[storages.fs :as fs]
|
||||
[uxbox.util.spec :as us]
|
||||
[uxbox.media :as media]
|
||||
[uxbox.util.images :as images]
|
||||
|
@ -18,12 +18,12 @@
|
|||
|
||||
(defn make-thumbnail
|
||||
[path {:keys [size format quality] :as cfg}]
|
||||
(let [parent (path/parent path)
|
||||
[filename ext] (path/split-ext path)
|
||||
(let [parent (fs/parent path)
|
||||
[filename ext] (fs/split-ext path)
|
||||
|
||||
suffix-parts [(nth size 0) (nth size 1) quality format]
|
||||
final-name (apply str filename "-" (interpose "." suffix-parts))
|
||||
final-path (path/path parent final-name)
|
||||
final-path (fs/path parent final-name)
|
||||
|
||||
images-storage media/images-storage
|
||||
thumbs-storage media/thumbnails-storage]
|
||||
|
|
|
@ -10,19 +10,19 @@
|
|||
[clojure.java.io :as io]
|
||||
[cuerdas.core :as str]
|
||||
[storages.core :as st]
|
||||
[storages.fs.local :refer (filesystem)]
|
||||
[storages.fs.misc :refer (hashed scoped)]
|
||||
[storages.backend.local :refer (localfs)]
|
||||
[storages.backend.misc :refer (hashed scoped)]
|
||||
[uxbox.config :refer (config)]))
|
||||
|
||||
;; --- State
|
||||
|
||||
(defstate static-storage
|
||||
:start (let [{:keys [basedir baseuri]} (:static config)]
|
||||
(filesystem {:basedir basedir :baseuri baseuri})))
|
||||
(localfs {:basedir basedir :baseuri baseuri})))
|
||||
|
||||
(defstate media-storage
|
||||
:start (let [{:keys [basedir baseuri]} (:media config)]
|
||||
(filesystem {:basedir basedir :baseuri baseuri})))
|
||||
(localfs {:basedir basedir :baseuri baseuri})))
|
||||
|
||||
(defstate images-storage
|
||||
:start (-> media-storage
|
||||
|
|
|
@ -9,12 +9,11 @@
|
|||
(:refer-clojure :exclude [with-open])
|
||||
(:require [clojure.java.io :as io]
|
||||
[suricatta.core :as sc]
|
||||
[storages.util :as path]
|
||||
[storages.fs :as fs]
|
||||
[uxbox.db :as db]
|
||||
[uxbox.sql :as sql]
|
||||
[uxbox.util.uuid :as uuid]
|
||||
[uxbox.util.closeable :refer (with-open)]
|
||||
[uxbox.util.tempfile :as tmpfile]
|
||||
[uxbox.util.transit :as t]
|
||||
[uxbox.util.snappy :as snappy]))
|
||||
|
||||
|
@ -55,7 +54,7 @@
|
|||
"Given an id, returns a path to a temporal file with the exported
|
||||
bundle of the specified project."
|
||||
[id]
|
||||
(let [path (tmpfile/create)]
|
||||
(let [path (fs/create-tempfile)]
|
||||
(write-data path id)
|
||||
path))
|
||||
|
||||
|
@ -105,7 +104,7 @@
|
|||
(defn import!
|
||||
"Given a path to the previously exported bundle, try to import it."
|
||||
[path]
|
||||
(with-open [istream (io/input-stream (path/path path))
|
||||
(with-open [istream (io/input-stream (fs/path path))
|
||||
zstream (snappy/input-stream istream)
|
||||
conn (db/connection)]
|
||||
(let [reader (t/reader zstream {:type :msgpack})]
|
||||
|
|
|
@ -9,9 +9,8 @@
|
|||
(:require [clojure.spec :as s]
|
||||
[promesa.core :as p]
|
||||
[suricatta.core :as sc]
|
||||
[buddy.core.codecs :as codecs]
|
||||
[storages.core :as st]
|
||||
[storages.util :as path]
|
||||
[storages.fs :as fs]
|
||||
[uxbox.config :as ucfg]
|
||||
[uxbox.util.spec :as us]
|
||||
[uxbox.sql :as sql]
|
||||
|
@ -185,7 +184,7 @@
|
|||
(ex/raise :type :validation
|
||||
:code ::image-does-not-exists))
|
||||
(let [path @(st/lookup storage (:path image))
|
||||
filename (path/base-name path)
|
||||
filename (fs/base-name path)
|
||||
path @(st/save storage filename path)
|
||||
image (assoc image
|
||||
:path (str path)
|
||||
|
|
Loading…
Reference in a new issue