(.require [library [lux (.except) [abstract [monad (.only do)]] [control ["[0]" try (.only Try)] [concurrency ["[0]" async (.only Async)]]] [data ["[0]" text (.only) ["%" \\format (.only format)]]] [world [environment (.only Environment)] ["[0]" file] [net [uri (.only URI) ["[0]" path]]]]]] ["[0]" // (.only) ["/[1]" // ["[1][0]" local] ["[1][0]" metadata]]]) (def .public (root environment fs) (-> (Environment Async) (file.System Async) file.Path) (let [/ (of fs separator)] (|> ///local.repository (text.replaced path.separator /) (format (of environment home) /)))) (def (path /) (-> Text (-> URI file.Path)) (text.replaced path.separator /)) (def (absolute_path environment fs) (-> (Environment Async) (file.System Async) (-> URI file.Path)) (let [/ (of fs separator)] (|>> ///metadata.local_uri (..path /) (format (..root environment fs) /)))) (def .public (repository environment fs) (-> (Environment Async) (file.System Async) (//.Repository Async)) (implementation (def description (..root environment fs)) (def download (|>> (..absolute_path environment fs) (of fs read))) (def (upload uri content) (do [! async.monad] [.let [absolute_path (..absolute_path environment fs uri)] ? (of fs file? absolute_path) _ (is (Async (Try Any)) (if ? (in {try.#Success []}) (when (file.parent fs absolute_path) {.#Some parent} (file.make_directories async.monad fs parent) _ (in {try.#Success []}))))] (of fs write absolute_path content)))))