fd check blob stone

This commit is contained in:
2026-01-09 08:23:40 -06:00
parent e04b15973a
commit 86a70bce3a
3 changed files with 13 additions and 6 deletions

9
fd.c
View File

@@ -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));

View File

@@ -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
}

View File

@@ -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}`)
}
}