@ref0/git 0.20.0 → 0.26.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/access/private-refs.mjs +1 -1
- package/dist/auth/access-jwt.mjs +3 -3
- package/dist/auth/auth-namespace.d.mts +3 -3
- package/dist/auth/auth-namespace.mjs +3 -2
- package/dist/auth/auth.d.mts +3 -3
- package/dist/auth/auth.mjs +9 -8
- package/dist/auth/authorize.mjs +1 -1
- package/dist/auth/fences.d.mts +1 -1
- package/dist/auth/host-function.mjs +1 -1
- package/dist/auth/host-services.mjs +4 -6
- package/dist/auth/identify.d.mts +1 -1
- package/dist/auth/identify.mjs +6 -0
- package/dist/auth/token-cleanup.mjs +2 -2
- package/dist/auth/token-rows.mjs +6 -1
- package/dist/auth/token-text.mjs +1 -1
- package/dist/auth/tokens-base.d.mts +1 -1
- package/dist/auth/tokens.d.mts +1 -1
- package/dist/auth/tokens.mjs +1 -1
- package/dist/client/client.d.mts +15 -7
- package/dist/client/client.mjs +21 -12
- package/dist/client/git-http.mjs +1 -1
- package/dist/client/local.mjs +60 -24
- package/dist/client/negotiate.mjs +3 -3
- package/dist/client/push-upload.mjs +26 -10
- package/dist/client/remote.mjs +4 -3
- package/dist/client/run-remote-helper.d.mts +2 -2
- package/dist/client/run-remote-helper.mjs +6 -6
- package/dist/client/slice-push.d.mts +1 -1
- package/dist/client/transport.mjs +3 -3
- package/dist/contracts/blobs.d.mts +3 -3
- package/dist/contracts/blobs.mjs +1 -1
- package/dist/contracts/calls-spent.mjs +5 -33
- package/dist/contracts/client.d.mts +15 -14
- package/dist/contracts/commits.d.mts +4 -4
- package/dist/contracts/commits.mjs +1 -1
- package/dist/contracts/engine.d.mts +2 -2
- package/dist/contracts/events.d.mts +1 -1
- package/dist/contracts/events.mjs +1 -1
- package/dist/contracts/files.d.mts +4 -4
- package/dist/contracts/files.mjs +1 -1
- package/dist/contracts/forks.d.mts +4 -4
- package/dist/contracts/forks.mjs +1 -1
- package/dist/contracts/git-hooks.d.mts +1 -1
- package/dist/contracts/git.d.mts +9 -5
- package/dist/contracts/grants.d.mts +1 -1
- package/dist/contracts/merges.d.mts +1 -1
- package/dist/contracts/object-values.d.mts +1 -0
- package/dist/contracts/object-values.mjs +16 -1
- package/dist/contracts/objects.d.mts +30 -18
- package/dist/contracts/opaque.mjs +1 -1
- package/dist/contracts/operations.mjs +1 -1
- package/dist/contracts/queue.d.mts +208 -44
- package/dist/contracts/queue.mjs +5 -5
- package/dist/contracts/refs.d.mts +5 -5
- package/dist/contracts/refs.mjs +1 -1
- package/dist/contracts/remote.d.mts +3 -6
- package/dist/contracts/repos.d.mts +3 -3
- package/dist/contracts/repos.mjs +1 -1
- package/dist/contracts/result.d.mts +10 -7
- package/dist/contracts/result.mjs +8 -3
- package/dist/contracts/rules.d.mts +13 -12
- package/dist/contracts/server.d.mts +8 -10
- package/dist/contracts/services.d.mts +6 -9
- package/dist/contracts/services.mjs +1 -2
- package/dist/contracts/signin.d.mts +1 -1
- package/dist/contracts/store.d.mts +2 -2
- package/dist/contracts/sync.d.mts +63 -6
- package/dist/contracts/sync.mjs +3 -2
- package/dist/contracts/tags.d.mts +3 -3
- package/dist/contracts/tags.mjs +1 -1
- package/dist/contracts/tokens.d.mts +2 -2
- package/dist/contracts/tokens.mjs +1 -1
- package/dist/contracts/topics.d.mts +9 -9
- package/dist/contracts/trees.d.mts +4 -4
- package/dist/contracts/trees.mjs +1 -1
- package/dist/contracts/work.d.mts +4 -4
- package/dist/contracts/work.mjs +2 -2
- package/dist/core/access.d.mts +1 -1
- package/dist/core/ancestry.mjs +30 -34
- package/dist/core/{promise.mjs → call-groups.mjs} +7 -30
- package/dist/core/call-services.mjs +1 -1
- package/dist/core/events/deliver.d.mts +2 -2
- package/dist/core/events/deliver.mjs +3 -3
- package/dist/core/events/retired.mjs +1 -1
- package/dist/core/forks.mjs +5 -5
- package/dist/core/hooks/groups.mjs +2 -2
- package/dist/core/imports.mjs +101 -21
- package/dist/core/index-job.mjs +14 -9
- package/dist/core/index-lost.d.mts +1 -1
- package/dist/core/loose-tally.mjs +38 -15
- package/dist/core/merge-parts.d.mts +17 -4
- package/dist/core/merge-parts.mjs +7 -2
- package/dist/core/mirror-rows.mjs +31 -1
- package/dist/core/objects/blobs.mjs +8 -10
- package/dist/core/objects/files.mjs +20 -17
- package/dist/core/objects/objects-layer.mjs +1 -1
- package/dist/core/objects/peel.mjs +1 -7
- package/dist/core/objects/reading.mjs +19 -18
- package/dist/core/objects/tree-edits.mjs +1 -1
- package/dist/core/objects/trees.mjs +257 -58
- package/dist/core/objects/writing.mjs +3 -9
- package/dist/core/own-writes.mjs +1 -1
- package/dist/core/parts.d.mts +8 -1
- package/dist/core/parts.mjs +8 -4
- package/dist/core/purge.mjs +31 -18
- package/dist/core/push.d.mts +2 -2
- package/dist/core/push.mjs +145 -98
- package/dist/core/receipts.d.mts +2 -2
- package/dist/core/receipts.mjs +9 -2
- package/dist/core/ref-index-job.mjs +4 -4
- package/dist/core/ref-view.mjs +74 -31
- package/dist/core/refs.mjs +3 -3
- package/dist/core/repack.mjs +25 -30
- package/dist/core/repo-info.mjs +1 -1
- package/dist/core/repos.mjs +1 -1
- package/dist/core/rules/changes.mjs +18 -40
- package/dist/core/rules/check.mjs +6 -5
- package/dist/core/rules/commit-changes.mjs +114 -58
- package/dist/core/rules/context.d.mts +3 -3
- package/dist/core/rules/context.mjs +18 -14
- package/dist/core/rules/fetch.mjs +1 -1
- package/dist/core/rules/protect.mjs +30 -17
- package/dist/core/saved-caller-views.d.mts +1 -1
- package/dist/core/saved-caller-views.mjs +3 -3
- package/dist/core/saved-callers.d.mts +1 -1
- package/dist/core/saved-callers.mjs +1 -1
- package/dist/core/seam.d.mts +1 -2
- package/dist/core/view.d.mts +6 -3
- package/dist/core/view.mjs +11 -10
- package/dist/core/work.mjs +2 -2
- package/dist/engine/allotted-xdiff.mjs +3 -16
- package/dist/engine/combined.d.mts +3 -0
- package/dist/engine/combined.mjs +200 -185
- package/dist/engine/content.d.mts +2 -2
- package/dist/engine/content.mjs +1 -1
- package/dist/engine/merge.mjs +7 -9
- package/dist/engine/reads.d.mts +2 -2
- package/dist/engine/reads.mjs +22 -14
- package/dist/engine/xdiff.d.mts +1 -1
- package/dist/engine/xdiff.mjs +1 -1
- package/dist/event-streams/event-streams.d.mts +1 -1
- package/dist/event-streams/event-streams.mjs +1 -1
- package/dist/event-streams/stream.d.mts +2 -2
- package/dist/event-streams/stream.mjs +3 -3
- package/dist/extend.d.mts +2 -6
- package/dist/extend.mjs +1 -5
- package/dist/http/core-parts.mjs +83 -26
- package/dist/http/handler.mjs +54 -9
- package/dist/http/parts.d.mts +1 -0
- package/dist/http/push-upload-job.mjs +138 -24
- package/dist/http/push-uploads.mjs +2 -2
- package/dist/http/receive-pack.mjs +14 -53
- package/dist/http/request-snapshot.mjs +258 -0
- package/dist/http/upload-pack.mjs +23 -18
- package/dist/index.d.mts +29 -21
- package/dist/index.mjs +11 -2
- package/dist/lfs/base.d.mts +1 -1
- package/dist/lfs/copy.d.mts +49 -1
- package/dist/lfs/copy.mjs +135 -22
- package/dist/lfs/layer.d.mts +4 -3
- package/dist/lfs/layer.mjs +4 -5
- package/dist/lfs/locks.mjs +2 -2
- package/dist/lfs/objects.d.mts +1 -1
- package/dist/lfs/objects.mjs +3 -3
- package/dist/lfs/pointers.mjs +1 -1
- package/dist/lfs/rows.d.mts +1 -1
- package/dist/lfs/rows.mjs +11 -4
- package/dist/lfs/upkeep.mjs +40 -9
- package/dist/lfs/uploaded.mjs +1 -1
- package/dist/lfs/wire.mjs +1 -1
- package/dist/merges/merges.mjs +17 -2
- package/dist/protocol/bytes/buffers.d.mts +1 -1
- package/dist/protocol/bytes/buffers.mjs +1 -1
- package/dist/protocol/bytes/deflate.d.mts +1 -1
- package/dist/protocol/bytes/deflate.mjs +1 -1
- package/dist/protocol/bytes/inflate.d.mts +1 -1
- package/dist/protocol/bytes/inflate.mjs +1 -1
- package/dist/protocol/bytes/sha1.d.mts +1 -1
- package/dist/protocol/bytes/sha1.mjs +1 -1
- package/dist/protocol/diff/read.d.mts +2 -1
- package/dist/protocol/diff/read.mjs +102 -8
- package/dist/protocol/packs/graph.mjs +1 -1
- package/dist/protocol/packs/idx.d.mts +1 -1
- package/dist/protocol/packs/idx.mjs +1 -1
- package/dist/protocol/packs/parts.mjs +1 -1
- package/dist/protocol/packs/reader.d.mts +1 -1
- package/dist/protocol/packs/reader.mjs +1 -1
- package/dist/protocol/packs/write-error.d.mts +1 -1
- package/dist/protocol/packs/write-error.mjs +1 -1
- package/dist/protocol/packs/writer.mjs +3 -3
- package/dist/protocol/wire/advertisement.d.mts +1 -1
- package/dist/protocol/wire/advertisement.mjs +3 -2
- package/dist/protocol/wire/fetch.d.mts +1 -1
- package/dist/protocol/wire/fetch.mjs +1 -1
- package/dist/protocol/wire/lines.d.mts +9 -1
- package/dist/protocol/wire/lines.mjs +28 -1
- package/dist/protocol/wire/push-uploads.mjs +10 -7
- package/dist/protocol/wire/receive-pack.d.mts +1 -1
- package/dist/protocol/wire/receive-pack.mjs +1 -1
- package/dist/protocol/wire/report-status.d.mts +1 -1
- package/dist/protocol/wire/report-status.mjs +1 -1
- package/dist/protocol/wire/v2.d.mts +1 -1
- package/dist/protocol/wire/v2.mjs +1 -1
- package/dist/queue/advance.mjs +31 -24
- package/dist/queue/base.d.mts +5 -3
- package/dist/queue/calls.mjs +5 -5
- package/dist/queue/commit.mjs +1 -1
- package/dist/queue/host.d.mts +1 -1
- package/dist/queue/layer.d.mts +0 -1
- package/dist/queue/layer.mjs +9 -5
- package/dist/queue/schedule.mjs +1 -1
- package/dist/queue/search.mjs +1 -1
- package/dist/queue/state.mjs +1 -1
- package/dist/queue/trim.mjs +2 -2
- package/dist/rest/client.d.mts +1 -1
- package/dist/rest/client.mjs +6 -6
- package/dist/rest/errors.mjs +1 -1
- package/dist/rest/handler.mjs +2 -2
- package/dist/rest/handlers.mjs +16 -6
- package/dist/rest/layer.mjs +1 -1
- package/dist/rest/listen.mjs +2 -2
- package/dist/rest/refs.mjs +1 -1
- package/dist/server/edge.mjs +27 -3
- package/dist/server/git-layer.d.mts +1 -2
- package/dist/server/git-layer.mjs +4 -5
- package/dist/server/lifecycle.mjs +1 -1
- package/dist/server/registry.mjs +2 -8
- package/dist/server/server.mjs +62 -43
- package/dist/signin/context.d.mts +1 -1
- package/dist/signin/context.mjs +1 -1
- package/dist/signin/forms.mjs +1 -1
- package/dist/signin/grants.d.mts +2 -2
- package/dist/signin/grants.mjs +1 -1
- package/dist/signin/wire.mjs +1 -1
- package/dist/storage/allotted.mjs +4 -9
- package/dist/storage/batch-upkeep.mjs +31 -12
- package/dist/storage/batches.d.mts +2 -3
- package/dist/storage/batches.mjs +52 -49
- package/dist/storage/budget.mjs +23 -1
- package/dist/storage/calls.d.mts +1 -1
- package/dist/storage/calls.mjs +41 -43
- package/dist/storage/charged-cache.mjs +180 -0
- package/dist/storage/chunks.d.mts +3 -3
- package/dist/storage/chunks.mjs +121 -8
- package/dist/storage/counted-bucket.mjs +32 -10
- package/dist/storage/fetch-row-cache.d.mts +6 -0
- package/dist/storage/fetch-row-cache.mjs +211 -0
- package/dist/storage/fetch.d.mts +1 -0
- package/dist/storage/fetch.mjs +54 -242
- package/dist/storage/held-types.d.mts +0 -1
- package/dist/storage/held-types.mjs +13 -4
- package/dist/storage/host-bucket.mjs +9 -4
- package/dist/storage/index-bitmaps.mjs +340 -65
- package/dist/storage/index-build.d.mts +2 -3
- package/dist/storage/index-build.mjs +274 -56
- package/dist/storage/index-fetch.d.mts +3 -1
- package/dist/storage/index-fetch.mjs +60 -21
- package/dist/storage/index-graph.mjs +1 -1
- package/dist/storage/index-layers.mjs +55 -25
- package/dist/storage/index-reach.mjs +15 -22
- package/dist/storage/index-whole.d.mts +7 -0
- package/dist/storage/index-whole.mjs +145 -37
- package/dist/storage/largest-files.mjs +1 -7
- package/dist/storage/layout.mjs +17 -1
- package/dist/storage/lfs-pointers.mjs +1 -6
- package/dist/storage/link-join.mjs +55 -16
- package/dist/storage/list-source.d.mts +7 -0
- package/dist/storage/list-source.mjs +288 -0
- package/dist/storage/loose.d.mts +8 -8
- package/dist/storage/loose.mjs +157 -91
- package/dist/storage/memory-budget.mjs +226 -22
- package/dist/storage/merge-cut.mjs +9 -6
- package/dist/storage/merge-fence.mjs +1 -1
- package/dist/storage/merge-row.mjs +1 -1
- package/dist/storage/merge.d.mts +2 -3
- package/dist/storage/merge.mjs +2 -2
- package/dist/storage/object-rows.d.mts +3 -3
- package/dist/storage/object-rows.mjs +179 -38
- package/dist/storage/pack-order.mjs +97 -44
- package/dist/storage/pack-ranges.mjs +44 -16
- package/dist/storage/pack-reads.d.mts +5 -3
- package/dist/storage/pack-reads.mjs +236 -72
- package/dist/storage/pack-receive.d.mts +1 -2
- package/dist/storage/pack-receive.mjs +24 -18
- package/dist/storage/packs.d.mts +1 -1
- package/dist/storage/packs.mjs +477 -116
- package/dist/storage/placed-reads.mjs +33 -16
- package/dist/storage/prune-seen.mjs +1 -1
- package/dist/storage/prune-walk.mjs +1 -1
- package/dist/storage/prune.mjs +4 -31
- package/dist/storage/push-allotment.mjs +26 -14
- package/dist/storage/push-uploads.mjs +195 -57
- package/dist/storage/pushed-commits.mjs +20 -1
- package/dist/storage/quarantine.d.mts +2 -3
- package/dist/storage/range-cache.mjs +175 -40
- package/dist/storage/raw-ids.mjs +39 -10
- package/dist/storage/ready.d.mts +2 -3
- package/dist/storage/ready.mjs +114 -38
- package/dist/storage/receive-bounds.mjs +31 -9
- package/dist/storage/receive-cache.d.mts +7 -0
- package/dist/storage/receive-cache.mjs +147 -0
- package/dist/storage/receive-files.mjs +1 -1
- package/dist/storage/receive-links.mjs +1 -1
- package/dist/storage/receive-state.d.mts +2 -2
- package/dist/storage/receive-state.mjs +6 -8
- package/dist/storage/receive-steps.d.mts +20 -0
- package/dist/storage/receive-steps.mjs +298 -13
- package/dist/storage/repack-backlog.mjs +1 -6
- package/dist/storage/repack-contained.mjs +2 -2
- package/dist/storage/repack-job.mjs +1 -1
- package/dist/storage/repack.d.mts +2 -3
- package/dist/storage/repack.mjs +54 -9
- package/dist/storage/request-cache.mjs +57 -0
- package/dist/storage/roots.mjs +1 -24
- package/dist/storage/rows.d.mts +2 -2
- package/dist/storage/rows.mjs +1 -1
- package/dist/storage/runs.d.mts +2 -2
- package/dist/storage/runs.mjs +1 -1
- package/dist/storage/send-list.mjs +62 -25
- package/dist/storage/stream-whole.mjs +84 -63
- package/dist/storage/swap-walk.mjs +1 -1
- package/dist/storage/unpack.mjs +878 -450
- package/dist/storage/visible.mjs +110 -32
- package/dist/storage/walk.mjs +1 -0
- package/dist/storage/wants.mjs +22 -58
- package/dist/store/call-count.d.mts +2 -2
- package/dist/store/call-count.mjs +24 -11
- package/dist/store/catalogue.d.mts +1 -1
- package/dist/store/catalogue.mjs +19 -7
- package/dist/store/crossing.mjs +1 -7
- package/dist/store/cursor-seal.d.mts +1 -1
- package/dist/store/cursor-seal.mjs +1 -1
- package/dist/store/door.mjs +9 -4
- package/dist/store/errors.d.mts +2 -2
- package/dist/store/errors.mjs +107 -19
- package/dist/store/git-store.mjs +7 -2
- package/dist/store/job-try.mjs +90 -9
- package/dist/store/list-job.mjs +10 -34
- package/dist/store/outbox.d.mts +2 -2
- package/dist/store/outbox.mjs +2 -2
- package/dist/store/queue-jobs.mjs +6 -12
- package/dist/store/records.d.mts +2 -2
- package/dist/store/records.mjs +2 -2
- package/dist/store/ref-rows.d.mts +2 -2
- package/dist/store/ref-rows.mjs +2 -2
- package/dist/store/repo-record.d.mts +2 -2
- package/dist/store/repo-record.mjs +3 -3
- package/dist/store/request-snapshot.mjs +5 -0
- package/dist/store/reservations.mjs +2 -2
- package/dist/store/topic-jobs.mjs +5 -11
- package/dist/sync/bound.d.mts +3 -3
- package/dist/sync/bound.mjs +10 -7
- package/dist/sync/github.mjs +65 -67
- package/dist/sync/http.mjs +1 -1
- package/dist/sync/import.mjs +201 -66
- package/dist/sync/layer.d.mts +1 -1
- package/dist/sync/layer.mjs +6 -6
- package/dist/sync/lfs-batch.mjs +1 -1
- package/dist/sync/lfs-copy.mjs +175 -15
- package/dist/sync/mirror.mjs +5 -10
- package/dist/sync/said.mjs +1 -1
- package/dist/sync/step.mjs +268 -86
- package/dist/sync/tries.mjs +25 -6
- package/dist/sync.d.mts +2 -2
- package/dist/sync.mjs +2 -2
- package/dist/topics/advance.mjs +3 -3
- package/dist/topics/calls.mjs +1 -1
- package/dist/topics/layer.d.mts +15 -14
- package/dist/topics/members.mjs +1 -1
- package/dist/topics/topic.mjs +1 -1
- package/package.json +3 -13
- package/dist/auth/helpers.mjs +0 -17
- package/dist/auth.d.mts +0 -5
- package/dist/auth.mjs +0 -5
- package/dist/core/rules/commit-changes.d.mts +0 -12
- package/dist/effect.d.mts +0 -9
- package/dist/effect.mjs +0 -7
- package/dist/server/joined.d.mts +0 -70
- package/dist/server/joined.mjs +0 -41
package/dist/sync/layer.mjs
CHANGED
|
@@ -3,22 +3,21 @@ import { fail } from "../contracts/result.mjs";
|
|
|
3
3
|
import { ImportJobData, MirrorJobData, Sync } from "../contracts/sync.mjs";
|
|
4
4
|
import { SyncBase } from "../core/parts.mjs";
|
|
5
5
|
import { LfsBase } from "../lfs/base.mjs";
|
|
6
|
-
import { withAudienceMemo } from "../core/ref-view.mjs";
|
|
7
6
|
import { CallBudget } from "../store/call-count.mjs";
|
|
8
7
|
import { importJobName, mirrorJobName } from "../store/records.mjs";
|
|
9
8
|
import { importTryTimeout } from "../storage/receive-bounds.mjs";
|
|
10
9
|
import { SyncState, importLimits } from "./bound.mjs";
|
|
11
|
-
import { cancelWith, importWith } from "./import.mjs";
|
|
10
|
+
import { cancelWith, deepenWith, importWith } from "./import.mjs";
|
|
12
11
|
import { mirrorFailed, mirrorTry, mirrorWith, mirrorsWith, removeMirrorWith } from "./mirror.mjs";
|
|
13
12
|
import { publishWith } from "./publish.mjs";
|
|
14
13
|
import { importFailed, importTry } from "./step.mjs";
|
|
15
14
|
import { syncRetry } from "./tries.mjs";
|
|
16
|
-
import * as Effect from "effect/Effect";
|
|
17
|
-
import * as HttpClient from "effect/http/HttpClient";
|
|
18
|
-
import * as Option from "effect/Option";
|
|
19
15
|
import { Job } from "@ref0/infra";
|
|
16
|
+
import * as Effect from "effect/Effect";
|
|
20
17
|
import * as Context from "effect/Context";
|
|
21
18
|
import * as Layer from "effect/Layer";
|
|
19
|
+
import * as Option from "effect/Option";
|
|
20
|
+
import * as HttpClient from "effect/http/HttpClient";
|
|
22
21
|
// src/sync/layer.ts
|
|
23
22
|
const Import = /* @__PURE__ */ Job.make(importJobName, {
|
|
24
23
|
payload: ImportJobData,
|
|
@@ -55,9 +54,10 @@ const layerWith = (options, limits) => Layer.effectContext(Effect.gen(function*
|
|
|
55
54
|
};
|
|
56
55
|
yield* registration.addJob(Import, () => importTry(bound), { onFailure: (_data, failure) => importFailed(bound, failure) });
|
|
57
56
|
yield* registration.addJob(Mirror, (data) => mirrorTry(bound, data), { onFailure: (data) => mirrorFailed(bound, data) });
|
|
58
|
-
const run = (effect) => base.through(
|
|
57
|
+
const run = (effect) => base.through(Effect.provide(effect, bound.needs));
|
|
59
58
|
return Context.make(SyncState, bound).pipe(Context.add(Sync, {
|
|
60
59
|
import: (input) => run(importWith(bound, input)),
|
|
60
|
+
deepen: (input) => run(deepenWith(bound, input)),
|
|
61
61
|
cancelImport: (input) => run(cancelWith(bound, input)),
|
|
62
62
|
mirror: (input) => run(mirrorWith(bound, input)),
|
|
63
63
|
mirrors: (input) => run(mirrorsWith(bound, input)),
|
package/dist/sync/lfs-batch.mjs
CHANGED
|
@@ -5,8 +5,8 @@ import { BatchRequest, LfsObjectAnswer } from "../lfs/wire.mjs";
|
|
|
5
5
|
import { boundedBytes, dropBody } from "../protocol/bytes/reader.mjs";
|
|
6
6
|
import { decodeJson } from "../protocol/wire/json.mjs";
|
|
7
7
|
import { readBody } from "../store/errors.mjs";
|
|
8
|
-
import * as Effect from "effect/Effect";
|
|
9
8
|
import * as Schema from "effect/Schema";
|
|
9
|
+
import * as Effect from "effect/Effect";
|
|
10
10
|
import * as Result from "effect/Result";
|
|
11
11
|
/**
|
|
12
12
|
* The most bytes a batch's answer is read to: one of `lfsBatchMost` objects, each a link and the
|
package/dist/sync/lfs-copy.mjs
CHANGED
|
@@ -1,17 +1,16 @@
|
|
|
1
1
|
import { gitError } from "../contracts/result.mjs";
|
|
2
2
|
import { importLfsPagesMost, importRow, lfsMissedHeld, lfsPageKey, lfsPageRow, missedCounted, noImportLfs, readLfsPage } from "../core/imports.mjs";
|
|
3
3
|
import { CoreParts } from "../core/parts.mjs";
|
|
4
|
-
import { largestObject } from "../lfs/rows.mjs";
|
|
4
|
+
import { largestObject, lfsCollections } from "../lfs/rows.mjs";
|
|
5
5
|
import { lfsOidAt, lfsSizeAt, pointersOfRecord, pointersRecords } from "../storage/lfs-pointers.mjs";
|
|
6
|
-
import { storeCommit } from "../store/errors.mjs";
|
|
6
|
+
import { bestEffort, storeCommit } from "../store/errors.mjs";
|
|
7
7
|
import { newChangeId, repoScope } from "../store/scopes.mjs";
|
|
8
|
-
import { lfsCopyBytes } from "./bound.mjs";
|
|
9
8
|
import { letGo, lfsDownloads } from "./lfs-batch.mjs";
|
|
10
9
|
import { bodyUntil } from "./http.mjs";
|
|
11
|
-
import { remoteOf, senderOf } from "./tries.mjs";
|
|
10
|
+
import { forGood, remoteOf, senderOf } from "./tries.mjs";
|
|
12
11
|
import * as Effect from "effect/Effect";
|
|
13
|
-
import * as Result from "effect/Result";
|
|
14
12
|
import * as Stream from "effect/Stream";
|
|
13
|
+
import * as Result from "effect/Result";
|
|
15
14
|
// src/sync/lfs-copy.ts
|
|
16
15
|
/**
|
|
17
16
|
* `row` with the pointers a segment's receive `found` kept as pages beside it, `put` in the commit
|
|
@@ -43,11 +42,11 @@ const withLfsPages = (row, found, copying) => {
|
|
|
43
42
|
};
|
|
44
43
|
/**
|
|
45
44
|
* What one step asks for: the distinct objects of `pointers` from entry `from`, up to
|
|
46
|
-
* `lfsBatchMost` of them, or until the next would take the step past `
|
|
47
|
-
* past it alone; and `end`, the entry after the last taken. An object
|
|
48
|
-
* never downloaded, so it takes none of the bytes.
|
|
45
|
+
* `lfsBatchMost` of them, or until the next would take the step past `most` bytes, the import's
|
|
46
|
+
* `lfsCopyBytes`, an object past it alone; and `end`, the entry after the last taken. An object
|
|
47
|
+
* past `largestObject` is never downloaded, so it takes none of the bytes.
|
|
49
48
|
*/
|
|
50
|
-
const takenFrom = (pointers, from) => {
|
|
49
|
+
const takenFrom = (pointers, from, most) => {
|
|
51
50
|
const wanted = [];
|
|
52
51
|
const seen = /* @__PURE__ */ new Set();
|
|
53
52
|
let bytes = 0;
|
|
@@ -58,7 +57,7 @@ const takenFrom = (pointers, from) => {
|
|
|
58
57
|
const size = lfsSizeAt(pointers, end);
|
|
59
58
|
const taking = size > largestObject ? 0 : size;
|
|
60
59
|
if (wanted.length === 100) break;
|
|
61
|
-
if (wanted.length > 0 && bytes + taking >
|
|
60
|
+
if (wanted.length > 0 && bytes + taking > most) break;
|
|
62
61
|
seen.add(oid);
|
|
63
62
|
wanted.push({
|
|
64
63
|
oid,
|
|
@@ -119,8 +118,9 @@ const downloaded = /* @__PURE__ */ Effect.fnUntraced(function* (send, offer, sta
|
|
|
119
118
|
/**
|
|
120
119
|
* The copy's commit at `version`: each object in `landed` listed and its staging row dropped,
|
|
121
120
|
* each in `missed` the record doesn't name yet counted, and named, as `missedCounted` says, and
|
|
122
|
-
* the cursor moved to `cursor`, the page's row deleted once it's past
|
|
123
|
-
* landed objects alone, as a step that failed partway keeps
|
|
121
|
+
* the cursor moved to `cursor`, the page's row deleted once it's past, and any object in parts
|
|
122
|
+
* dropped from it. Without a cursor, the landed objects alone, as a step that failed partway keeps
|
|
123
|
+
* them, so its next try skips them.
|
|
124
124
|
*/
|
|
125
125
|
const committed = /* @__PURE__ */ Effect.fnUntraced(function* (attempt, copy, version, row, lfs, landed, missed, cursor) {
|
|
126
126
|
const { store } = yield* CoreParts;
|
|
@@ -135,8 +135,11 @@ const committed = /* @__PURE__ */ Effect.fnUntraced(function* (attempt, copy, ve
|
|
|
135
135
|
page: lfs.page,
|
|
136
136
|
entry: cursor.end
|
|
137
137
|
};
|
|
138
|
+
const { copying, ...rest } = lfs;
|
|
139
|
+
const kept = cursor === void 0 && copying !== void 0 ? { copying } : {};
|
|
138
140
|
const next = {
|
|
139
|
-
...
|
|
141
|
+
...rest,
|
|
142
|
+
...kept,
|
|
140
143
|
...moved,
|
|
141
144
|
copied: lfs.copied + landed.length,
|
|
142
145
|
bytes: lfs.bytes + landed.reduce((sum, { size }) => sum + size, 0),
|
|
@@ -156,8 +159,156 @@ const committed = /* @__PURE__ */ Effect.fnUntraced(function* (attempt, copy, ve
|
|
|
156
159
|
],
|
|
157
160
|
delete: [...writes.delete, ...passed ? [lfsPageKey(lfs.page)] : []]
|
|
158
161
|
}))).ok) return yield* Effect.fail(copyRaced());
|
|
162
|
+
const left = copying !== void 0 && !landed.some(({ staging }) => staging.key === copying.key);
|
|
163
|
+
if (cursor !== void 0 && left) yield* leftUpload(copy, copying);
|
|
159
164
|
return next;
|
|
160
165
|
});
|
|
166
|
+
/** The stage an object in parts goes to, as the cursor names it. */
|
|
167
|
+
const stagingOf = (copying) => ({
|
|
168
|
+
key: copying.key,
|
|
169
|
+
row: {
|
|
170
|
+
collection: lfsCollections.staging,
|
|
171
|
+
id: copying.staged
|
|
172
|
+
}
|
|
173
|
+
});
|
|
174
|
+
/**
|
|
175
|
+
* An upload in parts the import leaves, aborted, best effort: its staging row has upkeep abort it
|
|
176
|
+
* at its `removeAt` in any case.
|
|
177
|
+
*/
|
|
178
|
+
const leftUpload = (copy, copying) => bestEffort(copy.abort(stagingOf(copying), copying.token));
|
|
179
|
+
/** A resume the source answered with other bytes than those from the copy's offset. */
|
|
180
|
+
const cannotResume = (offer, offset, status) => gitError("FAILED_PRECONDITION", `The LFS source at ${new URL(offer.href).host} can't resume object ${offer.oid}: asked for its bytes from ${offset}, it answered ${status} with others`, { hint: "Import from a source whose LFS downloads answer a Range request with 206" });
|
|
181
|
+
/** A 206's `Content-Range` of bytes, as RFC 9110 writes it: `bytes <first>-<last>/<length or *>`. */
|
|
182
|
+
const byteRange = /^bytes (\d+)-(\d+)\/(?:\d+|\*)$/;
|
|
183
|
+
/**
|
|
184
|
+
* Whether an answer of `status` with `contentRange` holds the bytes from `offset`: a 200, the whole
|
|
185
|
+
* object, only from 0, and a 206 only when its `Content-Range` starts at `offset`. Any other 206,
|
|
186
|
+
* one with no range, another unit or another start, holds bytes the copy can't place.
|
|
187
|
+
*/
|
|
188
|
+
const resumesAt = (status, contentRange, offset) => {
|
|
189
|
+
if (status === 200) return offset === 0;
|
|
190
|
+
const range = byteRange.exec(contentRange ?? "");
|
|
191
|
+
return status === 206 && range !== null && Number(range[1]) === offset;
|
|
192
|
+
};
|
|
193
|
+
/** An object's upload in parts begun, at its offset 0. */
|
|
194
|
+
const begun = (copy, repo, oid, size) => Effect.map(copy.upload(repo, oid), ({ staging, token, sha256 }) => ({
|
|
195
|
+
oid,
|
|
196
|
+
size,
|
|
197
|
+
key: staging.key,
|
|
198
|
+
staged: staging.row.id,
|
|
199
|
+
token,
|
|
200
|
+
offset: 0,
|
|
201
|
+
parts: [],
|
|
202
|
+
sha256
|
|
203
|
+
}));
|
|
204
|
+
/** The import's record at version `at` with `copying` saved as the copy's progress: its new version. */
|
|
205
|
+
const savedCopying = /* @__PURE__ */ Effect.fnUntraced(function* (attempt, at, row, lfs, copying) {
|
|
206
|
+
const { store } = yield* CoreParts;
|
|
207
|
+
const { copying: _, ...rest } = lfs;
|
|
208
|
+
const next = copying === void 0 ? rest : {
|
|
209
|
+
...rest,
|
|
210
|
+
copying
|
|
211
|
+
};
|
|
212
|
+
const done = yield* storeCommit(store.commit(repoScope(attempt.internalId), {
|
|
213
|
+
id: newChangeId(),
|
|
214
|
+
expect: at,
|
|
215
|
+
put: [importRow({
|
|
216
|
+
...row,
|
|
217
|
+
lfs: next
|
|
218
|
+
})]
|
|
219
|
+
}));
|
|
220
|
+
return done.ok ? done.version : yield* Effect.fail(copyRaced());
|
|
221
|
+
});
|
|
222
|
+
/**
|
|
223
|
+
* One step of an object past a step's bytes, copied in parts across tries (#2989): a multipart
|
|
224
|
+
* upload begun at a key of its own, then parts of the bucket's size read from the download, each
|
|
225
|
+
* hashed with SHA-256 as it goes on from the cursor, put, and saved in the record with the hash's
|
|
226
|
+
* state, at most a step's `lfsCopyBytes` of them. A resume asks for the bytes from the cursor's
|
|
227
|
+
* offset, and a source that answers with others fails the import, as no fallback can go on. Once
|
|
228
|
+
* every byte is in, the digest is held to the oid: other bytes are refused, and the upload
|
|
229
|
+
* aborted; the oid's own complete the upload at the start of the next step, its calls its own, and
|
|
230
|
+
* the object lands as any other. An upload the bucket no longer holds, as upkeep's abort at its
|
|
231
|
+
* `removeAt` leaves, is dropped from the cursor, so the next try starts the object again.
|
|
232
|
+
*/
|
|
233
|
+
const inParts = /* @__PURE__ */ Effect.fnUntraced(function* (attempt, copy, read, send, offer, missed, cursor) {
|
|
234
|
+
const { internalId, context, bound } = attempt;
|
|
235
|
+
const { row, lfs } = read;
|
|
236
|
+
let { version } = read;
|
|
237
|
+
const earlier = lfs.copying;
|
|
238
|
+
if (earlier !== void 0 && earlier.oid !== offer.oid) yield* leftUpload(copy, earlier);
|
|
239
|
+
let copying = earlier?.oid === offer.oid && (yield* copy.resumable(internalId, stagingOf(earlier), version)) ? earlier : yield* begun(copy, internalId, offer.oid, offer.size);
|
|
240
|
+
const staging = stagingOf(copying);
|
|
241
|
+
const ended = (landed, more) => committed(attempt, copy, version, row, {
|
|
242
|
+
...lfs,
|
|
243
|
+
copying
|
|
244
|
+
}, landed, [...missed, ...more], cursor);
|
|
245
|
+
const gone = (error) => error.code === "NOT_FOUND" ? Effect.andThen(savedCopying(attempt, version, row, lfs, void 0), Effect.fail(error)) : Effect.fail(error);
|
|
246
|
+
if (copying.offset === copying.size) {
|
|
247
|
+
yield* Effect.catch(copy.complete(staging, copying.token, copying.parts, copying.size), gone);
|
|
248
|
+
return yield* ended([{
|
|
249
|
+
oid: offer.oid,
|
|
250
|
+
size: offer.size,
|
|
251
|
+
staging
|
|
252
|
+
}], []);
|
|
253
|
+
}
|
|
254
|
+
const headers = new Headers(offer.header);
|
|
255
|
+
if (copying.offset > 0) headers.set("range", `bytes=${copying.offset}-`);
|
|
256
|
+
const request = new Request(offer.href, {
|
|
257
|
+
headers,
|
|
258
|
+
signal: context.signal
|
|
259
|
+
});
|
|
260
|
+
const response = yield* Effect.mapError(send(request), () => downloadUnanswered);
|
|
261
|
+
const { body } = response;
|
|
262
|
+
const absent = response.status === 404 || response.status === 410;
|
|
263
|
+
if (absent || response.status === 416) {
|
|
264
|
+
yield* letGo(response);
|
|
265
|
+
const reason = absent ? "not-found" : "other-bytes";
|
|
266
|
+
return yield* ended([], [{
|
|
267
|
+
oid: offer.oid,
|
|
268
|
+
size: offer.size,
|
|
269
|
+
reason
|
|
270
|
+
}]);
|
|
271
|
+
}
|
|
272
|
+
const answered = response.status === 200 || response.status === 206;
|
|
273
|
+
const range = response.headers.get("content-range");
|
|
274
|
+
if (answered && !resumesAt(response.status, range, copying.offset)) {
|
|
275
|
+
yield* letGo(response);
|
|
276
|
+
return yield* forGood(cannotResume(offer, copying.offset, response.status));
|
|
277
|
+
}
|
|
278
|
+
if (!answered || body === null) {
|
|
279
|
+
yield* letGo(response);
|
|
280
|
+
return yield* Effect.fail(downloadRefused(response.status));
|
|
281
|
+
}
|
|
282
|
+
const body$ = Stream.fromReadableStream({
|
|
283
|
+
evaluate: () => bodyUntil(body, context.signal),
|
|
284
|
+
onError: () => downloadUnanswered
|
|
285
|
+
});
|
|
286
|
+
const core = yield* CoreParts;
|
|
287
|
+
const saved = (progress) => savedCopying(attempt, version, row, lfs, {
|
|
288
|
+
...copying,
|
|
289
|
+
...progress
|
|
290
|
+
}).pipe(Effect.map((at) => {
|
|
291
|
+
version = at;
|
|
292
|
+
copying = {
|
|
293
|
+
...copying,
|
|
294
|
+
...progress
|
|
295
|
+
};
|
|
296
|
+
}), Effect.provideService(CoreParts, core));
|
|
297
|
+
if ((yield* Effect.catch(copy.putParts({
|
|
298
|
+
staging,
|
|
299
|
+
token: copying.token,
|
|
300
|
+
object: offer,
|
|
301
|
+
progress: copying,
|
|
302
|
+
body: body$,
|
|
303
|
+
bytes: bound.limits.lfsCopyBytes,
|
|
304
|
+
saved
|
|
305
|
+
}), gone)) !== "other") return lfs;
|
|
306
|
+
return yield* ended([], [{
|
|
307
|
+
oid: offer.oid,
|
|
308
|
+
size: offer.size,
|
|
309
|
+
reason: "other-bytes"
|
|
310
|
+
}]);
|
|
311
|
+
});
|
|
161
312
|
/**
|
|
162
313
|
* Each distinct object of `pointers` from `from` but those `listed`, missing as a source with no
|
|
163
314
|
* LFS API leaves it: `too-large` for one LFS keeps none of anyway.
|
|
@@ -193,7 +344,7 @@ const copyLfs = /* @__PURE__ */ Effect.fnUntraced(function* (attempt, version, r
|
|
|
193
344
|
const pointers = pointersOfRecord(yield* readLfsPage(store, internalId, lfs.page));
|
|
194
345
|
if (pointers === void 0) return yield* Effect.fail(pageUnreadable(lfs.page));
|
|
195
346
|
yield* reported(context, lfs);
|
|
196
|
-
const { wanted, end } = takenFrom(pointers, lfs.entry);
|
|
347
|
+
const { wanted, end } = takenFrom(pointers, lfs.entry, bound.limits.lfsCopyBytes);
|
|
197
348
|
const listed = yield* copy.listed(internalId, wanted.map(({ oid }) => oid));
|
|
198
349
|
const unlisted = wanted.filter(({ oid }) => !listed.has(oid));
|
|
199
350
|
const tooLarge = unlisted.flatMap(({ oid, size }) => size > largestObject ? [{
|
|
@@ -224,6 +375,15 @@ const copyLfs = /* @__PURE__ */ Effect.fnUntraced(function* (attempt, version, r
|
|
|
224
375
|
size: offer.size,
|
|
225
376
|
reason: offer.reason
|
|
226
377
|
});
|
|
378
|
+
const [only] = downloads;
|
|
379
|
+
if (downloads.length === 1 && only !== void 0 && (lfs.copying !== void 0 || only.size > bound.limits.lfsCopyBytes)) return yield* inParts(attempt, copy, {
|
|
380
|
+
version,
|
|
381
|
+
row,
|
|
382
|
+
lfs
|
|
383
|
+
}, send, only, missed, {
|
|
384
|
+
end,
|
|
385
|
+
count: pointers.count
|
|
386
|
+
});
|
|
227
387
|
const staged = yield* copy.stage(internalId, downloads);
|
|
228
388
|
const landed = [];
|
|
229
389
|
for (const [index, offer] of downloads.entries()) {
|
|
@@ -259,4 +419,4 @@ const copyLfs = /* @__PURE__ */ Effect.fnUntraced(function* (attempt, version, r
|
|
|
259
419
|
count: pointers.count
|
|
260
420
|
});
|
|
261
421
|
});
|
|
262
|
-
export { copyLfs, takenFrom, withLfsPages };
|
|
422
|
+
export { copyLfs, leftUpload, resumesAt, takenFrom, withLfsPages };
|
package/dist/sync/mirror.mjs
CHANGED
|
@@ -14,16 +14,15 @@ import { receiveRefs, sendPush } from "../client/remote.mjs";
|
|
|
14
14
|
import { oneShotReads } from "../storage/calls.mjs";
|
|
15
15
|
import { decodeRow, storeCall, storeCommit } from "../store/errors.mjs";
|
|
16
16
|
import { MirrorRow, destinationText, mirrorJobKey } from "../core/mirror-rows.mjs";
|
|
17
|
-
import { notFailed } from "../core/events/deliver.mjs";
|
|
18
17
|
import { collections, newChangeId, repoScope } from "../store/scopes.mjs";
|
|
19
18
|
import { asSync, mirrorLimits } from "./bound.mjs";
|
|
20
19
|
import { readImport } from "../core/imports.mjs";
|
|
21
|
-
import { fromRemote, httpOf, keptFieldsOf, openedFor, remoteOf, syncObjects, thrownOf, tried, unknownProvider } from "./tries.mjs";
|
|
22
|
-
import { CoreParts, ObjectsParts
|
|
23
|
-
import
|
|
20
|
+
import { fromRemote, httpOf, keptFieldsOf, openedFor, remoteOf, reviveFailedJob, syncObjects, thrownOf, tried, unknownProvider } from "./tries.mjs";
|
|
21
|
+
import { CoreParts, ObjectsParts } from "../core/parts.mjs";
|
|
22
|
+
import { CurrentJob, jsonBytes } from "@ref0/infra";
|
|
24
23
|
import * as Effect from "effect/Effect";
|
|
25
24
|
import * as Result from "effect/Result";
|
|
26
|
-
import
|
|
25
|
+
import * as Clock from "effect/Clock";
|
|
27
26
|
// src/sync/mirror.ts
|
|
28
27
|
/** How long a mirror waits before it reads its repo's import again, while the import runs. */
|
|
29
28
|
const importWait = 1e4;
|
|
@@ -143,11 +142,7 @@ const mirrorWith = /* @__PURE__ */ Effect.fnUntraced(function* (bound, input) {
|
|
|
143
142
|
put: [mirrorRow(ref, row)],
|
|
144
143
|
jobs: [job]
|
|
145
144
|
}))).ok) continue;
|
|
146
|
-
|
|
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] }));
|
|
150
|
-
}
|
|
145
|
+
yield* reviveFailedJob(scope, job);
|
|
151
146
|
return stateOf(input.repo, ref, row);
|
|
152
147
|
}
|
|
153
148
|
return yield* contended();
|
package/dist/sync/said.mjs
CHANGED
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
import { tryUnlessSpent } from "../contracts/calls-spent.mjs";
|
|
2
2
|
import { boundedBytes, dropBody } from "../protocol/bytes/reader.mjs";
|
|
3
3
|
import { cutWords, utf8 } from "../protocol/bytes/text.mjs";
|
|
4
|
+
import * as Schema from "effect/Schema";
|
|
4
5
|
import * as Effect from "effect/Effect";
|
|
5
6
|
import * as Option from "effect/Option";
|
|
6
|
-
import * as Schema from "effect/Schema";
|
|
7
7
|
import * as Result from "effect/Result";
|
|
8
8
|
import * as Base64 from "effect/encoding/Base64";
|
|
9
9
|
import * as Base64Url from "effect/encoding/Base64Url";
|