(.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 [program (.only Program)] ["[0]" file] [net ["[0]" uri (.only URI)]]]]] ["[0]" // (.only) ["/[1]" // ["[1][0]" local] ["[1][0]" metadata]]]) (def .public (root program fs) (-> (Program Async) (file.System Async) file.Path) (let [/ (at fs separator)] (|> ///local.repository (text.replaced uri.separator /) (format (at program home) /)))) (def (path /) (-> Text (-> URI file.Path)) (text.replaced uri.separator /)) (def (absolute_path program fs) (-> (Program Async) (file.System Async) (-> URI file.Path)) (let [/ (at fs separator)] (|>> ///metadata.local_uri (..path /) (format (..root program fs) /)))) (def .public (repository program fs) (-> (Program Async) (file.System Async) (//.Repository Async)) (implementation (def description (..root program fs)) (def download (|>> (..absolute_path program fs) (at fs read))) (def (upload uri content) (do [! async.monad] [.let [absolute_path (..absolute_path program fs uri)] ? (at fs file? absolute_path) _ (is (Async (Try Any)) (if ? (in {try.#Success []}) (case (file.parent fs absolute_path) {.#Some parent} (file.make_directories async.monad fs parent) _ (in {try.#Success []}))))] (at fs write absolute_path content)))))