diff --git a/fd.c b/fd.c index 373e36bc..5396a832 100644 --- a/fd.c +++ b/fd.c @@ -559,19 +559,22 @@ JSC_CCALL(fd_slurpwrite, size_t len; const char *data = js_get_blob_data(js, &len, argv[1]); - if (data == (const char *)-1) + if (!data) return JS_EXCEPTION; const char *str = JS_ToCString(js, argv[0]); if (!str) return JS_EXCEPTION; int fd = open(str, O_WRONLY | O_CREAT | O_TRUNC, 0644); - JS_FreeCString(js, str); - if (fd < 0) + if (fd < 0) { + JS_FreeCString(js, str); return JS_ThrowInternalError(js, "open failed for %s: %s", str, strerror(errno)); + } ssize_t written = write(fd, data, len); close(fd); + + JS_FreeCString(js, str); if (written != (ssize_t)len) return JS_ThrowInternalError(js, "write failed for %s: %s", str, strerror(errno)); diff --git a/link.ce b/link.ce index 88edcde3..4820a732 100644 --- a/link.ce +++ b/link.ce @@ -171,6 +171,7 @@ if (cmd == 'list') { link.add(pkg_name, target, shop) } catch (e) { log.console("Error: " + e.message) + log.error(e) $stop() return } diff --git a/link.cm b/link.cm index da421352..8457b754 100644 --- a/link.cm +++ b/link.cm @@ -81,7 +81,9 @@ Link.save = function(links) { link_cache = links var cfg = { links: links } var path = get_links_path() - fd.slurpwrite(path, new blob(toml.encode(cfg))) + var b = new blob(toml.encode(cfg)) + stone(b) + fd.slurpwrite(path, b) } Link.add = function(canonical, target, shop) { @@ -130,12 +132,13 @@ Link.add = function(canonical, target, shop) { shop.get(dep_locator) shop.extract(dep_locator) } catch (e) { - log.console(" Warning: Could not install dependency " + dep_locator + ": " + e.message) + log.console(` Warning: Could not install dependency ${dep_locator}: ${e.message}`) + log.error(e) } } } } catch (e) { - log.console(" Warning: Could not read dependencies from " + toml_path) + log.console(` Warning: Could not read dependencies from ${toml_path}`) } }