mirror of
https://github.com/janet-lang/janet
synced 2025-05-04 16:34:15 +00:00
Sync manifest on error so that we uninstall the correct files.
If we cannot create files during install, we want to be able to do a correct rollback.
This commit is contained in:
parent
9c437796d3
commit
367c4b14f5
@ -4001,6 +4001,13 @@
|
|||||||
(put manifest :files files)
|
(put manifest :files files)
|
||||||
files)
|
files)
|
||||||
|
|
||||||
|
(defn- sync-manifest
|
||||||
|
[&opt manifest]
|
||||||
|
(default manifest (dyn *bundle-manifest*))
|
||||||
|
(def bn (get manifest :bundle-name))
|
||||||
|
(def manifest-name (get-manifest-filename bn))
|
||||||
|
(spit manifest-name (string/format "%j\n" manifest)))
|
||||||
|
|
||||||
(defn bundle/manifest
|
(defn bundle/manifest
|
||||||
"Get the manifest for a give installed bundle"
|
"Get the manifest for a give installed bundle"
|
||||||
[bundle-name]
|
[bundle-name]
|
||||||
@ -4029,7 +4036,7 @@
|
|||||||
(defer (os/cd dir)
|
(defer (os/cd dir)
|
||||||
(print "running " filename-real " for bundle " bundle-name)
|
(print "running " filename-real " for bundle " bundle-name)
|
||||||
(dofile filename-real :env env)
|
(dofile filename-real :env env)
|
||||||
(spit manifest-name (string/format "%j\n" manifest)))))
|
(sync-manifest manifest))))
|
||||||
|
|
||||||
(defn bundle/uninstall
|
(defn bundle/uninstall
|
||||||
"Remove a bundle from the current syspath"
|
"Remove a bundle from the current syspath"
|
||||||
@ -4071,30 +4078,32 @@
|
|||||||
(defn bundle/add-directory
|
(defn bundle/add-directory
|
||||||
"Add a directory during the install process relative to `(dyn *syspath*)`"
|
"Add a directory during the install process relative to `(dyn *syspath*)`"
|
||||||
[dest &opt chmod-mode]
|
[dest &opt chmod-mode]
|
||||||
|
(edefer (sync-manifest)
|
||||||
(def files (get-files))
|
(def files (get-files))
|
||||||
(def absdest (string (dyn *syspath*) "/" dest))
|
(def absdest (string (dyn *syspath*) "/" dest))
|
||||||
(unless (os/mkdir absdest)
|
(unless (os/mkdir absdest)
|
||||||
(errorf "collision at %s, directory already exists" absdest))
|
(errorf "collision at %s, directory already exists" absdest))
|
||||||
|
(array/push files absdest)
|
||||||
(when chmod-mode
|
(when chmod-mode
|
||||||
(os/chmod absdest chmod-mode))
|
(os/chmod absdest chmod-mode))
|
||||||
(array/push files absdest)
|
|
||||||
(print "adding " absdest)
|
(print "adding " absdest)
|
||||||
absdest)
|
absdest))
|
||||||
|
|
||||||
(defn bundle/add-file
|
(defn bundle/add-file
|
||||||
"Add files during an install relative to `(dyn *syspath*)`"
|
"Add files during an install relative to `(dyn *syspath*)`"
|
||||||
[src &opt dest chmod-mode]
|
[src &opt dest chmod-mode]
|
||||||
(default dest src)
|
(default dest src)
|
||||||
|
(edefer (sync-manifest)
|
||||||
(def files (get-files))
|
(def files (get-files))
|
||||||
(def absdest (string (dyn *syspath*) "/" dest))
|
(def absdest (string (dyn *syspath*) "/" dest))
|
||||||
(when (os/stat absdest :mode)
|
(when (os/stat absdest :mode)
|
||||||
(errorf "collision at %s, file already exists" absdest))
|
(errorf "collision at %s, file already exists" absdest))
|
||||||
(spit absdest (slurp src))
|
(spit absdest (slurp src))
|
||||||
|
(array/push files absdest)
|
||||||
(when chmod-mode
|
(when chmod-mode
|
||||||
(os/chmod dest chmod-mode))
|
(os/chmod dest chmod-mode))
|
||||||
(array/push files absdest)
|
|
||||||
(print "adding " absdest)
|
(print "adding " absdest)
|
||||||
absdest)
|
absdest))
|
||||||
|
|
||||||
(defn bundle/list
|
(defn bundle/list
|
||||||
"Get a list of all installed bundles in lexical order."
|
"Get a list of all installed bundles in lexical order."
|
||||||
|
Loading…
x
Reference in New Issue
Block a user