diff options
Diffstat (limited to '')
-rw-r--r-- | stdlib/source/program/aedifex/repository/local.lux | 22 |
1 files changed, 14 insertions, 8 deletions
diff --git a/stdlib/source/program/aedifex/repository/local.lux b/stdlib/source/program/aedifex/repository/local.lux index f313b3176..7ac384efa 100644 --- a/stdlib/source/program/aedifex/repository/local.lux +++ b/stdlib/source/program/aedifex/repository/local.lux @@ -19,7 +19,8 @@ ["." uri (#+ URI)]]]] ["." // ["/#" // #_ - ["#." local]]]) + ["#." local] + ["#." metadata]]]) (def: (root /) (-> Text Path) @@ -29,18 +30,23 @@ (-> Text URI Path) (text.replace_all uri.separator)) -(def: (file program system uri) +(def: (file program system create? uri) (-> (Program Promise) (file.System Promise) + Bit URI (Promise (Try (File Promise)))) (do {! promise.monad} - [home (\ program home []) + [#let [uri (text.replace_once ///metadata.remote_file ///metadata.local_file uri)] + home (\ program home []) #let [/ (\ system separator) absolute_path (format home / (..root /) / (..path / uri))]] - (do {! (try.with !)} - [_ (: (Promise (Try Path)) - (file.make_directories promise.monad system (file.parent system absolute_path)))] + (if create? + (do {! (try.with !)} + [_ (: (Promise (Try Path)) + (file.make_directories promise.monad system (file.parent system absolute_path)))] + (: (Promise (Try (File Promise))) + (file.get_file promise.monad system absolute_path))) (: (Promise (Try (File Promise))) (!.use (\ system file) absolute_path))))) @@ -49,10 +55,10 @@ (def: (download uri) (do {! (try.with promise.monad)} - [file (..file program system uri)] + [file (..file program system false uri)] (!.use (\ file content) []))) (def: (upload uri content) (do {! (try.with promise.monad)} - [file (..file program system uri)] + [file (..file program system true uri)] (!.use (\ file over_write) [content])))) |