@ref0/git 0.14.0 → 0.20.0
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/dist/auth/access-jwt.mjs +2 -2
- package/dist/auth/authorize.mjs +3 -3
- package/dist/auth/fences.d.mts +1 -2
- package/dist/auth/fences.mjs +3 -3
- package/dist/auth/grants.mjs +4 -4
- package/dist/auth/host-function.mjs +18 -1
- package/dist/auth/identify.d.mts +1 -1
- package/dist/auth/identify.mjs +3 -3
- package/dist/auth/token-cleanup.mjs +67 -0
- package/dist/auth/token-rows.mjs +1 -1
- package/dist/auth/token-text.mjs +9 -1
- package/dist/auth/tokens-base.d.mts +35 -0
- package/dist/auth/tokens-base.mjs +13 -0
- package/dist/auth/tokens-layer.d.mts +2 -27
- package/dist/auth/tokens-layer.mjs +6 -11
- package/dist/auth/tokens-public.d.mts +3 -3
- package/dist/auth/tokens.d.mts +7 -10
- package/dist/auth/tokens.mjs +9 -80
- package/dist/client/answer.mjs +21 -42
- package/dist/client/client.d.mts +2 -4
- package/dist/client/git-http.mjs +17 -7
- package/dist/client/local.mjs +14 -13
- package/dist/client/push-upload.mjs +9 -8
- package/dist/client/remote.mjs +8 -10
- package/dist/client/run-remote-helper.d.mts +1 -0
- package/dist/client/run-remote-helper.mjs +58 -24
- package/dist/client/slice-push.d.mts +1 -1
- package/dist/client/transport.mjs +105 -46
- package/dist/contracts/blobs.d.mts +55 -8
- package/dist/contracts/blobs.mjs +16 -2
- package/dist/contracts/call-allowance.d.mts +13 -0
- package/dist/contracts/call-allowance.mjs +44 -0
- package/dist/contracts/calls-spent.mjs +8 -3
- package/dist/contracts/client.d.mts +15 -16
- package/dist/contracts/commits.d.mts +24 -24
- package/dist/contracts/engine.d.mts +6 -1
- package/dist/contracts/engine.mjs +10 -1
- package/dist/contracts/files.d.mts +10 -10
- package/dist/contracts/forks.d.mts +17 -17
- package/dist/contracts/git-events.d.mts +29 -1
- package/dist/contracts/git-hooks.d.mts +1 -1
- package/dist/contracts/git.d.mts +21 -0
- package/dist/contracts/grants.d.mts +24 -4
- package/dist/contracts/handlers.d.mts +1 -1
- package/dist/contracts/lfs.d.mts +28 -2
- package/dist/contracts/merges.d.mts +3 -2
- package/dist/contracts/objects.d.mts +23 -25
- package/dist/contracts/queue.d.mts +40 -12
- package/dist/contracts/queue.mjs +3 -4
- package/dist/contracts/refs.d.mts +26 -23
- package/dist/contracts/remote.d.mts +6 -7
- package/dist/contracts/remote.mjs +4 -1
- package/dist/contracts/repos.d.mts +29 -138
- package/dist/contracts/repos.mjs +5 -3
- package/dist/contracts/result.d.mts +35 -16
- package/dist/contracts/result.mjs +35 -7
- package/dist/contracts/server.d.mts +25 -50
- package/dist/contracts/services.d.mts +1 -1
- package/dist/contracts/store.d.mts +6 -5
- package/dist/contracts/sync.d.mts +11 -7
- package/dist/contracts/sync.mjs +12 -2
- package/dist/contracts/tags.d.mts +10 -10
- package/dist/contracts/time.d.mts +3 -0
- package/dist/contracts/{promises.mjs → time.mjs} +1 -1
- package/dist/contracts/tokens.d.mts +15 -17
- package/dist/contracts/tokens.mjs +3 -2
- package/dist/contracts/topics.d.mts +1 -1
- package/dist/contracts/trees.d.mts +12 -12
- package/dist/contracts/work.d.mts +24 -13
- package/dist/core/access.d.mts +1 -2
- package/dist/core/access.mjs +20 -9
- package/dist/core/ancestry.d.mts +1 -0
- package/dist/core/asked.mjs +1 -1
- package/dist/core/call-names.mjs +6 -1
- package/dist/core/call-services.mjs +11 -3
- package/dist/core/events/deliver.d.mts +1 -2
- package/dist/core/events/deliver.mjs +43 -36
- package/dist/core/events/retired.mjs +119 -0
- package/dist/core/forks.mjs +928 -432
- package/dist/core/hooks/groups.mjs +1 -1
- package/dist/core/imports.mjs +29 -23
- package/dist/core/index-job.mjs +122 -34
- package/dist/core/index-lost.d.mts +1 -2
- package/dist/core/index-lost.mjs +2 -2
- package/dist/core/loose-tally.mjs +1 -1
- package/dist/core/objects/blobs.mjs +129 -3
- package/dist/core/objects/lines.mjs +2 -2
- package/dist/core/objects/merges.mjs +4 -1
- package/dist/core/objects/objects-layer.d.mts +1 -1
- package/dist/core/objects/objects-layer.mjs +3 -3
- package/dist/core/objects/reading.mjs +24 -13
- package/dist/core/objects/tags.mjs +4 -1
- package/dist/core/objects/trees.mjs +2 -2
- package/dist/core/objects/writing.mjs +2 -2
- package/dist/core/own-writes.mjs +1 -1
- package/dist/core/parts.d.mts +4 -5
- package/dist/core/parts.mjs +3 -8
- package/dist/core/promise.mjs +9 -12
- package/dist/core/purge.mjs +287 -83
- package/dist/core/push-decide.mjs +2 -0
- package/dist/core/push-files.d.mts +1 -1
- package/dist/core/push.mjs +58 -47
- package/dist/core/receipts.mjs +8 -3
- package/dist/core/ref-index-job.mjs +4 -4
- package/dist/core/ref-view.mjs +2 -2
- package/dist/core/refs.mjs +5 -5
- package/dist/core/registered-rows.mjs +2 -2
- package/dist/core/repack.mjs +36 -21
- package/dist/core/repo-info.mjs +3 -3
- package/dist/core/repos.mjs +21 -9
- package/dist/core/rules/commit-changes.d.mts +0 -1
- package/dist/core/saved-caller-views.d.mts +7 -2
- package/dist/core/saved-caller-views.mjs +2 -2
- package/dist/core/saved-callers.d.mts +19 -2
- package/dist/core/seam.d.mts +16 -26
- package/dist/core/seam.mjs +7 -28
- package/dist/core/tokens.mjs +1 -1
- package/dist/core/view.mjs +7 -15
- package/dist/core/work.mjs +59 -14
- package/dist/effect.d.mts +3 -12
- package/dist/effect.mjs +1 -10
- package/dist/engine/failures.mjs +2 -1
- package/dist/engine/reads.mjs +4 -4
- package/dist/event-streams/stream.d.mts +2 -2
- package/dist/event-streams/stream.mjs +37 -14
- package/dist/extend.d.mts +2 -3
- package/dist/extend.mjs +2 -1
- package/dist/http/answers.mjs +8 -5
- package/dist/http/core-parts.mjs +95 -79
- package/dist/http/handler.mjs +34 -7
- package/dist/http/node.d.mts +14 -1
- package/dist/http/node.mjs +56 -27
- package/dist/http/parts.d.mts +1 -0
- package/dist/http/push-upload-job.mjs +30 -26
- package/dist/http/push-uploads.mjs +36 -21
- package/dist/http/upload-pack.mjs +3 -3
- package/dist/index.d.mts +14 -14
- package/dist/index.mjs +2 -2
- package/dist/lfs/answer.mjs +37 -0
- package/dist/lfs/base.d.mts +2 -0
- package/dist/lfs/base.mjs +25 -1
- package/dist/lfs/copy.d.mts +21 -7
- package/dist/lfs/copy.mjs +89 -6
- package/dist/lfs/layer.d.mts +15 -1
- package/dist/lfs/layer.mjs +24 -11
- package/dist/lfs/locks.mjs +2 -2
- package/dist/lfs/objects.d.mts +1 -0
- package/dist/lfs/objects.mjs +87 -17
- package/dist/lfs/pointers.mjs +2 -2
- package/dist/lfs/rows.mjs +42 -8
- package/dist/lfs/upkeep.mjs +48 -14
- package/dist/lfs/wire.mjs +6 -31
- package/dist/merges/merges.mjs +2 -2
- package/dist/node.d.mts +2 -2
- package/dist/protocol/bytes/buffers.mjs +13 -5
- package/dist/protocol/bytes/reader.mjs +6 -1
- package/dist/protocol/bytes/streams.mjs +27 -1
- package/dist/protocol/diff/read.d.mts +4 -3
- package/dist/protocol/diff/read.mjs +8 -3
- package/dist/protocol/objects/lfs-pointer.d.mts +14 -2
- package/dist/protocol/objects/lfs-pointer.mjs +1 -3
- package/dist/protocol/objects/links-raw.mjs +24 -10
- package/dist/protocol/objects/tag.d.mts +1 -1
- package/dist/protocol/objects/tree.mjs +23 -6
- package/dist/protocol/packs/delta.d.mts +6 -3
- package/dist/protocol/packs/delta.mjs +96 -32
- package/dist/protocol/packs/idx.d.mts +2 -1
- package/dist/protocol/packs/idx.mjs +22 -3
- package/dist/protocol/packs/parts.d.mts +4 -1
- package/dist/protocol/packs/parts.mjs +10 -7
- package/dist/protocol/packs/reader.d.mts +5 -0
- package/dist/protocol/packs/reader.mjs +3 -2
- package/dist/protocol/packs/writer.mjs +26 -8
- package/dist/queue/advance.mjs +21 -24
- package/dist/queue/base.d.mts +55 -0
- package/dist/queue/base.mjs +44 -0
- package/dist/queue/calls.mjs +51 -54
- package/dist/queue/commit.mjs +1 -1
- package/dist/queue/host.d.mts +1 -15
- package/dist/queue/host.mjs +2 -7
- package/dist/queue/layer.d.mts +2 -1
- package/dist/queue/layer.mjs +10 -3
- package/dist/queue/limits.mjs +2 -0
- package/dist/queue/push-option.mjs +9 -24
- package/dist/queue/schedule.mjs +1 -1
- package/dist/queue/state.mjs +2 -10
- package/dist/queue/trim.mjs +5 -3
- package/dist/rest/blobs.mjs +29 -5
- package/dist/rest/caller.d.mts +4 -4271
- package/dist/rest/caller.mjs +4 -0
- package/dist/rest/client.d.mts +8 -5
- package/dist/rest/client.mjs +19 -2
- package/dist/rest/handlers.mjs +50 -5
- package/dist/rest/layer.d.mts +2 -2
- package/dist/rest/layer.mjs +5 -12
- package/dist/rest/me.d.mts +3 -432
- package/dist/server/check-fetch.mjs +3 -3
- package/dist/server/edge-node.d.mts +11 -8
- package/dist/server/edge-node.mjs +9 -6
- package/dist/server/edge.d.mts +21 -7
- package/dist/server/edge.mjs +32 -11
- package/dist/server/extension.mjs +1 -1
- package/dist/server/git-layer.d.mts +5 -5
- package/dist/server/git-layer.mjs +28 -22
- package/dist/server/git-namespace.d.mts +4 -3
- package/dist/server/git-namespace.mjs +3 -2
- package/dist/server/joined.d.mts +6 -18
- package/dist/server/joined.mjs +9 -36
- package/dist/server/lifecycle.mjs +18 -106
- package/dist/server/registry.mjs +24 -7
- package/dist/server/server.mjs +205 -346
- package/dist/signin/context.d.mts +1 -2
- package/dist/signin/layer.d.mts +1 -1
- package/dist/signin/layer.mjs +1 -1
- package/dist/storage/allotted.mjs +18 -3
- package/dist/storage/batch-upkeep.mjs +274 -0
- package/dist/storage/batches.d.mts +8 -0
- package/dist/storage/batches.mjs +344 -0
- package/dist/storage/calls.d.mts +1 -2
- package/dist/storage/calls.mjs +144 -158
- package/dist/storage/chunks.d.mts +9 -0
- package/dist/storage/chunks.mjs +297 -0
- package/dist/storage/clean-up.mjs +72 -9
- package/dist/storage/counted-bucket.mjs +4 -4
- package/dist/storage/fetch.d.mts +1 -0
- package/dist/storage/fetch.mjs +287 -210
- package/dist/storage/host-bucket.mjs +1 -2
- package/dist/storage/id-mix.mjs +19 -5
- package/dist/storage/index-bitmaps.mjs +9 -2
- package/dist/storage/index-build.d.mts +0 -1
- package/dist/storage/index-build.mjs +80 -23
- package/dist/storage/index-fetch.mjs +113 -72
- package/dist/storage/index-files.d.mts +3 -0
- package/dist/storage/index-files.mjs +10 -5
- package/dist/storage/index-graph.mjs +72 -22
- package/dist/storage/index-remap.mjs +200 -64
- package/dist/storage/index-whole.mjs +127 -0
- package/dist/storage/largest-files.mjs +1 -1
- package/dist/storage/layout.mjs +23 -0
- package/dist/storage/loose.d.mts +7 -4
- package/dist/storage/loose.mjs +212 -67
- package/dist/storage/memory-budget.mjs +16 -4
- package/dist/storage/merge-plan.mjs +3 -2
- package/dist/storage/merge-row.mjs +7 -1
- package/dist/storage/merge-stream.mjs +164 -25
- package/dist/storage/merge-walk.mjs +8 -4
- package/dist/storage/merge-write.mjs +1 -1
- package/dist/storage/merge.d.mts +1 -1
- package/dist/storage/merge.mjs +1 -1
- package/dist/storage/object-rows.d.mts +1 -0
- package/dist/storage/object-rows.mjs +385 -65
- package/dist/storage/oid-table.mjs +171 -0
- package/dist/storage/pack-order.mjs +8 -4
- package/dist/storage/pack-ranges.d.mts +1 -2
- package/dist/storage/pack-ranges.mjs +4 -5
- package/dist/storage/pack-reads.d.mts +2 -1
- package/dist/storage/pack-reads.mjs +158 -42
- package/dist/storage/pack-receive.d.mts +1 -1
- package/dist/storage/pack-receive.mjs +2 -2
- package/dist/storage/packs.d.mts +1 -1
- package/dist/storage/packs.mjs +136 -66
- package/dist/storage/placed-reads.mjs +1 -1
- package/dist/storage/plan-columns.d.mts +4 -0
- package/dist/storage/plan-columns.mjs +238 -0
- package/dist/storage/prune-keep.mjs +134 -41
- package/dist/storage/prune-walk.mjs +202 -62
- package/dist/storage/prune.mjs +194 -91
- package/dist/storage/push-allotment.mjs +91 -12
- package/dist/storage/push-uploads.mjs +4 -4
- package/dist/storage/pushed-commits.mjs +4 -2
- package/dist/storage/quarantine.d.mts +1 -1
- package/dist/storage/range-cache.mjs +125 -8
- package/dist/storage/ready.d.mts +1 -1
- package/dist/storage/ready.mjs +8 -6
- package/dist/storage/receive-bounds.mjs +23 -8
- package/dist/storage/repack-backlog.mjs +6 -3
- package/dist/storage/repack.d.mts +1 -1
- package/dist/storage/rows.d.mts +1 -1
- package/dist/storage/rows.mjs +1 -1
- package/dist/storage/runs.mjs +195 -43
- package/dist/storage/send-list.d.mts +1 -0
- package/dist/storage/send-list.mjs +54 -10
- package/dist/storage/single-flight.mjs +13 -7
- package/dist/storage/stream-whole.mjs +127 -26
- package/dist/storage/unpack.mjs +371 -79
- package/dist/storage/visible.mjs +2 -2
- package/dist/storage/walk.mjs +192 -38
- package/dist/storage/wants.mjs +5 -5
- package/dist/store/bodies.mjs +38 -0
- package/dist/store/call-count.d.mts +8 -12
- package/dist/store/call-count.mjs +34 -46
- package/dist/store/catalogue.d.mts +2 -2
- package/dist/store/catalogue.mjs +145 -35
- package/dist/store/crossing.mjs +1 -3
- package/dist/store/cursor-seal.d.mts +1 -2
- package/dist/store/cursor-seal.mjs +16 -6
- package/dist/store/door.mjs +183 -0
- package/dist/store/errors.d.mts +3 -4
- package/dist/store/errors.mjs +15 -33
- package/dist/store/git-store.mjs +25 -7
- package/dist/store/job-try.mjs +9 -32
- package/dist/store/list-job.mjs +44 -8
- package/dist/store/records.d.mts +3 -0
- package/dist/store/records.mjs +3 -0
- package/dist/store/repo-record.d.mts +1 -2
- package/dist/store/repo-record.mjs +32 -20
- package/dist/store/reservations.mjs +1 -1
- package/dist/store/scopes.mjs +11 -0
- package/dist/store/settle.mjs +4 -4
- package/dist/sync/github.mjs +3 -3
- package/dist/sync/import.mjs +31 -18
- package/dist/sync/lfs-batch.mjs +4 -5
- package/dist/sync/lfs-copy.mjs +17 -6
- package/dist/sync/mirror.mjs +34 -31
- package/dist/sync/said.mjs +16 -37
- package/dist/sync/step.mjs +33 -25
- package/dist/sync/tries.mjs +9 -9
- package/dist/topics/advance.mjs +10 -11
- package/dist/topics/base.d.mts +15 -0
- package/dist/topics/base.mjs +8 -0
- package/dist/topics/host.mjs +1 -1
- package/dist/topics/layer.d.mts +4 -9
- package/dist/topics/layer.mjs +2 -3
- package/dist/topics/members.mjs +4 -4
- package/dist/topics/public.d.mts +2 -1
- package/dist/topics/topic.mjs +2 -2
- package/package.json +5 -4
- package/dist/contracts/promises.d.mts +0 -39
- package/dist/core/call-names.d.mts +0 -3
- package/dist/core/clock.mjs +0 -18
- package/dist/lfs/calls.mjs +0 -26
- package/dist/rest/api.d.mts +0 -23
- package/dist/rest/blobs.d.mts +0 -833
- package/dist/rest/commits.d.mts +0 -3543
- package/dist/rest/errors.d.mts +0 -2124
- package/dist/rest/events.d.mts +0 -426
- package/dist/rest/files.d.mts +0 -1342
- package/dist/rest/forks.d.mts +0 -2160
- package/dist/rest/handlers.d.mts +0 -8
- package/dist/rest/merges.d.mts +0 -477
- package/dist/rest/queue.d.mts +0 -5917
- package/dist/rest/refs.d.mts +0 -2988
- package/dist/rest/repos.d.mts +0 -2567
- package/dist/rest/tags.d.mts +0 -1316
- package/dist/rest/tokens.d.mts +0 -2614
- package/dist/rest/topics.d.mts +0 -2224
- package/dist/rest/trees.d.mts +0 -1709
- package/dist/rest/work.d.mts +0 -1695
- package/dist/server/lifecycle.d.mts +0 -2
- package/dist/store/promises.d.mts +0 -11
- package/dist/store/promises.mjs +0 -327
package/dist/sync/import.mjs
CHANGED
|
@@ -1,11 +1,12 @@
|
|
|
1
1
|
import { fail, gitError } from "../contracts/result.mjs";
|
|
2
|
+
import { ImportDepth, importDepthMost } from "../contracts/sync.mjs";
|
|
2
3
|
import { openRepo } from "../core/access.mjs";
|
|
3
4
|
import { CoreParts, QueueParts } from "../core/parts.mjs";
|
|
4
5
|
import { creatingRefView } from "../core/ref-view.mjs";
|
|
5
6
|
import { createWith, repoCalls } from "../core/repos.mjs";
|
|
6
7
|
import { hostRecordOf } from "../store/catalogue.mjs";
|
|
7
8
|
import { importJobName } from "../store/records.mjs";
|
|
8
|
-
import { afterWrites, storeCall } from "../store/errors.mjs";
|
|
9
|
+
import { afterWrites, storeCall, storeCommit } from "../store/errors.mjs";
|
|
9
10
|
import { newChangeId, repoScope } from "../store/scopes.mjs";
|
|
10
11
|
import { unknownProvider } from "./tries.mjs";
|
|
11
12
|
import { heldError } from "../core/receipts.mjs";
|
|
@@ -40,26 +41,35 @@ const cancelled = (repo) => fail("FAILED_PRECONDITION", `The import of '${repo}'
|
|
|
40
41
|
context: { reason: "import-cancelled" }
|
|
41
42
|
});
|
|
42
43
|
const noImport = (repo) => fail("NOT_FOUND", `'${repo}' has no import running`);
|
|
44
|
+
const isImportDepth = /* @__PURE__ */ Schema.is(ImportDepth);
|
|
45
|
+
/** Whether `depth` is one `ImportDepth` takes, as a plain answer: no narrowing of `depth`. */
|
|
46
|
+
const isDepth = (depth) => isImportDepth(depth);
|
|
47
|
+
/** `depth` refused unless it's what an import takes, `ImportDepth`: before anything is written. */
|
|
48
|
+
const checkedDepth = (depth) => depth === void 0 || isDepth(depth) ? Effect.void : fail("INVALID_ARGUMENT", `An import's depth is a whole number from 1 to ${importDepthMost}, not ${depth}`, { hint: "Leave depth out to import the whole history" });
|
|
43
49
|
/** The import's record as its create writes it: nothing listed or copied yet. */
|
|
44
|
-
const startRow = (bound, input, by) =>
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
50
|
+
const startRow = (bound, input, by) => {
|
|
51
|
+
const row = {
|
|
52
|
+
source: {
|
|
53
|
+
provider: input.source.provider,
|
|
54
|
+
repo: input.source.repo
|
|
55
|
+
},
|
|
56
|
+
by,
|
|
57
|
+
state: "running",
|
|
58
|
+
roots: [],
|
|
59
|
+
deepest: 0,
|
|
60
|
+
step: bound.limits.firstStep,
|
|
61
|
+
copied: false,
|
|
62
|
+
objects: 0,
|
|
63
|
+
bytes: 0
|
|
64
|
+
};
|
|
65
|
+
if (input.depth !== void 0) row.depth = input.depth;
|
|
66
|
+
return row;
|
|
67
|
+
};
|
|
58
68
|
const encodeSample = /* @__PURE__ */ Schema.encodeUnknownEffect(Schema.fromJsonString(Schema.Unknown));
|
|
59
69
|
/** The latest sample the import's running try reported, as `onProgress` takes it, if it's new. */
|
|
60
70
|
const progressOf = /* @__PURE__ */ Effect.fnUntraced(function* (internalId) {
|
|
61
71
|
const { jobs } = yield* QueueParts;
|
|
62
|
-
const sample = (yield* storeCall(
|
|
72
|
+
const sample = (yield* storeCall(jobs.list(repoScope(internalId), { state: "running" }))).items.find((job) => job.name === importJobName)?.progress;
|
|
63
73
|
if (sample === void 0 || !isPhase(sample.phase)) return void 0;
|
|
64
74
|
return {
|
|
65
75
|
seen: yield* encodeSample(sample).pipe(Effect.orElseSucceed(() => void 0)),
|
|
@@ -111,10 +121,12 @@ const importWith = /* @__PURE__ */ Effect.fnUntraced(function* (bound, input) {
|
|
|
111
121
|
if (!bound.providers.has(source.provider)) return yield* Effect.fail(unknownProvider(source.provider));
|
|
112
122
|
const { actor } = input;
|
|
113
123
|
if (actor.anonymous === true) return yield* fail("UNAUTHENTICATED", "An import needs an actor: each step asks again as it");
|
|
124
|
+
yield* checkedDepth(input.depth);
|
|
114
125
|
const data = { source: {
|
|
115
126
|
provider: source.provider,
|
|
116
127
|
repo: source.repo
|
|
117
128
|
} };
|
|
129
|
+
if (input.depth !== void 0) data.depth = input.depth;
|
|
118
130
|
const caller = { actor };
|
|
119
131
|
const by = yield* savedCallerOf(actor.id, caller);
|
|
120
132
|
const create = {
|
|
@@ -126,7 +138,8 @@ const importWith = /* @__PURE__ */ Effect.fnUntraced(function* (bound, input) {
|
|
|
126
138
|
input: [
|
|
127
139
|
"import",
|
|
128
140
|
source.provider,
|
|
129
|
-
source.repo
|
|
141
|
+
source.repo,
|
|
142
|
+
...input.depth === void 0 ? [] : [input.depth]
|
|
130
143
|
],
|
|
131
144
|
put: [importRow(startRow(bound, input, by))],
|
|
132
145
|
jobs: [bound.importJob.encodedJob({
|
|
@@ -150,7 +163,7 @@ const cancelWith = /* @__PURE__ */ Effect.fnUntraced(function* (_bound, input) {
|
|
|
150
163
|
const read = yield* readImport(store, internalId, opened);
|
|
151
164
|
if (read.row?.state !== "running") return yield* noImport(input.repo);
|
|
152
165
|
if (read.cancelled) return;
|
|
153
|
-
yield*
|
|
166
|
+
yield* storeCommit(store.commit(repoScope(internalId), {
|
|
154
167
|
id: newChangeId(),
|
|
155
168
|
expect: read.version,
|
|
156
169
|
put: [{
|
package/dist/sync/lfs-batch.mjs
CHANGED
|
@@ -1,7 +1,8 @@
|
|
|
1
1
|
import { credentialHeader } from "../client/transport.mjs";
|
|
2
2
|
import { gitError } from "../contracts/result.mjs";
|
|
3
|
-
import {
|
|
4
|
-
import {
|
|
3
|
+
import { lfsType } from "../lfs/answer.mjs";
|
|
4
|
+
import { BatchRequest, LfsObjectAnswer } from "../lfs/wire.mjs";
|
|
5
|
+
import { boundedBytes, dropBody } from "../protocol/bytes/reader.mjs";
|
|
5
6
|
import { decodeJson } from "../protocol/wire/json.mjs";
|
|
6
7
|
import { readBody } from "../store/errors.mjs";
|
|
7
8
|
import * as Effect from "effect/Effect";
|
|
@@ -68,9 +69,7 @@ const unanswered = /* @__PURE__ */ gitError("UNAVAILABLE", "The source's LFS API
|
|
|
68
69
|
/** The source's batch refusing, by its status alone: its body may echo the credential. */
|
|
69
70
|
const batchRefused = (status) => gitError("UNAVAILABLE", `The source's LFS batch answered ${status}`, { hint: "The job tries again" });
|
|
70
71
|
/** A response's body let go, its cancel's failure no reason to fail what's already decided. */
|
|
71
|
-
const letGo = (response) =>
|
|
72
|
-
await response.body?.cancel().catch(() => void 0);
|
|
73
|
-
});
|
|
72
|
+
const letGo = (response) => dropBody(response.body);
|
|
74
73
|
/**
|
|
75
74
|
* The source's offers for `wanted`, at most `lfsBatchMost` objects, asked of `remote` with its
|
|
76
75
|
* credentials through `send`. A source answering 404 or 501 serves no LFS API: `no-lfs`. Any other
|
package/dist/sync/lfs-copy.mjs
CHANGED
|
@@ -3,7 +3,7 @@ import { importLfsPagesMost, importRow, lfsMissedHeld, lfsPageKey, lfsPageRow, m
|
|
|
3
3
|
import { CoreParts } from "../core/parts.mjs";
|
|
4
4
|
import { largestObject } from "../lfs/rows.mjs";
|
|
5
5
|
import { lfsOidAt, lfsSizeAt, pointersOfRecord, pointersRecords } from "../storage/lfs-pointers.mjs";
|
|
6
|
-
import {
|
|
6
|
+
import { storeCommit } from "../store/errors.mjs";
|
|
7
7
|
import { newChangeId, repoScope } from "../store/scopes.mjs";
|
|
8
8
|
import { lfsCopyBytes } from "./bound.mjs";
|
|
9
9
|
import { letGo, lfsDownloads } from "./lfs-batch.mjs";
|
|
@@ -143,7 +143,7 @@ const committed = /* @__PURE__ */ Effect.fnUntraced(function* (attempt, copy, ve
|
|
|
143
143
|
missing: counted.missing,
|
|
144
144
|
named: counted.named
|
|
145
145
|
};
|
|
146
|
-
if (!(yield*
|
|
146
|
+
if (!(yield* storeCommit(store.commit(repoScope(attempt.internalId), {
|
|
147
147
|
id: newChangeId(),
|
|
148
148
|
expect: version,
|
|
149
149
|
put: [
|
|
@@ -180,9 +180,12 @@ const restMissing = (pointers, from, listed) => {
|
|
|
180
180
|
/**
|
|
181
181
|
* One step of the copy, at the import's record as read at `version`: the objects `takenFrom` the
|
|
182
182
|
* cursor's page that the repo doesn't list, asked of the source in one batch, each download piped
|
|
183
|
-
* to its
|
|
184
|
-
*
|
|
185
|
-
*
|
|
183
|
+
* to its object's staging key, one at a time, then one commit. An object whose bytes an earlier
|
|
184
|
+
* try put at its key, and didn't list, is listed with no download. A source with no LFS API gives
|
|
185
|
+
* none, so the rest of the page is missing with them. A download that fails keeps what landed
|
|
186
|
+
* before it and fails the try, whose next asks a fresh batch from the cursor. Upkeep's commit that
|
|
187
|
+
* ends a stage moves the version, so a step that staged before it fails `copyRaced`, and its next
|
|
188
|
+
* try stages again.
|
|
186
189
|
*/
|
|
187
190
|
const copyLfs = /* @__PURE__ */ Effect.fnUntraced(function* (attempt, version, row, lfs, copy) {
|
|
188
191
|
const { bound, internalId, context } = attempt;
|
|
@@ -221,11 +224,19 @@ const copyLfs = /* @__PURE__ */ Effect.fnUntraced(function* (attempt, version, r
|
|
|
221
224
|
size: offer.size,
|
|
222
225
|
reason: offer.reason
|
|
223
226
|
});
|
|
224
|
-
const staged = yield* copy.stage(internalId, downloads
|
|
227
|
+
const staged = yield* copy.stage(internalId, downloads);
|
|
225
228
|
const landed = [];
|
|
226
229
|
for (const [index, offer] of downloads.entries()) {
|
|
227
230
|
const staging = staged[index];
|
|
228
231
|
if (staging === void 0) break;
|
|
232
|
+
if (staging.landed) {
|
|
233
|
+
landed.push({
|
|
234
|
+
oid: offer.oid,
|
|
235
|
+
size: offer.size,
|
|
236
|
+
staging
|
|
237
|
+
});
|
|
238
|
+
continue;
|
|
239
|
+
}
|
|
229
240
|
const outcome = yield* Effect.result(downloaded(send, offer, staging, copy, context.signal));
|
|
230
241
|
if (Result.isFailure(outcome)) {
|
|
231
242
|
if (landed.length > 0) yield* committed(attempt, copy, version, row, lfs, landed, []);
|
package/dist/sync/mirror.mjs
CHANGED
|
@@ -11,16 +11,16 @@ import { savedCallerOf } from "../core/saved-callers.mjs";
|
|
|
11
11
|
import { hostRecordOf } from "../store/catalogue.mjs";
|
|
12
12
|
import { hiddenUnder } from "../protocol/wire/lines.mjs";
|
|
13
13
|
import { receiveRefs, sendPush } from "../client/remote.mjs";
|
|
14
|
-
import {
|
|
15
|
-
import { decodeRow, storeCall } from "../store/errors.mjs";
|
|
14
|
+
import { oneShotReads } from "../storage/calls.mjs";
|
|
15
|
+
import { decodeRow, storeCall, storeCommit } from "../store/errors.mjs";
|
|
16
16
|
import { MirrorRow, destinationText, mirrorJobKey } from "../core/mirror-rows.mjs";
|
|
17
17
|
import { notFailed } from "../core/events/deliver.mjs";
|
|
18
18
|
import { collections, newChangeId, repoScope } from "../store/scopes.mjs";
|
|
19
19
|
import { asSync, mirrorLimits } from "./bound.mjs";
|
|
20
20
|
import { readImport } from "../core/imports.mjs";
|
|
21
21
|
import { fromRemote, httpOf, keptFieldsOf, openedFor, remoteOf, syncObjects, thrownOf, tried, unknownProvider } from "./tries.mjs";
|
|
22
|
-
import { CoreParts, ObjectsParts, QueueParts
|
|
23
|
-
import * as Clock
|
|
22
|
+
import { CoreParts, ObjectsParts, QueueParts } from "../core/parts.mjs";
|
|
23
|
+
import * as Clock from "effect/Clock";
|
|
24
24
|
import * as Effect from "effect/Effect";
|
|
25
25
|
import * as Result from "effect/Result";
|
|
26
26
|
import { CurrentJob, isInfraError, jsonBytes } from "@ref0/infra";
|
|
@@ -88,10 +88,15 @@ const mirrorWith = /* @__PURE__ */ Effect.fnUntraced(function* (bound, input) {
|
|
|
88
88
|
kind: "repo.update",
|
|
89
89
|
repo: input.repo
|
|
90
90
|
};
|
|
91
|
-
const
|
|
91
|
+
const opened = yield* openRepo(caller, operation, [], input.internalId, "first-read");
|
|
92
|
+
const { internalId, name, record } = opened;
|
|
92
93
|
const ref = headOf(input.ref ?? record.defaultBranch);
|
|
93
94
|
if (!isRefName(ref)) return yield* fail("INVALID_ARGUMENT", `'${ref}' isn't a ref Git takes`);
|
|
94
95
|
if (hiddenUnder((yield* CoreParts).hiddenRefs(), ref) !== void 0) return yield* fail("INVALID_ARGUMENT", `'${ref}' is Git's own, and no mirror pushes it`);
|
|
96
|
+
const { store } = yield* CoreParts;
|
|
97
|
+
const scope = repoScope(internalId);
|
|
98
|
+
const mirrorRead = (asked) => readAsked(store, internalId, [mirrorKey(ref)], [mirrorsCount], asked);
|
|
99
|
+
const first = yield* mirrorRead(opened);
|
|
95
100
|
const refView = yield* refViewIn(caller, repoAccess({
|
|
96
101
|
name,
|
|
97
102
|
record,
|
|
@@ -121,10 +126,8 @@ const mirrorWith = /* @__PURE__ */ Effect.fnUntraced(function* (bound, input) {
|
|
|
121
126
|
key,
|
|
122
127
|
data: { destination: saved.destination }
|
|
123
128
|
});
|
|
124
|
-
const { store } = yield* CoreParts;
|
|
125
|
-
const scope = repoScope(internalId);
|
|
126
129
|
for (let tries = 0; tries < 5; tries += 1) {
|
|
127
|
-
const read =
|
|
130
|
+
const read = tries === 0 ? first : yield* mirrorRead();
|
|
128
131
|
const [[own] = []] = read.results;
|
|
129
132
|
const [count = 0] = read.counts;
|
|
130
133
|
const held = own === void 0 ? void 0 : yield* decodeRow(MirrorRow, own, `Mirror '${ref}'`);
|
|
@@ -134,16 +137,16 @@ const mirrorWith = /* @__PURE__ */ Effect.fnUntraced(function* (bound, input) {
|
|
|
134
137
|
});
|
|
135
138
|
const row = { ...saved };
|
|
136
139
|
if (held?.lastPushed !== void 0 && sameSource(held.destination, saved.destination)) row.lastPushed = held.lastPushed;
|
|
137
|
-
if (!(yield*
|
|
140
|
+
if (!(yield* storeCommit(store.commit(scope, {
|
|
138
141
|
id: newChangeId(),
|
|
139
142
|
expect: read.version,
|
|
140
143
|
put: [mirrorRow(ref, row)],
|
|
141
144
|
jobs: [job]
|
|
142
145
|
}))).ok) continue;
|
|
143
146
|
const { jobs } = yield* QueueParts;
|
|
144
|
-
if ((yield* storeCall(
|
|
145
|
-
yield* storeCall(
|
|
146
|
-
yield* storeCall(
|
|
147
|
+
if ((yield* storeCall(jobs.retry(scope, job)).pipe(Effect.catchIf(notFailed, () => Effect.void), Effect.catchIf((error) => isInfraError(error.cause) && error.cause.reason === "compacted", () => Effect.succeed(false)))) === false) {
|
|
148
|
+
yield* storeCall(jobs.discard(scope, job)).pipe(Effect.catchIf(notFailed, () => Effect.void));
|
|
149
|
+
yield* storeCall(store.add(scope, { jobs: [job] }));
|
|
147
150
|
}
|
|
148
151
|
return stateOf(input.repo, ref, row);
|
|
149
152
|
}
|
|
@@ -154,7 +157,7 @@ const mirrorWith = /* @__PURE__ */ Effect.fnUntraced(function* (bound, input) {
|
|
|
154
157
|
* `mirrorLimits.mirrors` keeps within one read, and the read's version.
|
|
155
158
|
*/
|
|
156
159
|
const destinationRows = /* @__PURE__ */ Effect.fnUntraced(function* (store, internalId, destination) {
|
|
157
|
-
const snapshot = yield* storeCall(
|
|
160
|
+
const snapshot = yield* storeCall(store.read(repoScope(internalId), [mirrorsRead]));
|
|
158
161
|
const [rows = []] = snapshot.results;
|
|
159
162
|
const mirrored = [];
|
|
160
163
|
for (const row of rows) {
|
|
@@ -178,8 +181,8 @@ const destinationRows = /* @__PURE__ */ Effect.fnUntraced(function* (store, inte
|
|
|
178
181
|
* takes none, nor does one that `writeTries` other writes beat: the push stands either way.
|
|
179
182
|
*/
|
|
180
183
|
const settle = /* @__PURE__ */ Effect.fnUntraced(function* (attempt, read, settled) {
|
|
181
|
-
const { store } =
|
|
182
|
-
const at = yield* Clock
|
|
184
|
+
const { store } = yield* CoreParts;
|
|
185
|
+
const at = yield* Clock.currentTimeMillis;
|
|
183
186
|
let { mirrored, version } = read;
|
|
184
187
|
let { pauses } = settled;
|
|
185
188
|
for (let tries = 0; tries < 5; tries += 1) {
|
|
@@ -200,7 +203,7 @@ const settle = /* @__PURE__ */ Effect.fnUntraced(function* (attempt, read, settl
|
|
|
200
203
|
put.push(mirrorRow(ref, next));
|
|
201
204
|
}
|
|
202
205
|
if (put.length === 0) break;
|
|
203
|
-
if ((yield*
|
|
206
|
+
if ((yield* storeCommit(store.commit(repoScope(attempt.internalId), {
|
|
204
207
|
id: newChangeId(),
|
|
205
208
|
expect: version,
|
|
206
209
|
put
|
|
@@ -216,7 +219,7 @@ const goingOn = /* @__PURE__ */ Effect.fnUntraced(function* (listed, edits) {
|
|
|
216
219
|
const going = /* @__PURE__ */ new Set();
|
|
217
220
|
if (edits.length === 0) return going;
|
|
218
221
|
const kinds = yield* kindsOf({
|
|
219
|
-
objects: oneShotReads(
|
|
222
|
+
objects: oneShotReads(syncObjects(yield* ObjectsParts)),
|
|
220
223
|
listed,
|
|
221
224
|
pushed: () => Effect.succeed(void 0),
|
|
222
225
|
edits
|
|
@@ -243,7 +246,7 @@ const upstreamOf = /* @__PURE__ */ Effect.fnUntraced(function* (http, heard) {
|
|
|
243
246
|
* repo deleted since. A host that failed fails the try.
|
|
244
247
|
*/
|
|
245
248
|
const seenOf = /* @__PURE__ */ Effect.fnUntraced(function* (attempt, active, settled) {
|
|
246
|
-
const { internalId,
|
|
249
|
+
const { internalId, signal } = attempt;
|
|
247
250
|
const record = yield* hostRecordOf((yield* CoreParts).store, internalId);
|
|
248
251
|
if (record === void 0) return void 0;
|
|
249
252
|
const repo = repoAccess({
|
|
@@ -255,7 +258,7 @@ const seenOf = /* @__PURE__ */ Effect.fnUntraced(function* (attempt, active, set
|
|
|
255
258
|
const seen = [];
|
|
256
259
|
for (const mirror of active) {
|
|
257
260
|
const saver = saverOf(mirror.row);
|
|
258
|
-
const viewed = views.get(saver) ?? (yield* viewAgainOf(mirror.row.by, repo, "fetch",
|
|
261
|
+
const viewed = views.get(saver) ?? (yield* viewAgainOf(mirror.row.by, repo, "fetch", signal));
|
|
259
262
|
views.set(saver, viewed);
|
|
260
263
|
if (viewed.kind !== "refused" && viewed.view.sees(mirror.ref)) seen.push(mirror);
|
|
261
264
|
else settled.pauses.set(mirror.ref, "unseen");
|
|
@@ -282,14 +285,14 @@ const seenOf = /* @__PURE__ */ Effect.fnUntraced(function* (attempt, active, set
|
|
|
282
285
|
* twice.
|
|
283
286
|
*/
|
|
284
287
|
const mirrorStep = /* @__PURE__ */ Effect.fnUntraced(function* (attempt) {
|
|
285
|
-
const { store } =
|
|
288
|
+
const { store } = yield* CoreParts;
|
|
286
289
|
const read = yield* destinationRows(store, attempt.internalId, attempt.destination);
|
|
287
290
|
const active = read.mirrored.filter(({ row }) => row.state === "active");
|
|
288
291
|
if (active.length === 0) return void 0;
|
|
289
292
|
const imported = yield* readImport(store, attempt.internalId);
|
|
290
293
|
if (imported.row?.state === "running" && !imported.cancelled) return {
|
|
291
294
|
kind: "more",
|
|
292
|
-
at: (yield* Clock
|
|
295
|
+
at: (yield* Clock.currentTimeMillis) + importWait
|
|
293
296
|
};
|
|
294
297
|
const settled = {
|
|
295
298
|
pauses: /* @__PURE__ */ new Map(),
|
|
@@ -303,7 +306,7 @@ const mirrorStep = /* @__PURE__ */ Effect.fnUntraced(function* (attempt) {
|
|
|
303
306
|
});
|
|
304
307
|
/** The try past its savers' checks: the tips, the upstream's, and the one push between them. */
|
|
305
308
|
const pushStep = /* @__PURE__ */ Effect.fnUntraced(function* (attempt, seen, settled) {
|
|
306
|
-
const { bound,
|
|
309
|
+
const { bound, signal } = attempt;
|
|
307
310
|
const stored = yield* ObjectsParts;
|
|
308
311
|
const opened = yield* openedFor(bound.caller, attempt.internalId);
|
|
309
312
|
if (opened === void 0) return;
|
|
@@ -316,7 +319,7 @@ const pushStep = /* @__PURE__ */ Effect.fnUntraced(function* (attempt, seen, set
|
|
|
316
319
|
});
|
|
317
320
|
}
|
|
318
321
|
if (tipped.length === 0) return;
|
|
319
|
-
const remote = yield* remoteOf(bound, attempt.destination,
|
|
322
|
+
const remote = yield* remoteOf(bound, attempt.destination, signal, "write");
|
|
320
323
|
const { http, heard } = yield* httpOf(remote, keptFieldsOf(bound, attempt.destination));
|
|
321
324
|
const upstream = yield* upstreamOf(http, heard);
|
|
322
325
|
if (upstream.kind === "refused") {
|
|
@@ -341,7 +344,7 @@ const pushStep = /* @__PURE__ */ Effect.fnUntraced(function* (attempt, seen, set
|
|
|
341
344
|
else settled.pauses.set(edit.ref, "diverged");
|
|
342
345
|
if (edits.length === 0) return;
|
|
343
346
|
const source = {
|
|
344
|
-
objects:
|
|
347
|
+
objects: syncObjects(stored),
|
|
345
348
|
listed: opened.listed,
|
|
346
349
|
limits: stored.fetchLimits
|
|
347
350
|
};
|
|
@@ -363,14 +366,14 @@ const pushStep = /* @__PURE__ */ Effect.fnUntraced(function* (attempt, seen, set
|
|
|
363
366
|
});
|
|
364
367
|
/** `sync.mirror`'s handler over `bound`: one try, its failure thrown as `SyncTryError`. */
|
|
365
368
|
const mirrorTry = /* @__PURE__ */ Effect.fnUntraced(function* (bound, data) {
|
|
366
|
-
const
|
|
369
|
+
const signal = yield* CurrentJob.signal;
|
|
367
370
|
const attempt = {
|
|
368
371
|
bound,
|
|
369
372
|
internalId: yield* currentRepo,
|
|
370
373
|
destination: data.destination,
|
|
371
|
-
|
|
374
|
+
signal
|
|
372
375
|
};
|
|
373
|
-
return yield* tried(Effect.provideContext(
|
|
376
|
+
return yield* tried(Effect.provideContext(mirrorStep(attempt), bound.needs));
|
|
374
377
|
});
|
|
375
378
|
/**
|
|
376
379
|
* Once a destination's job has failed for good, every active mirror its rows name paused
|
|
@@ -378,18 +381,18 @@ const mirrorTry = /* @__PURE__ */ Effect.fnUntraced(function* (bound, data) {
|
|
|
378
381
|
* commit another write beat, until the queue's bound on `onFailure` aborts the signal.
|
|
379
382
|
*/
|
|
380
383
|
const mirrorFailed = /* @__PURE__ */ Effect.fnUntraced(function* (bound, data) {
|
|
381
|
-
const context = yield* CurrentJob.CurrentJob;
|
|
382
384
|
const internalId = yield* currentRepo;
|
|
383
385
|
const marked = Effect.gen(function* () {
|
|
386
|
+
const { store } = yield* CoreParts;
|
|
384
387
|
for (;;) {
|
|
385
|
-
const read = yield* destinationRows(
|
|
388
|
+
const read = yield* destinationRows(store, internalId, data.destination);
|
|
386
389
|
const put = read.mirrored.flatMap(({ ref, row }) => row.state === "active" ? [mirrorRow(ref, {
|
|
387
390
|
...row,
|
|
388
391
|
state: "paused",
|
|
389
392
|
paused: "refused"
|
|
390
393
|
})] : []);
|
|
391
394
|
if (put.length === 0) return;
|
|
392
|
-
if ((yield*
|
|
395
|
+
if ((yield* storeCommit(store.commit(repoScope(internalId), {
|
|
393
396
|
id: newChangeId(),
|
|
394
397
|
expect: read.version,
|
|
395
398
|
put
|
|
@@ -452,7 +455,7 @@ const removeMirrorWith = /* @__PURE__ */ Effect.fnUntraced(function* (_bound, in
|
|
|
452
455
|
}));
|
|
453
456
|
const [[own] = []] = read.results;
|
|
454
457
|
if (own === void 0 || !refView.sees(ref)) return yield* none;
|
|
455
|
-
if ((yield*
|
|
458
|
+
if ((yield* storeCommit(store.commit(scope, {
|
|
456
459
|
id: newChangeId(),
|
|
457
460
|
expect: read.version,
|
|
458
461
|
delete: [mirrorKey(ref)]
|
package/dist/sync/said.mjs
CHANGED
|
@@ -1,4 +1,7 @@
|
|
|
1
|
+
import { tryUnlessSpent } from "../contracts/calls-spent.mjs";
|
|
2
|
+
import { boundedBytes, dropBody } from "../protocol/bytes/reader.mjs";
|
|
1
3
|
import { cutWords, utf8 } from "../protocol/bytes/text.mjs";
|
|
4
|
+
import * as Effect from "effect/Effect";
|
|
2
5
|
import * as Option from "effect/Option";
|
|
3
6
|
import * as Schema from "effect/Schema";
|
|
4
7
|
import * as Result from "effect/Result";
|
|
@@ -159,46 +162,22 @@ const isJson = (response) => {
|
|
|
159
162
|
return type === "application/json" || /^application\/[\w.-]+\+json$/.test(type);
|
|
160
163
|
};
|
|
161
164
|
/**
|
|
162
|
-
*
|
|
163
|
-
*
|
|
164
|
-
*
|
|
165
|
+
* `body` whole, as text, when it's at most `saidBytesMost` bytes: `undefined` past it, when a read
|
|
166
|
+
* fails, though a spent call bound stays the defect it is, or when another reader holds it, as a
|
|
167
|
+
* host's instrumentation may, which `getReader` would throw on. Its reader is the scope's, so an
|
|
168
|
+
* interrupt cancels a read that waits: a refusal that stalls never holds its try. Cancelled after,
|
|
169
|
+
* either way, but for a held body, its holder's to let go.
|
|
165
170
|
*/
|
|
166
|
-
const bodyStart =
|
|
167
|
-
const reader = body.getReader();
|
|
168
|
-
const stop = () => {
|
|
169
|
-
reader.cancel(signal.reason).catch(() => void 0);
|
|
170
|
-
};
|
|
171
|
-
const decoder = new TextDecoder();
|
|
172
|
-
let text = "";
|
|
173
|
-
let bytes = 0;
|
|
174
|
-
signal.addEventListener("abort", stop, { once: true });
|
|
175
|
-
try {
|
|
176
|
-
while (!signal.aborted) {
|
|
177
|
-
const piece = await reader.read();
|
|
178
|
-
if (piece.done) return signal.aborted ? void 0 : text + decoder.decode();
|
|
179
|
-
bytes += piece.value.byteLength;
|
|
180
|
-
if (bytes > 4096) return void 0;
|
|
181
|
-
text += decoder.decode(piece.value, { stream: true });
|
|
182
|
-
}
|
|
183
|
-
return;
|
|
184
|
-
} finally {
|
|
185
|
-
signal.removeEventListener("abort", stop);
|
|
186
|
-
reader.cancel().catch(() => void 0);
|
|
187
|
-
reader.releaseLock();
|
|
188
|
-
}
|
|
189
|
-
};
|
|
171
|
+
const bodyStart = (body) => body.locked ? Effect.succeed(void 0) : boundedBytes(body, saidBytesMost, (reader) => tryUnlessSpent(() => reader.read(), () => "unread")).pipe(Effect.map((bytes) => bytes === void 0 ? void 0 : new TextDecoder().decode(bytes)), Effect.orElseSucceed(() => void 0));
|
|
190
172
|
/**
|
|
191
173
|
* What the refusal `response` to `request` said in `fields`, as `keptSaid` keeps it: its body read
|
|
192
|
-
* only when it's JSON and some field is marked,
|
|
193
|
-
*
|
|
174
|
+
* only when it's JSON and some field is marked, and always dropped after. An interrupt stops the
|
|
175
|
+
* read and cancels the body, as a try's abort does through its runner. A failed or stopped read
|
|
176
|
+
* keeps nothing.
|
|
194
177
|
*/
|
|
195
|
-
const saidOf =
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
}
|
|
200
|
-
const text = await bodyStart(response.body, request.signal).catch(() => void 0);
|
|
201
|
-
if (text === void 0) return void 0;
|
|
202
|
-
return keptSaid(text, fields, requestSecrets(request));
|
|
178
|
+
const saidOf = (request, response, fields) => {
|
|
179
|
+
const { body } = response;
|
|
180
|
+
if (fields.length === 0 || body === null || !isJson(response)) return Effect.as(dropBody(body), void 0);
|
|
181
|
+
return Effect.map(bodyStart(body), (text) => text === void 0 ? void 0 : keptSaid(text, fields, requestSecrets(request)));
|
|
203
182
|
};
|
|
204
183
|
export { ProviderRefused, keptSaid, requestSecrets, saidBytesMost, saidOf };
|
package/dist/sync/step.mjs
CHANGED
|
@@ -8,14 +8,14 @@ import { isRefName } from "../core/names.mjs";
|
|
|
8
8
|
import { cutWords, utf8 } from "../protocol/bytes/text.mjs";
|
|
9
9
|
import { negotiate } from "../client/negotiate.mjs";
|
|
10
10
|
import { discover, fetchTerms, remoteRefsAndHeadOf } from "../client/remote.mjs";
|
|
11
|
-
import {
|
|
11
|
+
import { oneShotReads, scopedReceiveStep } from "../storage/calls.mjs";
|
|
12
12
|
import { isPackId } from "../storage/layout.mjs";
|
|
13
13
|
import { receiveCutParentsMost } from "../storage/receive-bounds.mjs";
|
|
14
14
|
import { ReceiveRow, receiveKey, stagedRow } from "../storage/receive-steps.mjs";
|
|
15
15
|
import { decodeHeld } from "../storage/rows.mjs";
|
|
16
16
|
import { infiniteDepth } from "../storage/shallow.mjs";
|
|
17
|
-
import { decodeRow, storeCall } from "../store/errors.mjs";
|
|
18
|
-
import {
|
|
17
|
+
import { decodeRow, storeCall, storeCommit } from "../store/errors.mjs";
|
|
18
|
+
import { tryGitStore } from "../store/git-store.mjs";
|
|
19
19
|
import { decodeRecord, hostRecordOf } from "../store/catalogue.mjs";
|
|
20
20
|
import { listJobRow } from "../store/list-job.mjs";
|
|
21
21
|
import { StoredRepo } from "../store/records.mjs";
|
|
@@ -25,7 +25,7 @@ import { copyLfs, withLfsPages } from "./lfs-copy.mjs";
|
|
|
25
25
|
import { ImportRow, cancelKey, cutKey, cutRow, failedHint, failedRow, importEndDeletes, importKey, importRow, readImport, readTipPages, stoppedTry, tipPageKey, tipPageRow, tipPagesOf, tipRowBytes } from "../core/imports.mjs";
|
|
26
26
|
import { ForGood, SyncTryError, forGood, fromRemote, httpOf, keptFieldsOf, openedFor, remoteOf, syncObjects, thrownOf, tried } from "./tries.mjs";
|
|
27
27
|
import { currentRepo } from "../store/job-try.mjs";
|
|
28
|
-
import { CoreParts, ObjectsParts
|
|
28
|
+
import { CoreParts, ObjectsParts } from "../core/parts.mjs";
|
|
29
29
|
import { importOwner } from "../protocol/wire/lines.mjs";
|
|
30
30
|
import { repoAccess } from "../core/access.mjs";
|
|
31
31
|
import { viewAgainOf } from "../core/saved-caller-views.mjs";
|
|
@@ -57,7 +57,7 @@ import { CurrentJob } from "@ref0/infra";
|
|
|
57
57
|
*/
|
|
58
58
|
/** The deepest a segment's step grows: past it, a segment's history is whole anyway. */
|
|
59
59
|
const stepMost = 1 << 20;
|
|
60
|
-
const
|
|
60
|
+
const noDeepen = () => gitError("FAILED_PRECONDITION", "The remote doesn't take a shallow fetch, so no import of it stops at a depth", { hint: "Import it again without a depth" });
|
|
61
61
|
const tooManyTips = (limits, bytes) => gitError("RESOURCE_EXHAUSTED", `The remote's branches and tags take ${bytes} bytes as refs`, {
|
|
62
62
|
hint: `An import takes branches and tags of at most ${limits.tipBytes} bytes together, as a repo's refs count them`,
|
|
63
63
|
context: {
|
|
@@ -195,7 +195,7 @@ const readOwn = (attempt) => Effect.flatMap(Effect.service(CoreParts), ({ store
|
|
|
195
195
|
* The import's record at `row`, committed at `version` with `deletes`: a commit another beat is read
|
|
196
196
|
* next try.
|
|
197
197
|
*/
|
|
198
|
-
const saved = (attempt, version, row, deletes = [], puts = []) => Effect.flatMap(Effect.service(CoreParts), ({ store }) =>
|
|
198
|
+
const saved = (attempt, version, row, deletes = [], puts = []) => Effect.flatMap(Effect.service(CoreParts), ({ store }) => storeCommit(store.commit(repoScope(attempt.internalId), {
|
|
199
199
|
id: newChangeId(),
|
|
200
200
|
expect: version,
|
|
201
201
|
put: [importRow(row), ...puts],
|
|
@@ -373,8 +373,10 @@ const stepAfter = (step, bytes, most) => bytes < most / 4 ? Math.min(step * 2, s
|
|
|
373
373
|
* objects alone with the import's record moved past it in the same commit. Its oldest commits, the
|
|
374
374
|
* remote's `shallow` lines, are its boundary: their parents a later segment brings, so only they
|
|
375
375
|
* may be absent, and every other link is checked as a whole push's is. A remote that takes no
|
|
376
|
-
* deepen sends the whole history in one segment, with no boundary
|
|
377
|
-
*
|
|
376
|
+
* deepen sends the whole history in one segment, with no boundary, and fails an import with a
|
|
377
|
+
* `depth` for good. A segment as deep as `depth`, or one whose roots stay as they were, the remote
|
|
378
|
+
* being a shallow clone itself, is the last: its roots are the repo's, which publish writes. The
|
|
379
|
+
* parents a boundary left out are kept
|
|
378
380
|
* as the import's cut, in the commit that lands the segment, and the segment after which their
|
|
379
381
|
* root is no longer one needs them, in its pack or the repo, whatever its answer claims, so no ref
|
|
380
382
|
* is published on a commit whose parents the repo lacks.
|
|
@@ -387,12 +389,14 @@ const fetchSegment = /* @__PURE__ */ Effect.fnUntraced(function* (attempt, row,
|
|
|
387
389
|
const tips = [...new Set(listed.flatMap((page) => Object.values(page)))];
|
|
388
390
|
const opened = yield* openedRepo(attempt);
|
|
389
391
|
if (opened === void 0) return void 0;
|
|
390
|
-
const objects =
|
|
392
|
+
const objects = syncObjects(yield* ObjectsParts);
|
|
391
393
|
yield* report(context, "fetch", row);
|
|
392
394
|
const { http, heard } = yield* httpOf(remote, keptFieldsOf(bound, row.source));
|
|
393
395
|
const upload = yield* Effect.mapError(discover(http), advertisedFrom(remote, "advertise its refs", heard));
|
|
394
396
|
const shallow = yield* deepens(upload);
|
|
395
|
-
|
|
397
|
+
if (!shallow && row.depth !== void 0) return yield* forGood(noDeepen());
|
|
398
|
+
const asked = row.depth ?? 2147483647;
|
|
399
|
+
const wanted = Math.min(row.deepest + row.step, asked);
|
|
396
400
|
const request = {
|
|
397
401
|
wants: tips,
|
|
398
402
|
shallows: [...row.roots],
|
|
@@ -422,11 +426,7 @@ const fetchSegment = /* @__PURE__ */ Effect.fnUntraced(function* (attempt, row,
|
|
|
422
426
|
limit: bound.limits.rootsMost
|
|
423
427
|
} }));
|
|
424
428
|
}
|
|
425
|
-
|
|
426
|
-
pack.cancel();
|
|
427
|
-
return yield* forGood(shallowRemote());
|
|
428
|
-
}
|
|
429
|
-
const copied = roots.length === 0;
|
|
429
|
+
const copied = roots.length === 0 || wanted >= asked || row.roots.length > 0 && sameRoots(roots, row.roots);
|
|
430
430
|
const pushedPack = {
|
|
431
431
|
bytes: stream,
|
|
432
432
|
objects: pack.objects
|
|
@@ -540,7 +540,7 @@ const staged = /* @__PURE__ */ Effect.fnUntraced(function* (attempt, row, stagin
|
|
|
540
540
|
*/
|
|
541
541
|
const receiveJoining = /* @__PURE__ */ Effect.fnUntraced(function* (attempt, pack) {
|
|
542
542
|
const { store } = yield* CoreParts;
|
|
543
|
-
const held = (yield* storeCall(
|
|
543
|
+
const held = (yield* storeCall(store.read(repoScope(attempt.internalId), [receiveKey(pack)]))).results[0]?.[0];
|
|
544
544
|
if (held === void 0) return false;
|
|
545
545
|
const { value } = yield* decodeHeld(ReceiveRow, held);
|
|
546
546
|
return value.phase === "joining";
|
|
@@ -562,7 +562,7 @@ const resumedIn = /* @__PURE__ */ Effect.fnUntraced(function* (attempt, row, rec
|
|
|
562
562
|
const { pack, lands } = receiving;
|
|
563
563
|
const { needs, kept } = carriedCut(row.roots, lands.roots, cut);
|
|
564
564
|
const input = {
|
|
565
|
-
store:
|
|
565
|
+
store: yield* tryGitStore((yield* CoreParts).store),
|
|
566
566
|
pack,
|
|
567
567
|
objects: lands.objects - row.objects
|
|
568
568
|
};
|
|
@@ -688,7 +688,9 @@ const publishGuard = (read, page) => {
|
|
|
688
688
|
};
|
|
689
689
|
/**
|
|
690
690
|
* Step 3: the next page's refs moved to their tips, in one atomic commit that moves the record's
|
|
691
|
-
* cursor past the page and deletes it. The
|
|
691
|
+
* cursor past the page and deletes it. The first page's writes the import's roots as the repo's,
|
|
692
|
+
* so no ref names a commit whose parents the repo lacks, and no walk from one reads past them. The
|
|
693
|
+
* last page's marks the import done instead, with the
|
|
692
694
|
* remote's default branch made the repo's when it's one of the tips, which the listing put on that
|
|
693
695
|
* page. A ref another write moved first fails the try, and the next moves the page's refs from
|
|
694
696
|
* where they are then; a refusal of another kind fails it with that ref's own error.
|
|
@@ -715,7 +717,7 @@ const publish = /* @__PURE__ */ Effect.fnUntraced(function* (attempt, row) {
|
|
|
715
717
|
to
|
|
716
718
|
}];
|
|
717
719
|
});
|
|
718
|
-
const
|
|
720
|
+
const request = {
|
|
719
721
|
caller: attempt.bound.caller,
|
|
720
722
|
repo: opened.name,
|
|
721
723
|
internalId: attempt.internalId,
|
|
@@ -750,7 +752,13 @@ const publish = /* @__PURE__ */ Effect.fnUntraced(function* (attempt, row) {
|
|
|
750
752
|
};
|
|
751
753
|
},
|
|
752
754
|
guard: publishGuard(adopting?.read, page)
|
|
753
|
-
}
|
|
755
|
+
};
|
|
756
|
+
if (page === 0 && row.roots.length > 0) request.roots = {
|
|
757
|
+
shallow: row.roots,
|
|
758
|
+
unshallow: [],
|
|
759
|
+
sent: []
|
|
760
|
+
};
|
|
761
|
+
const rejected = (yield* push(request)).updates.flatMap((update) => update.kind === "rejected" ? [update] : []);
|
|
754
762
|
const [first] = rejected;
|
|
755
763
|
if (first === void 0) return last ? void 0 : more;
|
|
756
764
|
const now = (yield* openedRepo(attempt))?.refs;
|
|
@@ -765,7 +773,7 @@ const stepIn = /* @__PURE__ */ Effect.fnUntraced(function* (attempt) {
|
|
|
765
773
|
const read = yield* readOwn(attempt);
|
|
766
774
|
const { row } = read;
|
|
767
775
|
if (read.cancelled && (Object.keys(read.cut).length > 0 || row?.receiving !== void 0)) {
|
|
768
|
-
if (!(yield*
|
|
776
|
+
if (!(yield* storeCommit(store.commit(repoScope(attempt.internalId), {
|
|
769
777
|
id: newChangeId(),
|
|
770
778
|
expect: read.version,
|
|
771
779
|
delete: importEndDeletes(row)
|
|
@@ -825,7 +833,7 @@ const importTry = /* @__PURE__ */ Effect.fnUntraced(function* (bound) {
|
|
|
825
833
|
internalId: yield* currentRepo,
|
|
826
834
|
context
|
|
827
835
|
};
|
|
828
|
-
return yield* tried(Effect.provideContext(
|
|
836
|
+
return yield* tried(Effect.provideContext(stepOf(attempt), bound.needs));
|
|
829
837
|
});
|
|
830
838
|
/**
|
|
831
839
|
* The import's record marked failed with the last try's error, once the job is failed: read again
|
|
@@ -834,7 +842,6 @@ const importTry = /* @__PURE__ */ Effect.fnUntraced(function* (bound) {
|
|
|
834
842
|
* the cancel is what failed the last try: only the keys its run kept go.
|
|
835
843
|
*/
|
|
836
844
|
const importFailed = /* @__PURE__ */ Effect.fnUntraced(function* (bound, { error }) {
|
|
837
|
-
const context = yield* CurrentJob.CurrentJob;
|
|
838
845
|
const internalId = yield* currentRepo;
|
|
839
846
|
const passing = error instanceof SyncTryError && !error.permanent;
|
|
840
847
|
const last = error instanceof SyncTryError ? error.kept : stoppedTry;
|
|
@@ -847,11 +854,12 @@ const importFailed = /* @__PURE__ */ Effect.fnUntraced(function* (bound, { error
|
|
|
847
854
|
hint: failedHint
|
|
848
855
|
} : cut;
|
|
849
856
|
const marked = Effect.gen(function* () {
|
|
857
|
+
const { store } = yield* CoreParts;
|
|
850
858
|
for (;;) {
|
|
851
|
-
const read = yield* readImport(
|
|
859
|
+
const read = yield* readImport(store, internalId);
|
|
852
860
|
const { row } = read;
|
|
853
861
|
if (row === void 0 || row.state !== "running") return;
|
|
854
|
-
if ((yield*
|
|
862
|
+
if ((yield* storeCommit(store.commit(repoScope(internalId), {
|
|
855
863
|
id: newChangeId(),
|
|
856
864
|
expect: read.version,
|
|
857
865
|
put: read.cancelled ? [] : [importRow(failedRow(row, kept))],
|