@ref0/git 0.6.0 → 0.7.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/namespace.d.mts +2 -0
- package/dist/access/private-refs.d.mts +6 -29
- package/dist/access/private-refs.mjs +28 -13
- package/dist/access/public.d.mts +6 -0
- package/dist/access/public.mjs +9 -0
- package/dist/auth/access-jwt.d.mts +10 -6
- package/dist/auth/access-jwt.mjs +59 -40
- package/dist/auth/auth-namespace.d.mts +6 -0
- package/dist/auth/auth-namespace.mjs +12 -0
- package/dist/auth/auth.d.mts +3 -6
- package/dist/auth/auth.mjs +2 -9
- package/dist/auth/authorize.mjs +4 -5
- package/dist/auth/fences.d.mts +1 -1
- package/dist/auth/host-function.mjs +17 -8
- package/dist/auth/identify.mjs +2 -1
- package/dist/auth/namespaces.d.mts +2 -2
- package/dist/auth/token-rows.mjs +1 -1
- package/dist/auth/tokens-layer.d.mts +42 -0
- package/dist/auth/tokens-layer.mjs +29 -0
- package/dist/auth/tokens-namespace.d.mts +2 -0
- package/dist/auth/tokens-public.d.mts +6 -0
- package/dist/auth/tokens-public.mjs +29 -0
- package/dist/auth/tokens.d.mts +13 -6
- package/dist/auth/tokens.mjs +5 -5
- package/dist/auth.d.mts +2 -2
- package/dist/auth.mjs +2 -2
- package/dist/client/git-http.mjs +1 -1
- package/dist/client/local.mjs +4 -3
- package/dist/client/remote-helper.mjs +3 -8
- package/dist/client/remote.mjs +26 -7
- package/dist/client/run-remote-helper.d.mts +1 -1
- package/dist/client/run-remote-helper.mjs +2 -2
- package/dist/client/slice-push.d.mts +1 -1
- package/dist/contracts/access.d.mts +18 -10
- package/dist/contracts/access.mjs +17 -0
- package/dist/contracts/actors.d.mts +17 -1
- package/dist/contracts/actors.mjs +8 -1
- package/dist/contracts/authorize.d.mts +7 -4
- package/dist/contracts/blobs.d.mts +1 -1
- package/dist/contracts/blobs.mjs +1 -1
- package/dist/contracts/calls-spent.d.mts +6 -4
- package/dist/contracts/calls-spent.mjs +10 -8
- package/dist/contracts/commits.d.mts +2 -2
- package/dist/contracts/commits.mjs +1 -1
- package/dist/contracts/engine.d.mts +1 -1
- package/dist/contracts/events.d.mts +33 -22
- package/dist/contracts/events.mjs +13 -4
- package/dist/contracts/files.d.mts +2 -2
- package/dist/contracts/files.mjs +1 -1
- package/dist/contracts/forks.d.mts +58 -58
- package/dist/contracts/forks.mjs +1 -1
- package/dist/contracts/git-events.d.mts +50 -0
- package/dist/contracts/git-events.mjs +23 -0
- package/dist/contracts/git-hooks.d.mts +37 -0
- package/dist/contracts/git-hooks.mjs +10 -0
- package/dist/contracts/git.d.mts +93 -42
- package/dist/contracts/git.mjs +6 -5
- package/dist/contracts/ids.d.mts +16 -0
- package/dist/contracts/ids.mjs +19 -4
- package/dist/contracts/lfs.d.mts +2 -0
- package/dist/contracts/namespaces.d.mts +2 -2
- package/dist/contracts/objects.d.mts +1 -1
- package/dist/contracts/opaque.mjs +9 -0
- package/dist/contracts/operations.d.mts +293 -100
- package/dist/contracts/promises.d.mts +2 -0
- package/dist/contracts/push-uploads.d.mts +4 -1
- package/dist/contracts/push-uploads.mjs +9 -4
- package/dist/contracts/queue.d.mts +218 -47
- package/dist/contracts/queue.mjs +81 -6
- package/dist/contracts/refs.d.mts +30 -8
- package/dist/contracts/refs.mjs +1 -1
- package/dist/contracts/remote.d.mts +42 -21
- package/dist/contracts/remote.mjs +22 -0
- package/dist/contracts/repo-records.d.mts +2 -2
- package/dist/contracts/repos.d.mts +126 -79
- package/dist/contracts/repos.mjs +43 -5
- package/dist/contracts/result.d.mts +46 -31
- package/dist/contracts/result.mjs +43 -16
- package/dist/contracts/rules.d.mts +50 -44
- package/dist/contracts/rules.mjs +5 -1
- package/dist/contracts/server.d.mts +282 -198
- package/dist/contracts/services.d.mts +1 -7
- package/dist/contracts/services.mjs +1 -3
- package/dist/contracts/signin.d.mts +140 -43
- package/dist/contracts/signin.mjs +35 -1
- package/dist/contracts/store.d.mts +1 -1
- package/dist/contracts/sync.d.mts +112 -90
- package/dist/contracts/sync.mjs +34 -7
- package/dist/contracts/tags.d.mts +1 -1
- package/dist/contracts/tags.mjs +1 -1
- package/dist/contracts/tokens.d.mts +232 -57
- package/dist/contracts/tokens.mjs +80 -19
- package/dist/contracts/topics.d.mts +22 -10
- package/dist/contracts/topics.mjs +6 -3
- package/dist/contracts/trees.d.mts +2 -2
- package/dist/contracts/trees.mjs +1 -1
- package/dist/contracts/work.d.mts +2 -2
- package/dist/contracts/work.mjs +2 -2
- package/dist/core/access.d.mts +10 -10
- package/dist/core/access.mjs +31 -8
- package/dist/core/clock.mjs +1 -1
- package/dist/core/events/deliver.d.mts +3 -2
- package/dist/core/events/deliver.mjs +170 -92
- package/dist/core/forks.mjs +49 -24
- package/dist/core/hooks/groups.d.mts +27 -0
- package/dist/core/hooks/groups.mjs +74 -0
- package/dist/core/hooks/namespace.d.mts +2 -0
- package/dist/core/hooks/order.d.mts +2 -2
- package/dist/core/hooks/order.mjs +6 -6
- package/dist/core/hooks/public.d.mts +7 -0
- package/dist/core/hooks/public.mjs +5 -0
- package/dist/core/imports.mjs +94 -10
- package/dist/core/index-job.mjs +11 -8
- package/dist/core/merge-parts.d.mts +1 -1
- package/dist/core/merge-parts.mjs +1 -1
- package/dist/core/mirror-rows.mjs +18 -0
- package/dist/core/names.mjs +1 -1
- package/dist/core/namespaces.d.mts +2 -1
- package/dist/core/objects/commit-writes.mjs +5 -5
- package/dist/core/objects/merges.mjs +1 -1
- package/dist/core/objects/objects-layer.mjs +1 -1
- package/dist/core/objects/reading.mjs +52 -7
- package/dist/core/objects/tree-edits.mjs +13 -28
- package/dist/core/objects/trees.mjs +4 -4
- package/dist/core/objects/writing.mjs +3 -3
- package/dist/core/own-writes.mjs +1 -1
- package/dist/core/parts.d.mts +22 -3
- package/dist/core/parts.mjs +5 -3
- package/dist/core/promise.mjs +23 -3
- package/dist/core/purge.d.mts +2 -2
- package/dist/core/purge.mjs +80 -30
- package/dist/core/push.mjs +55 -74
- package/dist/core/receipts.d.mts +2 -2
- package/dist/core/receipts.mjs +28 -4
- package/dist/core/ref-index-job.mjs +4 -4
- package/dist/core/ref-view.mjs +2 -2
- package/dist/core/refs.mjs +41 -10
- package/dist/core/registered-records.mjs +30 -0
- package/dist/core/{claim-rows.mjs → registered-rows.mjs} +6 -6
- package/dist/core/repack.d.mts +2 -2
- package/dist/core/repack.mjs +11 -9
- package/dist/core/repo-info.mjs +59 -25
- package/dist/core/repos.mjs +17 -11
- package/dist/core/rules/changes.mjs +2 -2
- package/dist/core/rules/commit-changes.mjs +1 -1
- package/dist/core/rules/context.d.mts +4 -5
- package/dist/core/rules/context.mjs +3 -4
- package/dist/core/rules/fetch.mjs +74 -21
- package/dist/core/saved-caller-views.d.mts +72 -0
- package/dist/core/saved-caller-views.mjs +123 -0
- package/dist/core/saved-callers-public.d.mts +5 -0
- package/dist/core/saved-callers-public.mjs +10 -0
- package/dist/core/saved-callers.mjs +95 -0
- package/dist/core/seam.d.mts +12 -1
- package/dist/core/seam.mjs +4 -2
- package/dist/core/tokens.mjs +5 -1
- package/dist/core/view.d.mts +1 -1
- package/dist/core/view.mjs +1 -1
- package/dist/core/work.mjs +6 -5
- package/dist/effect.d.mts +2 -2
- package/dist/effect.mjs +2 -2
- package/dist/engine/content.d.mts +2 -2
- package/dist/engine/content.mjs +1 -1
- package/dist/engine/diff.mjs +2 -2
- package/dist/engine/merge-base-walk.d.mts +2 -2
- package/dist/engine/merge-base-walk.mjs +1 -1
- package/dist/engine/merge-renames.mjs +1 -1
- package/dist/engine/reads.d.mts +2 -2
- package/dist/engine/reads.mjs +1 -1
- package/dist/engine/xdiff.d.mts +1 -1
- package/dist/engine/xdiff.mjs +2 -2
- package/dist/event-streams/event-streams.d.mts +6 -2
- package/dist/event-streams/event-streams.mjs +6 -2
- package/dist/event-streams/stream.mjs +5 -2
- package/dist/extend.d.mts +3 -3
- package/dist/extend.mjs +3 -2
- package/dist/http/answers.mjs +4 -3
- package/dist/http/core-parts.mjs +2 -2
- package/dist/http/handler.mjs +1 -1
- package/dist/http/parts.d.mts +1 -0
- package/dist/http/push-uploads.mjs +7 -5
- package/dist/http/receive-pack.mjs +3 -3
- package/dist/http/upload-pack.mjs +6 -5
- package/dist/index.d.mts +33 -20
- package/dist/index.mjs +13 -7
- package/dist/lfs/base.d.mts +2 -2
- package/dist/lfs/calls.mjs +3 -2
- package/dist/lfs/layer.d.mts +5 -4
- package/dist/lfs/layer.mjs +17 -16
- package/dist/lfs/locks.mjs +3 -3
- package/dist/lfs/objects.d.mts +3 -2
- package/dist/lfs/objects.mjs +149 -34
- package/dist/lfs/pointers.mjs +1 -1
- package/dist/lfs/purge.mjs +1 -1
- package/dist/lfs/rows.mjs +1 -1
- package/dist/lfs/upkeep.mjs +13 -9
- package/dist/lfs/wire.mjs +1 -1
- 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/hmac-sha256.mjs +3 -6
- 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 +2 -2
- package/dist/protocol/diff/read.d.mts +1 -1
- package/dist/protocol/diff/read.mjs +1 -1
- package/dist/protocol/diff/tree-diff.d.mts +1 -1
- package/dist/protocol/diff/tree-diff.mjs +11 -11
- package/dist/protocol/objects/lfs-pointer.mjs +6 -1
- package/dist/protocol/objects/tag.mjs +1 -1
- package/dist/protocol/objects/tree.mjs +1 -1
- 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 +2 -2
- 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 +4 -4
- package/dist/protocol/wire/advertisement.d.mts +1 -1
- package/dist/protocol/wire/advertisement.mjs +1 -1
- package/dist/protocol/wire/fetch.d.mts +1 -1
- package/dist/protocol/wire/fetch.mjs +1 -1
- package/dist/protocol/wire/lines.d.mts +1 -1
- package/dist/protocol/wire/lines.mjs +2 -2
- package/dist/protocol/wire/push-uploads.mjs +4 -2
- 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 +2 -2
- package/dist/protocol/wire/v2.mjs +2 -2
- package/dist/queue/advance.mjs +155 -63
- package/dist/queue/callers.mjs +56 -69
- package/dist/queue/calls.mjs +20 -11
- package/dist/queue/commit.mjs +28 -22
- package/dist/queue/host.d.mts +10 -11
- package/dist/queue/host.mjs +15 -7
- package/dist/queue/lanes.mjs +9 -18
- package/dist/queue/layer.d.mts +3 -3
- package/dist/queue/layer.mjs +11 -10
- package/dist/queue/limits.mjs +17 -5
- package/dist/queue/rows.mjs +5 -10
- package/dist/queue/schedule.mjs +6 -5
- package/dist/queue/search.mjs +8 -13
- package/dist/queue/state.mjs +7 -2
- package/dist/queue/trim.mjs +10 -5
- package/dist/rest/api.d.mts +1 -1
- package/dist/rest/blobs.d.mts +20 -20
- package/dist/rest/caller.d.mts +22 -20
- package/dist/rest/client.mjs +6 -6
- package/dist/rest/commits.d.mts +335 -335
- package/dist/rest/errors.d.mts +10 -10
- package/dist/rest/errors.mjs +1 -1
- package/dist/rest/events.d.mts +13 -11
- package/dist/rest/events.mjs +3 -1
- package/dist/rest/files.d.mts +30 -30
- package/dist/rest/forks.d.mts +150 -150
- package/dist/rest/handler.mjs +4 -3
- package/dist/rest/handlers.mjs +13 -7
- package/dist/rest/layer.d.mts +3 -3
- package/dist/rest/layer.mjs +8 -7
- package/dist/rest/listen.mjs +2 -2
- package/dist/rest/me.d.mts +18 -20
- package/dist/rest/me.mjs +1 -1
- package/dist/rest/merges.d.mts +10 -10
- package/dist/rest/queue.d.mts +140 -140
- package/dist/rest/queue.mjs +1 -1
- package/dist/rest/refs.d.mts +95 -95
- package/dist/rest/refs.mjs +1 -1
- package/dist/rest/repos.d.mts +127 -127
- package/dist/rest/tags.d.mts +30 -30
- package/dist/rest/tokens.d.mts +250 -260
- package/dist/rest/tokens.mjs +10 -42
- package/dist/rest/topics.d.mts +63 -63
- package/dist/rest/topics.mjs +1 -1
- package/dist/rest/trees.d.mts +106 -106
- package/dist/rest/wire.d.mts +6 -4
- package/dist/rest/wire.mjs +4 -3
- package/dist/rest/work.d.mts +69 -69
- package/dist/rest/work.mjs +1 -1
- package/dist/server/check-fetch.mjs +9 -0
- package/dist/server/extension.mjs +3 -115
- package/dist/server/git-layer.d.mts +20 -3
- package/dist/server/git-layer.mjs +30 -19
- package/dist/server/git-namespace.d.mts +4 -4
- package/dist/server/git-namespace.mjs +6 -4
- package/dist/server/joined.d.mts +83 -0
- package/dist/server/joined.mjs +91 -0
- package/dist/server/registry.d.mts +7 -3
- package/dist/server/registry.mjs +135 -31
- package/dist/server/routes.mjs +2 -2
- package/dist/server/server.d.mts +9 -2
- package/dist/server/server.mjs +279 -191
- package/dist/signin/context.d.mts +2 -1
- package/dist/signin/context.mjs +32 -37
- package/dist/signin/device.mjs +5 -5
- package/dist/signin/forms.mjs +1 -1
- package/dist/signin/grants.d.mts +2 -3
- package/dist/signin/grants.mjs +5 -5
- package/dist/signin/layer.d.mts +9 -0
- package/dist/signin/layer.mjs +41 -0
- package/dist/signin/namespace.d.mts +2 -0
- package/dist/signin/public.d.mts +6 -0
- package/dist/signin/public.mjs +5 -0
- package/dist/signin/route.mjs +47 -21
- package/dist/signin/web.mjs +3 -3
- package/dist/signin/wire.mjs +1 -1
- package/dist/storage/calls.d.mts +1 -1
- package/dist/storage/calls.mjs +4 -4
- package/dist/storage/clean-up.mjs +12 -5
- package/dist/storage/counted-bucket.mjs +34 -51
- package/dist/storage/fetch.mjs +1 -1
- package/dist/storage/host-bucket.mjs +1 -1
- package/dist/storage/index-build.d.mts +2 -2
- package/dist/storage/index-build.mjs +3 -3
- package/dist/storage/index-fetch.mjs +10 -6
- package/dist/storage/index-graph.mjs +1 -1
- package/dist/storage/index-layers.mjs +1 -1
- package/dist/storage/index-visible.mjs +1 -1
- package/dist/storage/memory-budget.mjs +7 -1
- package/dist/storage/merge-cut.mjs +24 -1
- package/dist/storage/merge-fence.mjs +1 -1
- package/dist/storage/merge-plan.mjs +5 -2
- package/dist/storage/merge-row.mjs +1 -1
- package/dist/storage/merge-stream.mjs +16 -7
- package/dist/storage/merge-write.mjs +1 -1
- package/dist/storage/merge.d.mts +2 -2
- package/dist/storage/merge.mjs +1 -1
- package/dist/storage/object-rows.d.mts +2 -2
- package/dist/storage/object-rows.mjs +3 -3
- package/dist/storage/pack-ranges.d.mts +3 -1
- package/dist/storage/pack-ranges.mjs +168 -69
- package/dist/storage/pack-reads.mjs +4 -4
- package/dist/storage/pack-receive.d.mts +1 -1
- package/dist/storage/pack-receive.mjs +7 -9
- package/dist/storage/packs.d.mts +1 -1
- package/dist/storage/packs.mjs +45 -52
- package/dist/storage/placed-reads.mjs +81 -15
- package/dist/storage/prune-seen.mjs +126 -0
- package/dist/storage/prune-walk.mjs +87 -99
- package/dist/storage/prune.mjs +49 -14
- package/dist/storage/push-uploads.mjs +4 -2
- package/dist/storage/quarantine.d.mts +2 -2
- package/dist/storage/ready.d.mts +2 -2
- package/dist/storage/ready.mjs +3 -3
- 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 +1 -1
- package/dist/storage/receive-steps.mjs +1 -1
- package/dist/storage/repack-contained.mjs +2 -2
- package/dist/storage/repack-job.d.mts +2 -2
- package/dist/storage/repack-job.mjs +5 -4
- package/dist/storage/repack.d.mts +1 -1
- package/dist/storage/repack.mjs +9 -3
- 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 +15 -6
- package/dist/storage/send-list.mjs +6 -6
- package/dist/storage/single-flight.mjs +2 -2
- package/dist/storage/swap-walk.mjs +1 -1
- package/dist/storage/unpack.mjs +1 -1
- package/dist/store/call-count.d.mts +1 -1
- package/dist/store/call-count.mjs +125 -34
- package/dist/store/catalogue.d.mts +1 -1
- package/dist/store/catalogue.mjs +2 -2
- package/dist/store/crossing.mjs +2 -6
- package/dist/store/cursor-seal.mjs +1 -1
- package/dist/store/errors.d.mts +7 -3
- package/dist/store/errors.mjs +41 -13
- package/dist/store/job-try.mjs +119 -15
- package/dist/store/list-job.mjs +5 -5
- package/dist/store/outbox.d.mts +2 -2
- package/dist/store/outbox.mjs +75 -16
- package/dist/store/promises.d.mts +2 -2
- package/dist/store/promises.mjs +31 -6
- package/dist/store/queue-jobs.mjs +1 -1
- package/dist/store/records.d.mts +2 -2
- package/dist/store/records.mjs +16 -24
- package/dist/store/ref-rows.d.mts +2 -2
- package/dist/store/ref-rows.mjs +6 -6
- package/dist/store/reservations.mjs +35 -8
- package/dist/store/scopes.mjs +6 -4
- package/dist/store/topic-jobs.mjs +8 -8
- package/dist/sync/bound.d.mts +1 -3
- package/dist/sync/bound.mjs +30 -42
- package/dist/sync/bridge.d.mts +6 -0
- package/dist/sync/bridge.mjs +29 -0
- package/dist/sync/github.d.mts +5 -6
- package/dist/sync/github.mjs +37 -42
- package/dist/sync/http.mjs +15 -0
- package/dist/sync/import.mjs +17 -18
- package/dist/sync/layer.d.mts +9 -0
- package/dist/sync/layer.mjs +68 -0
- package/dist/sync/mirror.mjs +137 -58
- package/dist/sync/publish.mjs +3 -6
- package/dist/sync/step.mjs +217 -79
- package/dist/sync/tries.mjs +22 -15
- package/dist/sync.d.mts +3 -6
- package/dist/sync.mjs +3 -6
- package/dist/topics/advance.mjs +205 -90
- package/dist/topics/calls.mjs +8 -8
- package/dist/topics/directory.mjs +35 -12
- package/dist/topics/host.d.mts +5 -8
- package/dist/topics/host.mjs +42 -19
- package/dist/topics/layer.d.mts +381 -0
- package/dist/topics/layer.mjs +62 -0
- package/dist/topics/members.mjs +1 -1
- package/dist/topics/namespace.d.mts +2 -0
- package/dist/topics/public.d.mts +6 -0
- package/dist/topics/public.mjs +13 -0
- package/dist/topics/rows.mjs +12 -3
- package/dist/topics/topic.mjs +11 -10
- package/package.json +8 -13
- package/dist/access.d.mts +0 -2
- package/dist/access.mjs +0 -1
- package/dist/core/hooks/post-receive.mjs +0 -216
- package/dist/core/hooks/pre-receive.d.mts +0 -12
- package/dist/core/hooks/pre-receive.mjs +0 -36
- package/dist/server/extension.d.mts +0 -21
- package/dist/sync/import.d.mts +0 -10
- package/dist/sync/jobs.d.mts +0 -9
- package/dist/sync/jobs.mjs +0 -75
- package/dist/sync/mirror.d.mts +0 -13
- package/dist/sync/publish.d.mts +0 -6
- /package/dist/core/{claim-rows.d.mts → registered-rows.d.mts} +0 -0
package/dist/lfs/objects.mjs
CHANGED
|
@@ -1,16 +1,20 @@
|
|
|
1
1
|
import { Sha256 } from "../protocol/bytes/sha256.mjs";
|
|
2
2
|
import { contended, openFor } from "../core/access.mjs";
|
|
3
|
-
import {
|
|
3
|
+
import { seenIn } from "../core/objects/reading.mjs";
|
|
4
|
+
import { checkRead, readRefusal } from "../core/rules/fetch.mjs";
|
|
5
|
+
import { utf8 } from "../protocol/bytes/text.mjs";
|
|
6
|
+
import { objectId } from "../protocol/objects/object.mjs";
|
|
7
|
+
import { bestEffort, decodeRow } from "../store/errors.mjs";
|
|
4
8
|
import { randomText } from "../store/random.mjs";
|
|
5
9
|
import { bucketCall, bucketDo, bucketFailed, bucketStream } from "../storage/calls.mjs";
|
|
6
|
-
import { isLfsOid } from "../protocol/objects/lfs-pointer.mjs";
|
|
10
|
+
import { isLfsOid, lfsPointerText } from "../protocol/objects/lfs-pointer.mjs";
|
|
7
11
|
import { ListedRow, UploadRow, largestObject, lfsCollections, linkLife, listedKey, listedRead, objectKey, stagingId, stagingKey, stagingRead, streamMost, uploadGrace, uploadKey, uploadRead } from "./rows.mjs";
|
|
8
12
|
import { BatchRequest, VerifyRequest, batchMost, bodyOf, lfsAnswer } from "./wire.mjs";
|
|
9
|
-
import { fail, gitError } from "../contracts/result.mjs";
|
|
10
|
-
import { Unavailable } from "@ref0/infra";
|
|
11
|
-
import * as Effect from "effect/Effect";
|
|
13
|
+
import { fail, gitError, httpStatus } from "../contracts/result.mjs";
|
|
12
14
|
import * as Clock$1 from "effect/Clock";
|
|
15
|
+
import * as Effect from "effect/Effect";
|
|
13
16
|
import * as Option from "effect/Option";
|
|
17
|
+
import { Unavailable } from "@ref0/infra";
|
|
14
18
|
import * as Stream from "effect/Stream";
|
|
15
19
|
import * as DateTime from "effect/DateTime";
|
|
16
20
|
// src/lfs/objects.ts
|
|
@@ -51,24 +55,64 @@ const listedOf = /* @__PURE__ */ Effect.fnUntraced(function* (rows, repo, oids)
|
|
|
51
55
|
return listed;
|
|
52
56
|
});
|
|
53
57
|
/**
|
|
54
|
-
* The listed rows of `oids` a download from `repo` reads: its own, then,
|
|
55
|
-
*
|
|
56
|
-
*
|
|
57
|
-
*
|
|
58
|
+
* The listed rows of `oids` a download from `repo` reads: its own, then its source's, up the fork
|
|
59
|
+
* chain by internal ID for at most `forkReads` sources. The first listing wins, so a fork's own
|
|
60
|
+
* upload shadows its source's. Each source's rows of every one of `oids` are read, found sooner or
|
|
61
|
+
* not, so the reads made are the same whichever of them are listed, as `unseenOf` needs. A deleted
|
|
62
|
+
* source's rows are read too: its LFS rows and bytes stay while a fork's row names it, since
|
|
63
|
+
* `git.purge` waits on one.
|
|
58
64
|
*/
|
|
59
65
|
const chainListed = /* @__PURE__ */ Effect.fnUntraced(function* (rows, repo, oids) {
|
|
60
66
|
const listed = yield* listedOf(rows, repo, oids);
|
|
67
|
+
if (oids.length === 0) return listed;
|
|
61
68
|
let from = repo;
|
|
62
69
|
for (let read = 0; read < 16; read += 1) {
|
|
63
|
-
const missing = oids.filter((oid) => !listed.has(oid));
|
|
64
|
-
if (missing.length === 0) break;
|
|
65
70
|
const source = yield* rows.source(from);
|
|
66
71
|
if (source === void 0) break;
|
|
67
|
-
for (const [oid, row] of yield* listedOf(rows, source,
|
|
72
|
+
for (const [oid, row] of yield* listedOf(rows, source, oids)) if (!listed.has(oid)) listed.set(oid, row);
|
|
68
73
|
from = source;
|
|
69
74
|
}
|
|
70
75
|
return listed;
|
|
71
76
|
});
|
|
77
|
+
/**
|
|
78
|
+
* Which of `listed`'s objects `caller` mayn't know `repo` lists. A caller whose view of it is
|
|
79
|
+
* narrowed (`RepoView.narrowed`), as under `access` one who doesn't read every pattern is, knows of
|
|
80
|
+
* a listed object only when a ref it sees reaches its pointer as git-lfs writes it
|
|
81
|
+
* (`lfsPointerText`), so an object only a hidden ref's tree points at answers as one never
|
|
82
|
+
* uploaded. So does one only a pointer of another text names, with an extension or blank lines.
|
|
83
|
+
* The view is asked of a pointer for each of `oids`, listed or not, by the listed size or else 0,
|
|
84
|
+
* so the calls it makes are the same whichever of them are listed. Any other caller knows of every
|
|
85
|
+
* one: its view answers that it isn't narrowed, and nothing more is read.
|
|
86
|
+
*/
|
|
87
|
+
const unseenOf = /* @__PURE__ */ Effect.fnUntraced(function* (caller, repo, oids, listed) {
|
|
88
|
+
const unseen = /* @__PURE__ */ new Set();
|
|
89
|
+
const pointers = /* @__PURE__ */ new Map();
|
|
90
|
+
for (const oid of new Set(oids)) {
|
|
91
|
+
const text = lfsPointerText({
|
|
92
|
+
oid,
|
|
93
|
+
size: listed.get(oid)?.size ?? 0
|
|
94
|
+
});
|
|
95
|
+
pointers.set(yield* objectId({
|
|
96
|
+
type: "blob",
|
|
97
|
+
bytes: utf8(text)
|
|
98
|
+
}), oid);
|
|
99
|
+
}
|
|
100
|
+
const seen = yield* seenIn(caller, repo, [...pointers.keys()]);
|
|
101
|
+
if (seen === void 0) return unseen;
|
|
102
|
+
for (const [pointer, oid] of pointers) if (listed.has(oid) && !seen.has(pointer)) unseen.add(oid);
|
|
103
|
+
return unseen;
|
|
104
|
+
});
|
|
105
|
+
/** `listed`, less what `caller` mayn't know of, asked for each of `oids`, as `unseenOf` says. */
|
|
106
|
+
const seenListed = /* @__PURE__ */ Effect.fnUntraced(function* (caller, repo, oids, listed) {
|
|
107
|
+
const unseen = yield* unseenOf(caller, repo, oids, listed);
|
|
108
|
+
return unseen.size === 0 ? listed : new Map([...listed].filter(([oid]) => !unseen.has(oid)));
|
|
109
|
+
});
|
|
110
|
+
/** Which of `rows`' objects `caller` mayn't know are listed, asked for each of `oids`, as `unseenOf` says. */
|
|
111
|
+
const unseenRows = (caller, repo, oids, rows) => {
|
|
112
|
+
const listed = /* @__PURE__ */ new Map();
|
|
113
|
+
for (const [oid, { listed: row }] of rows) if (row !== void 0) listed.set(oid, row);
|
|
114
|
+
return unseenOf(caller, repo, oids, listed);
|
|
115
|
+
};
|
|
72
116
|
const isoOf = (at) => DateTime.formatIso(DateTime.makeUnsafe(at));
|
|
73
117
|
/** An action back to this server, sending the request's own credentials. */
|
|
74
118
|
const ownAction = (call, path, expiresAt) => {
|
|
@@ -107,9 +151,32 @@ const batch = /* @__PURE__ */ Effect.fnUntraced(function* (parts, call) {
|
|
|
107
151
|
});
|
|
108
152
|
});
|
|
109
153
|
const validSize = (size) => Number.isSafeInteger(size) && size >= 0 && size <= largestObject;
|
|
154
|
+
/**
|
|
155
|
+
* The host's fetch rules' refusals of `listed`'s objects, each listed object the caller knows of
|
|
156
|
+
* asked once, before any link is signed. A host's failure fails the whole batch.
|
|
157
|
+
*/
|
|
158
|
+
const refusedOf = /* @__PURE__ */ Effect.fnUntraced(function* (call, listed) {
|
|
159
|
+
const refused = /* @__PURE__ */ new Map();
|
|
160
|
+
for (const [oid, { size }] of listed) {
|
|
161
|
+
const target = {
|
|
162
|
+
kind: "lfs",
|
|
163
|
+
oid,
|
|
164
|
+
size
|
|
165
|
+
};
|
|
166
|
+
const refusal = yield* readRefusal(call.repo, {
|
|
167
|
+
caller: call.caller,
|
|
168
|
+
target,
|
|
169
|
+
request: call.request
|
|
170
|
+
});
|
|
171
|
+
if (refusal !== void 0) refused.set(oid, refusal);
|
|
172
|
+
}
|
|
173
|
+
return refused;
|
|
174
|
+
});
|
|
110
175
|
const downloads = /* @__PURE__ */ Effect.fnUntraced(function* (parts, call, repo, objects) {
|
|
111
176
|
const oids = objects.map(({ oid }) => oid);
|
|
112
|
-
const
|
|
177
|
+
const chained = yield* chainListed(parts.rows, repo.internalId, oids);
|
|
178
|
+
const listed = yield* seenListed(call.caller, repo, oids, chained);
|
|
179
|
+
const refused = yield* refusedOf(call, listed);
|
|
113
180
|
const expiresAt = (yield* Clock$1.currentTimeMillis) + linkLife;
|
|
114
181
|
const answers = /* @__PURE__ */ new Map();
|
|
115
182
|
for (const { oid, size } of objects) {
|
|
@@ -118,6 +185,11 @@ const downloads = /* @__PURE__ */ Effect.fnUntraced(function* (parts, call, repo
|
|
|
118
185
|
answers.set(oid, objectError(oid, size, 404, "Object does not exist"));
|
|
119
186
|
continue;
|
|
120
187
|
}
|
|
188
|
+
const refusal = refused.get(oid);
|
|
189
|
+
if (refusal !== void 0) {
|
|
190
|
+
answers.set(oid, objectError(oid, size, httpStatus[refusal.code], refusal.message));
|
|
191
|
+
continue;
|
|
192
|
+
}
|
|
121
193
|
const key = row.key;
|
|
122
194
|
const signed = parts.signed;
|
|
123
195
|
const download = signed === void 0 ? ownAction(call, `objects/${oid}`, expiresAt) : {
|
|
@@ -144,9 +216,10 @@ const uploads = /* @__PURE__ */ Effect.fnUntraced(function* (parts, call, repo,
|
|
|
144
216
|
for (let tries = 0; tries < 5; tries += 1) {
|
|
145
217
|
const at = yield* Clock$1.currentTimeMillis;
|
|
146
218
|
const read = yield* objectRows(parts.rows, call.caller, repo, oids);
|
|
219
|
+
const unseen = yield* unseenRows(call.caller, repo, oids, read.rows);
|
|
147
220
|
const expiresAt = at + linkLife;
|
|
148
221
|
const removeAt = expiresAt + uploadGrace;
|
|
149
|
-
const put = objects.filter(({ oid }) => read.rows.get(oid)?.listed === void 0).map(({ oid, size }) => {
|
|
222
|
+
const put = objects.filter(({ oid }) => read.rows.get(oid)?.listed === void 0 || unseen.has(oid)).map(({ oid, size }) => {
|
|
150
223
|
const before = read.rows.get(oid)?.upload;
|
|
151
224
|
const value = {
|
|
152
225
|
size,
|
|
@@ -206,17 +279,19 @@ const uploadActions = /* @__PURE__ */ Effect.fnUntraced(function* (parts, call,
|
|
|
206
279
|
const verify = /* @__PURE__ */ Effect.fnUntraced(function* (parts, call) {
|
|
207
280
|
const { oid, size } = yield* bodyOf(call.request, VerifyRequest);
|
|
208
281
|
if (!isLfsOid(oid)) return yield* fail("INVALID_ARGUMENT", "An oid is a SHA-256, as 64 lowercase hex digits");
|
|
209
|
-
const { rows:
|
|
282
|
+
const { rows: registered, signed } = parts;
|
|
210
283
|
const repo = yield* openFor(call.caller, call.repo, true);
|
|
211
284
|
for (let tries = 0; tries < 5; tries += 1) {
|
|
212
|
-
const read = yield* objectRows(
|
|
285
|
+
const read = yield* objectRows(registered, call.caller, repo, [oid]);
|
|
213
286
|
const rows = read.rows.get(oid);
|
|
214
|
-
|
|
287
|
+
const unseen = (yield* unseenRows(call.caller, repo, [oid], read.rows)).has(oid);
|
|
288
|
+
if (rows?.listed !== void 0 && !unseen) return lfsAnswer(200, { message: "Verified" });
|
|
215
289
|
const key = rows?.upload === void 0 ? void 0 : objectKey(repo.internalId, oid, rows.upload.generation);
|
|
216
290
|
const stored = signed === void 0 || key === void 0 ? void 0 : yield* bucketCall(Effect.map(signed.head(key), Option.getOrUndefined));
|
|
217
291
|
if (stored?.sha256 !== oid) return yield* fail("FAILED_PRECONDITION", "The bucket holds no bytes for this object", { hint: "Upload it again" });
|
|
218
292
|
if (stored.size !== size) return yield* fail("INVALID_ARGUMENT", `This object is ${stored.size} bytes, not ${size}`);
|
|
219
|
-
if (
|
|
293
|
+
if (unseen) return lfsAnswer(200, { message: "Verified" });
|
|
294
|
+
if ((yield* registered.commit(repo.internalId, read.version, {
|
|
220
295
|
put: [{
|
|
221
296
|
...listedKey(oid),
|
|
222
297
|
value: {
|
|
@@ -236,17 +311,19 @@ const verify = /* @__PURE__ */ Effect.fnUntraced(function* (parts, call) {
|
|
|
236
311
|
*/
|
|
237
312
|
const receive = /* @__PURE__ */ Effect.fnUntraced(function* (parts, call, oid) {
|
|
238
313
|
if (!isLfsOid(oid)) return yield* fail("INVALID_ARGUMENT", "An oid is a SHA-256, as 64 lowercase hex digits");
|
|
239
|
-
const { rows:
|
|
314
|
+
const { rows: registered, bucket } = parts;
|
|
240
315
|
const repo = yield* openFor(call.caller, call.repo, true);
|
|
241
316
|
const started = yield* Clock$1.currentTimeMillis;
|
|
242
|
-
const
|
|
243
|
-
|
|
317
|
+
const read = yield* objectRows(registered, call.caller, repo, [oid]);
|
|
318
|
+
const rows = read.rows.get(oid);
|
|
319
|
+
const unseen = (yield* unseenRows(call.caller, repo, [oid], read.rows)).has(oid);
|
|
320
|
+
if (rows?.listed !== void 0 && !unseen) return yield* answered(call.request);
|
|
244
321
|
const upload = rows?.upload;
|
|
245
322
|
if (upload === void 0 || upload.expiresAt < started) return yield* fail("FAILED_PRECONDITION", "No upload link for this object is live", { hint: "Ask the batch API again" });
|
|
246
323
|
const id = randomText(16);
|
|
247
324
|
const key = stagingKey(repo.internalId, id);
|
|
248
325
|
const staged = stagingId(started + uploadGrace, id);
|
|
249
|
-
yield*
|
|
326
|
+
yield* registered.add(repo.internalId, {
|
|
250
327
|
put: [{
|
|
251
328
|
collection: lfsCollections.staging,
|
|
252
329
|
id: staged,
|
|
@@ -266,15 +343,35 @@ const receive = /* @__PURE__ */ Effect.fnUntraced(function* (parts, call, oid) {
|
|
|
266
343
|
})
|
|
267
344
|
});
|
|
268
345
|
yield* Effect.uninterruptible(bucketDo(bucket.put(key, body, { size: upload.size }))).pipe(Effect.mapError((error) => hashed.past() ? pastSize(upload.size) : error));
|
|
269
|
-
if (hashed.sha256() !== oid)
|
|
270
|
-
|
|
346
|
+
if (hashed.sha256() !== oid) {
|
|
347
|
+
yield* dropStaged(parts, repo.internalId, key, staged);
|
|
348
|
+
return yield* fail("INVALID_ARGUMENT", "The bytes' SHA-256 isn't the oid");
|
|
349
|
+
}
|
|
350
|
+
return yield* listStaged(registered, call.caller, repo, {
|
|
271
351
|
oid,
|
|
272
352
|
size: upload.size,
|
|
273
353
|
key,
|
|
274
354
|
staged,
|
|
275
|
-
deadline: started + streamMost
|
|
355
|
+
deadline: started + streamMost,
|
|
356
|
+
unseen
|
|
276
357
|
});
|
|
277
358
|
});
|
|
359
|
+
/**
|
|
360
|
+
* Deletes refused bytes at once, then their staging row at the version it's read at (#1940). A
|
|
361
|
+
* failure of either leaves the row, whose wake has upkeep delete the bytes at its removeAt, and is
|
|
362
|
+
* no reason to answer it in place of the refusal.
|
|
363
|
+
*/
|
|
364
|
+
const dropStaged = /* @__PURE__ */ Effect.fnUntraced(function* (parts, repo, key, staged) {
|
|
365
|
+
const row = {
|
|
366
|
+
collection: lfsCollections.staging,
|
|
367
|
+
id: staged
|
|
368
|
+
};
|
|
369
|
+
yield* bestEffort(Effect.gen(function* () {
|
|
370
|
+
yield* bucketDo(parts.bucket.remove(key));
|
|
371
|
+
const read = yield* parts.rows.read(repo, [row]);
|
|
372
|
+
yield* parts.rows.commit(repo, read.version, { delete: [row] });
|
|
373
|
+
}));
|
|
374
|
+
});
|
|
278
375
|
const pastSize = (size) => gitError("INVALID_ARGUMENT", `The bytes run past the ${size} the batch named`);
|
|
279
376
|
/**
|
|
280
377
|
* An answer to a request whose body isn't needed: the body is let go first, and a cancel that
|
|
@@ -301,12 +398,12 @@ const hashing = (body, most) => {
|
|
|
301
398
|
};
|
|
302
399
|
};
|
|
303
400
|
/** Lists a Worker upload's bytes at their staging key, in the commit that drops its staging row. */
|
|
304
|
-
const listStaged = /* @__PURE__ */ Effect.fnUntraced(function* (
|
|
401
|
+
const listStaged = /* @__PURE__ */ Effect.fnUntraced(function* (registered, caller, repo, staged) {
|
|
305
402
|
for (let tries = 0; tries < 5; tries += 1) {
|
|
306
|
-
const read = yield* objectRows(
|
|
307
|
-
if (read.rows.get(staged.oid)?.listed !== void 0) return lfsAnswer(200, { message: "Already uploaded" });
|
|
403
|
+
const read = yield* objectRows(registered, caller, repo, [staged.oid], [stagingRead(staged.staged)]);
|
|
404
|
+
if (read.rows.get(staged.oid)?.listed !== void 0) return lfsAnswer(200, { message: staged.unseen ? "Uploaded" : "Already uploaded" });
|
|
308
405
|
if ((read.also[0] ?? []).length === 0 || (yield* Clock$1.currentTimeMillis) > staged.deadline) return yield* fail("DEADLINE_EXCEEDED", "The upload ran too long", { hint: "Upload it again" });
|
|
309
|
-
if ((yield*
|
|
406
|
+
if ((yield* registered.commit(repo.internalId, read.version, {
|
|
310
407
|
put: [{
|
|
311
408
|
...listedKey(staged.oid),
|
|
312
409
|
value: {
|
|
@@ -323,15 +420,27 @@ const listStaged = /* @__PURE__ */ Effect.fnUntraced(function* (claimed, caller,
|
|
|
323
420
|
return yield* contended();
|
|
324
421
|
});
|
|
325
422
|
/**
|
|
326
|
-
* A listed object's bytes, the repo's own or a source's, once the caller may read the repo
|
|
327
|
-
* `
|
|
423
|
+
* A listed object's bytes, the repo's own or a source's, once the caller may read the repo and
|
|
424
|
+
* knows of the object, as `unseenOf` says: else it answers as one never uploaded. The host's fetch
|
|
425
|
+
* rules are asked of it then, before the bucket's stream opens, and their refusal or failure is
|
|
426
|
+
* the read's. `signal` aborted cancels the bucket's stream, opening or open.
|
|
328
427
|
*/
|
|
329
428
|
const objectOf = /* @__PURE__ */ Effect.fnUntraced(function* (parts, read) {
|
|
330
429
|
const { oid, size, signal } = read;
|
|
331
430
|
if (!isLfsOid(oid)) return yield* fail("NOT_FOUND", "Object does not exist");
|
|
332
431
|
const repo = yield* openFor(read.caller, read.repo, false, read.internalId);
|
|
333
|
-
const
|
|
432
|
+
const chained = yield* chainListed(parts.rows, repo.internalId, [oid]);
|
|
433
|
+
const listed = (yield* seenListed(read.caller, repo, [oid], chained)).get(oid);
|
|
334
434
|
if (listed === void 0 || size !== void 0 && size !== listed.size) return yield* fail("NOT_FOUND", "Object does not exist");
|
|
435
|
+
yield* checkRead(read.repo, {
|
|
436
|
+
caller: read.caller,
|
|
437
|
+
target: {
|
|
438
|
+
kind: "lfs",
|
|
439
|
+
oid,
|
|
440
|
+
size: listed.size
|
|
441
|
+
},
|
|
442
|
+
request: read.request
|
|
443
|
+
});
|
|
335
444
|
const stream = yield* bucketStream(parts.bucket, listed.key);
|
|
336
445
|
if (stream === void 0) return yield* fail("DATA_LOSS", `LFS object ${oid}'s bytes are missing`);
|
|
337
446
|
const bytes = signal === void 0 ? stream : stream.pipeThrough(new TransformStream(), { signal });
|
|
@@ -341,12 +450,18 @@ const objectOf = /* @__PURE__ */ Effect.fnUntraced(function* (parts, read) {
|
|
|
341
450
|
bytes
|
|
342
451
|
};
|
|
343
452
|
});
|
|
344
|
-
/**
|
|
453
|
+
/**
|
|
454
|
+
* `GET objects/<oid>`, a Worker download: a listed object's bytes, the repo's own or a source's,
|
|
455
|
+
* as `objectOf` reads them. Its fetch rules are asked again, though the batch that gave the link
|
|
456
|
+
* asked them: the link outlives that answer, and a signed bucket's link, which the bucket serves,
|
|
457
|
+
* is asked only at the batch.
|
|
458
|
+
*/
|
|
345
459
|
const send = /* @__PURE__ */ Effect.fnUntraced(function* (parts, call, oid) {
|
|
346
460
|
const object = yield* objectOf(parts, {
|
|
347
461
|
caller: call.caller,
|
|
348
462
|
repo: call.repo,
|
|
349
|
-
oid
|
|
463
|
+
oid,
|
|
464
|
+
request: call.request
|
|
350
465
|
});
|
|
351
466
|
return new Response(object.bytes, {
|
|
352
467
|
status: 200,
|
package/dist/lfs/pointers.mjs
CHANGED
|
@@ -26,7 +26,7 @@ const pushCheckMilliseconds = 6e4;
|
|
|
26
26
|
/** A file's modes: a symlink or a submodule is never a pointer. */
|
|
27
27
|
const fileModes = /* @__PURE__ */ new Set(["100644", "100755"]);
|
|
28
28
|
/**
|
|
29
|
-
* The check, over the repo's listed rows in LFS's
|
|
29
|
+
* The check, over the repo's listed rows in LFS's registration's `rows`: each ref it refuses, with why.
|
|
30
30
|
* It answers only for the refs it's asked of, and may be asked twice.
|
|
31
31
|
*/
|
|
32
32
|
const pointerCheck = /* @__PURE__ */ Effect.fnUntraced(function* (rows, input) {
|
package/dist/lfs/purge.mjs
CHANGED
|
@@ -2,7 +2,7 @@ import { bucketDo } from "../storage/calls.mjs";
|
|
|
2
2
|
import { decodeRow } from "../store/errors.mjs";
|
|
3
3
|
import { ListedRow, lfsCollections } from "./rows.mjs";
|
|
4
4
|
import * as Effect from "effect/Effect";
|
|
5
|
-
/** LFS's
|
|
5
|
+
/** LFS's registration's purge over its `rows` and `bucket`, which charges each call. */
|
|
6
6
|
const lfsPurge = (rows, bucket) => /* @__PURE__ */ Effect.fnUntraced(function* ({ repo }) {
|
|
7
7
|
const snapshot = yield* rows.read(repo, [
|
|
8
8
|
{
|
package/dist/lfs/rows.mjs
CHANGED
|
@@ -7,7 +7,7 @@ import * as Schema from "effect/Schema";
|
|
|
7
7
|
* SHA-256 ever reach. A repo serves only the objects it lists, and lists one only after its bytes
|
|
8
8
|
* were checked at its key.
|
|
9
9
|
*/
|
|
10
|
-
/** LFS's collections in a repo's scope: its
|
|
10
|
+
/** LFS's collections in a repo's scope: its registration's rows, under `lfs/`. */
|
|
11
11
|
const lfsCollections = {
|
|
12
12
|
/** Each LFS object the repo lists, by its oid. Only a deleted repo unlists. */
|
|
13
13
|
objects: "lfs/objects",
|
package/dist/lfs/upkeep.mjs
CHANGED
|
@@ -1,13 +1,14 @@
|
|
|
1
1
|
import { bucketDo } from "../storage/calls.mjs";
|
|
2
2
|
import { decodeRow } from "../store/errors.mjs";
|
|
3
|
-
import { EndingRow, StagingRow, UploadRow, endingKey, lfsCollections, listedRead, objectKey, uploadKey, uploadRead } from "./rows.mjs";
|
|
3
|
+
import { EndingRow, ListedRow, StagingRow, UploadRow, endingKey, lfsCollections, listedRead, objectKey, uploadKey, uploadRead } from "./rows.mjs";
|
|
4
4
|
import * as Effect from "effect/Effect";
|
|
5
5
|
// src/lfs/upkeep.ts
|
|
6
6
|
/**
|
|
7
7
|
* LFS's part of a repo's `git.repack`: it deletes the bytes no listing will name. A Worker
|
|
8
8
|
* upload's staging key goes at its row's `removeAt`, a day after it began, when its stream has
|
|
9
9
|
* long ended. A signed upload's object key goes at its upload row's `removeAt`, a day after its
|
|
10
|
-
* last link expired, if the object is still unlisted
|
|
10
|
+
* last link expired, if the object is still unlisted or listed at another key: the commit that
|
|
11
|
+
* drops the upload row puts
|
|
11
12
|
* an ending row naming the key, so verify, which lists only the key its upload row names, never
|
|
12
13
|
* lists it again, and an upload after gets a key of its own. A delete that lands late, after a try
|
|
13
14
|
* that sent it timed out, reaches only bytes no listing names. A key is deleted before the row
|
|
@@ -17,7 +18,7 @@ import * as Effect from "effect/Effect";
|
|
|
17
18
|
/** The most rows of each kind a step ends. */
|
|
18
19
|
const upkeepPage = 500;
|
|
19
20
|
/**
|
|
20
|
-
* LFS's
|
|
21
|
+
* LFS's registration's upkeep over its `rows` and `bucket`'s objects: `bucket` charges each call, and
|
|
21
22
|
* `signed` says the host signs LFS's links, so its uploads have upload rows to end.
|
|
22
23
|
*/
|
|
23
24
|
const lfsUpkeep = (rows, bucket, signed) => ({ repo, at }) => upkeepStep({
|
|
@@ -112,10 +113,11 @@ const dueUploads = /* @__PURE__ */ Effect.fnUntraced(function* (upkeep) {
|
|
|
112
113
|
}
|
|
113
114
|
});
|
|
114
115
|
const uploadOf = (row) => decodeRow(UploadRow, row, `LFS object ${row.id}'s upload`);
|
|
116
|
+
const listedOf = (row) => decodeRow(ListedRow, row, `LFS object ${row.id}`);
|
|
115
117
|
/**
|
|
116
|
-
* Drops each due upload row, read again at one version.
|
|
117
|
-
*
|
|
118
|
-
* staging keys, which their own rows end.
|
|
118
|
+
* Drops each due upload row, read again at one version. On a signed bucket, an object still
|
|
119
|
+
* unlisted, or listed at another key, gets its ending row in the same commit, then its bytes go; a
|
|
120
|
+
* Worker's bytes are at staging keys, which their own rows end.
|
|
119
121
|
*/
|
|
120
122
|
const endUploads = /* @__PURE__ */ Effect.fnUntraced(function* (upkeep, oids) {
|
|
121
123
|
const snapshot = yield* upkeep.rows.read(upkeep.repo, oids.flatMap((oid) => [uploadRead(oid), listedRead(oid)]));
|
|
@@ -123,13 +125,15 @@ const endUploads = /* @__PURE__ */ Effect.fnUntraced(function* (upkeep, oids) {
|
|
|
123
125
|
const ended = [];
|
|
124
126
|
for (const [index, oid] of oids.entries()) {
|
|
125
127
|
const uploadRow = snapshot.results[index * 2]?.[0];
|
|
126
|
-
const
|
|
128
|
+
const listedRow = snapshot.results[index * 2 + 1]?.[0];
|
|
127
129
|
const upload = uploadRow === void 0 ? void 0 : yield* uploadOf(uploadRow);
|
|
128
130
|
if (upload === void 0 || upload.removeAt > upkeep.at) continue;
|
|
129
131
|
dropped.push(oid);
|
|
130
|
-
|
|
132
|
+
const key = objectKey(upkeep.repo, oid, upload.generation);
|
|
133
|
+
const listed = listedRow === void 0 ? void 0 : yield* listedOf(listedRow);
|
|
134
|
+
if (upkeep.signed && listed?.key !== key) ended.push({
|
|
131
135
|
...endingKey(oid, upload.generation),
|
|
132
|
-
key
|
|
136
|
+
key
|
|
133
137
|
});
|
|
134
138
|
}
|
|
135
139
|
if (dropped.length === 0) return did;
|
package/dist/lfs/wire.mjs
CHANGED
|
@@ -2,8 +2,8 @@ import { fail, httpStatus } from "../contracts/result.mjs";
|
|
|
2
2
|
import { decodeJson } from "../protocol/wire/json.mjs";
|
|
3
3
|
import { boundedBytes } from "../protocol/bytes/reader.mjs";
|
|
4
4
|
import { brokenRead, endedEarly, readBody } from "../store/errors.mjs";
|
|
5
|
-
import * as Schema from "effect/Schema";
|
|
6
5
|
import * as Effect from "effect/Effect";
|
|
6
|
+
import * as Schema from "effect/Schema";
|
|
7
7
|
import * as Result from "effect/Result";
|
|
8
8
|
// src/lfs/wire.ts
|
|
9
9
|
/**
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { BufferError, BufferMeter } from "./buffers.mjs";
|
|
2
|
-
import * as Schema from "effect/Schema";
|
|
3
2
|
import * as Effect from "effect/Effect";
|
|
3
|
+
import * as Schema from "effect/Schema";
|
|
4
4
|
import * as Scope from "effect/Scope";
|
|
5
5
|
/**
|
|
6
6
|
* One zlib member deflated at a time, as a pack holds one per entry, at zlib's defaults: level 6,
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { allotOrFail, allotScoped, capacityOf } from "./buffers.mjs";
|
|
2
|
-
import * as Schema from "effect/Schema";
|
|
3
2
|
import * as Effect from "effect/Effect";
|
|
3
|
+
import * as Schema from "effect/Schema";
|
|
4
4
|
import untyped from "pako/lib/zlib/deflate.js";
|
|
5
5
|
// src/protocol/bytes/deflate.ts
|
|
6
6
|
/**
|
|
@@ -33,8 +33,7 @@ const nodeHmac = (createHmac, key) => {
|
|
|
33
33
|
hmac.update(bytes);
|
|
34
34
|
},
|
|
35
35
|
digest: async () => Uint8Array.from(hmac.digest()),
|
|
36
|
-
abandon: () => void 0
|
|
37
|
-
via: "createHmac"
|
|
36
|
+
abandon: () => void 0
|
|
38
37
|
};
|
|
39
38
|
};
|
|
40
39
|
/**
|
|
@@ -59,8 +58,7 @@ const streamedHmac = async (DigestStream, key) => {
|
|
|
59
58
|
abandon: () => {
|
|
60
59
|
stream.digest.catch(() => void 0);
|
|
61
60
|
writer.abort().catch(() => void 0);
|
|
62
|
-
}
|
|
63
|
-
via: "DigestStream"
|
|
61
|
+
}
|
|
64
62
|
};
|
|
65
63
|
};
|
|
66
64
|
/** An `HmacSha256` through `Sha256`, in JavaScript. */
|
|
@@ -76,8 +74,7 @@ const scriptHmac = (key) => {
|
|
|
76
74
|
outer.update(digestOf(inner));
|
|
77
75
|
return digestOf(outer);
|
|
78
76
|
},
|
|
79
|
-
abandon: () => void 0
|
|
80
|
-
via: "Sha256"
|
|
77
|
+
abandon: () => void 0
|
|
81
78
|
};
|
|
82
79
|
};
|
|
83
80
|
/** An `HmacSha256` under `key`, through the first `on` has: `createHmac`, `DigestStream`, `Sha256`. */
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import * as Schema from "effect/Schema";
|
|
2
1
|
import * as Effect from "effect/Effect";
|
|
2
|
+
import * as Schema from "effect/Schema";
|
|
3
3
|
import * as Result from "effect/Result";
|
|
4
4
|
import * as Scope from "effect/Scope";
|
|
5
5
|
/** The bytes an inflater keeps between calls, at most: its window, its tables and its state. */
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import * as Schema from "effect/Schema";
|
|
2
1
|
import * as Effect from "effect/Effect";
|
|
2
|
+
import * as Schema from "effect/Schema";
|
|
3
3
|
/**
|
|
4
4
|
* A SHA-1's state between writes: its five words, the bytes it took, and the bytes past its last
|
|
5
5
|
* whole 64-byte block, as lowercase hex, as many as `length` leaves past a block. Decode stored state through it, so a damaged one fails by
|
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
import * as Schema from "effect/Schema";
|
|
2
1
|
import * as Effect from "effect/Effect";
|
|
3
|
-
import * as
|
|
2
|
+
import * as Schema from "effect/Schema";
|
|
4
3
|
import * as Result from "effect/Result";
|
|
4
|
+
import * as Hex from "effect/encoding/Hex";
|
|
5
5
|
// src/protocol/bytes/sha1.ts
|
|
6
6
|
/**
|
|
7
7
|
* SHA-1, as FIPS 180-4 defines it, written a piece at a time, whose state is plain data: a pack's
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import { Allotment, GitObject, ObjectsRead } from "../../contracts/objects.mjs";
|
|
2
2
|
import { Oid } from "../../contracts/ids.mjs";
|
|
3
3
|
import "../objects/tree.mjs";
|
|
4
|
-
import * as Schema from "effect/Schema";
|
|
5
4
|
import * as Effect from "effect/Effect";
|
|
5
|
+
import * as Schema from "effect/Schema";
|
|
6
6
|
/**
|
|
7
7
|
* How a diff reads objects: through a caller's reader, every read counted, every object drained
|
|
8
8
|
* once and checked against its size and type, and every byte decoded charged to the diff's limits.
|
|
@@ -5,8 +5,8 @@ import { emptyTree } from "../objects/object.mjs";
|
|
|
5
5
|
import { decodeTag } from "../objects/tag.mjs";
|
|
6
6
|
import { parseTreeBytes, treeEntriesIn } from "../objects/tree.mjs";
|
|
7
7
|
import { tryUnlessSpent } from "../../contracts/calls-spent.mjs";
|
|
8
|
-
import * as Schema from "effect/Schema";
|
|
9
8
|
import * as Effect from "effect/Effect";
|
|
9
|
+
import * as Schema from "effect/Schema";
|
|
10
10
|
// src/protocol/diff/read.ts
|
|
11
11
|
const mebibyte = 1048576;
|
|
12
12
|
/**
|
|
@@ -34,7 +34,7 @@ export interface PairedChanges {
|
|
|
34
34
|
readonly renamesSkipped?: RenamesSkipped;
|
|
35
35
|
}
|
|
36
36
|
/** Two trees' changes, as `git diff --find-renames` lists them, or without renames when off. */
|
|
37
|
-
export declare const walkTrees: <E>(input: WireDiffInput<E>) => Effect.Effect<PairedChanges,
|
|
37
|
+
export declare const walkTrees: <E>(input: WireDiffInput<E>) => Effect.Effect<PairedChanges, E | DiffError, never>;
|
|
38
38
|
/** Each change's lines, as numstat counts them, within one reader's limits. */
|
|
39
39
|
export declare const countLines: <E, E2>(changes: ReadonlyArray<TreeChange>, read: DiffRead<E>, count: LineCounter<E2>, limits?: DiffLimits, tally?: ReadTally) => Effect.Effect<ReadonlyArray<LineCount>, DiffError | E | E2>;
|
|
40
40
|
/** Changes with renames paired among their deletions and additions, as `pairRecords` pairs them. */
|
|
@@ -82,13 +82,13 @@ const flattened = (slot, into) => {
|
|
|
82
82
|
* one `reader.prefetch`, and each folder's records go in a slot where it stands, so the list
|
|
83
83
|
* keeps Git's order. Without a batch, each tree is read on its own, in the same order.
|
|
84
84
|
*/
|
|
85
|
-
const walkRecords =
|
|
85
|
+
const walkRecords = /* @__PURE__ */ Effect.fnUntraced(function* (reader, base, head) {
|
|
86
86
|
const pathOf = (prefix, name) => prefix === void 0 ? Effect.succeed(name) : Effect.map(reader.charge(prefix.length + 1 + name.length), () => joinedBytes([
|
|
87
87
|
prefix,
|
|
88
88
|
slash,
|
|
89
89
|
name
|
|
90
90
|
]));
|
|
91
|
-
const whole = (entries, prefix, side, slot, next)
|
|
91
|
+
const whole = Effect.fnUntraced(function* (entries, prefix, side, slot, next) {
|
|
92
92
|
for (const entry of entries) {
|
|
93
93
|
const path = yield* pathOf(prefix, entry.name);
|
|
94
94
|
if (isFolder(entry)) {
|
|
@@ -103,7 +103,7 @@ const walkRecords = (reader, base, head) => Effect.gen(function* () {
|
|
|
103
103
|
} else slot.items.push(side(path, entry));
|
|
104
104
|
}
|
|
105
105
|
});
|
|
106
|
-
const walk = (before, after, prefix, slot, next)
|
|
106
|
+
const walk = Effect.fnUntraced(function* (before, after, prefix, slot, next) {
|
|
107
107
|
let x = 0;
|
|
108
108
|
let y = 0;
|
|
109
109
|
const below = (folder) => {
|
|
@@ -177,7 +177,7 @@ const walkRecords = (reader, base, head) => Effect.gen(function* () {
|
|
|
177
177
|
level = next;
|
|
178
178
|
}
|
|
179
179
|
return flattened(root, []);
|
|
180
|
-
})
|
|
180
|
+
}, (effect, reader) => Effect.ensuring(effect, Effect.sync(() => reader.forgetTrees())));
|
|
181
181
|
const mebibyte = 1048576;
|
|
182
182
|
/**
|
|
183
183
|
* The most a diff that pairs renames keeps (Q615): its walk's records and the pass's own state for
|
|
@@ -286,7 +286,7 @@ const byNameOf = (sides) => {
|
|
|
286
286
|
* `memory-limit`, as it does when the records alone pass `diffKeptMost`, after the first pass.
|
|
287
287
|
* Git has no such bound, and would go on.
|
|
288
288
|
*/
|
|
289
|
-
const pairRecords = (reader, records, options = {})
|
|
289
|
+
const pairRecords = /* @__PURE__ */ Effect.fnUntraced(function* (reader, records, options = {}) {
|
|
290
290
|
const minimum = options.minimumScore || 3e4;
|
|
291
291
|
const limit = options.renameLimit ?? 1e3;
|
|
292
292
|
const relevant = options.relevant ?? (() => true);
|
|
@@ -379,7 +379,7 @@ const pairRecords = (reader, records, options = {}) => Effect.gen(function* () {
|
|
|
379
379
|
if (text === void 0) return void 0;
|
|
380
380
|
return text ? sets.text : sets.binary;
|
|
381
381
|
};
|
|
382
|
-
const spansFor =
|
|
382
|
+
const spansFor = Effect.fnUntraced(function* (side) {
|
|
383
383
|
const { oid } = side.object;
|
|
384
384
|
const scored = yield* classOf(side);
|
|
385
385
|
const known = setsFor(oid, scored);
|
|
@@ -410,7 +410,7 @@ const pairRecords = (reader, records, options = {}) => Effect.gen(function* () {
|
|
|
410
410
|
set.set(oid, made);
|
|
411
411
|
return made;
|
|
412
412
|
});
|
|
413
|
-
const scored = (source, target, least)
|
|
413
|
+
const scored = Effect.fnUntraced(function* (source, target, least) {
|
|
414
414
|
const one = yield* reader.sizeOf(source.object.oid);
|
|
415
415
|
const two = yield* reader.sizeOf(target.object.oid);
|
|
416
416
|
if (!sizesAllow(one, two, least)) return void 0;
|
|
@@ -502,7 +502,7 @@ const placed = (records, pairs, taken) => records.flatMap((record, at) => {
|
|
|
502
502
|
const bigFileBytes = 536870912;
|
|
503
503
|
const empty = /* @__PURE__ */ new Uint8Array();
|
|
504
504
|
/** A side's bytes as a diff reads them, a gitlink's as Git writes one, or `big` past the threshold. */
|
|
505
|
-
const sideOf =
|
|
505
|
+
const sideOf = /* @__PURE__ */ Effect.fnUntraced(function* (reader, side) {
|
|
506
506
|
if (side === void 0) return empty;
|
|
507
507
|
if (side.mode === "160000") return encoder.encode(`Subproject commit ${side.oid}\n`);
|
|
508
508
|
if ((yield* reader.sizeOf(side.oid)) > 536870912) return "big";
|
|
@@ -513,7 +513,7 @@ const sideOf = (reader, side) => Effect.gen(function* () {
|
|
|
513
513
|
* first 8,000 bytes. Both sides are read, so a binary file diffs as binary even when its two
|
|
514
514
|
* sides are the same object, as numstat counts an exact rename's.
|
|
515
515
|
*/
|
|
516
|
-
const sidesOf =
|
|
516
|
+
const sidesOf = /* @__PURE__ */ Effect.fnUntraced(function* (reader, record) {
|
|
517
517
|
const one = yield* sideOf(reader, record.old);
|
|
518
518
|
const two = record.new !== void 0 && record.old !== void 0 && record.new.oid === record.old.oid && record.new.mode === record.old.mode ? one : yield* sideOf(reader, record.new);
|
|
519
519
|
if (one === "big" || two === "big" || isBinary(one) || isBinary(two)) return "binary";
|
|
@@ -526,7 +526,7 @@ const sidesOf = (reader, record) => Effect.gen(function* () {
|
|
|
526
526
|
* A record's lines as numstat counts them: one diff of its two sides, a type change's too, or
|
|
527
527
|
* `binary`.
|
|
528
528
|
*/
|
|
529
|
-
const lineCount =
|
|
529
|
+
const lineCount = /* @__PURE__ */ Effect.fnUntraced(function* (reader, count, record) {
|
|
530
530
|
const sides = yield* sidesOf(reader, record);
|
|
531
531
|
if (sides === "binary") return sides;
|
|
532
532
|
return yield* count(sides.one, sides.two);
|
|
@@ -591,7 +591,7 @@ const changesOf = (paired) => {
|
|
|
591
591
|
};
|
|
592
592
|
};
|
|
593
593
|
/** Two trees' changes, as `git diff --find-renames` lists them, or without renames when off. */
|
|
594
|
-
const walkTrees =
|
|
594
|
+
const walkTrees = /* @__PURE__ */ Effect.fnUntraced(function* (input) {
|
|
595
595
|
const reader = new DiffReader(input.read, input.limits, input.tally, input.batch);
|
|
596
596
|
const walked = yield* walkRecords(reader, input.base, input.head);
|
|
597
597
|
if (input.renames === false) return { changes: walked.map(changeOf) };
|