cortad 0.1.9 → 0.1.10
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/local.mjs +5 -2
- package/package.json +1 -1
package/local.mjs
CHANGED
|
@@ -719,7 +719,10 @@ if (!files.length) fail("no source files here to read.");
|
|
|
719
719
|
// Which project this is, as a hash of where it lives: the same folder coming back resumes the same
|
|
720
720
|
// connection, and the path itself never leaves this machine.
|
|
721
721
|
const project = createHash("sha256").update(realpathSync(root)).digest("hex").slice(0, 16);
|
|
722
|
-
|
|
722
|
+
// A network that drops while connecting ends here in a sentence, never a stack trace: running the
|
|
723
|
+
// command again starts a clean connection.
|
|
724
|
+
const unreachable = (err) => fail(`could not reach ${origin.host}: ${err?.name === "TimeoutError" ? "it did not answer in time" : "the connection failed"}. Check your connection and run the command again.`);
|
|
725
|
+
const attach = await call("POST", "/local/attach", { code, name: basename(root), project }).catch(unreachable);
|
|
723
726
|
if (!attach.ok) fail(attach.data?.error ?? `could not sign in (${attach.status})`);
|
|
724
727
|
box = attach.data.box;
|
|
725
728
|
key = attach.data.key;
|
|
@@ -759,7 +762,7 @@ const parts = Math.max(1, Math.ceil(bytes.length / PART));
|
|
|
759
762
|
for (let off = 0; off < bytes.length; off += PART) {
|
|
760
763
|
const last = off + PART >= bytes.length;
|
|
761
764
|
step(parts > 1 ? `connecting, ${Math.floor(off / PART) + 1} of ${parts}` : "connecting");
|
|
762
|
-
const put = await call("PUT", `/local/${box}/tree?last=${last ? 1 : 0}${last ? `&digest=${treeDigest}${head ? `&head=${head}` : ""}` : ""}`, bytes.subarray(off, off + PART), { raw: true, timeoutMs: 120_000 });
|
|
765
|
+
const put = await call("PUT", `/local/${box}/tree?last=${last ? 1 : 0}${last ? `&digest=${treeDigest}${head ? `&head=${head}` : ""}` : ""}`, bytes.subarray(off, off + PART), { raw: true, timeoutMs: 120_000 }).catch(unreachable);
|
|
763
766
|
if (!put.ok) fail(put.data?.error ?? `upload failed (${put.status})`);
|
|
764
767
|
if (last) resumed = put.data?.resumed === true;
|
|
765
768
|
}
|