@ref0/git 0.12.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/access/private-refs.mjs +3 -3
- package/dist/auth/access-jwt.mjs +2 -2
- package/dist/auth/auth.d.mts +2 -2
- package/dist/auth/auth.mjs +3 -6
- package/dist/auth/authorize.mjs +4 -20
- 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/helpers.mjs +3 -11
- package/dist/auth/host-function.mjs +18 -1
- package/dist/auth/host-services.mjs +11 -0
- package/dist/auth/identify.d.mts +1 -1
- package/dist/auth/identify.mjs +3 -3
- package/dist/auth/policy.d.mts +27 -7
- package/dist/auth/policy.mjs +8 -4
- 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 -28
- package/dist/auth/tokens-layer.mjs +6 -12
- package/dist/auth/tokens-public.d.mts +3 -3
- package/dist/auth/tokens.d.mts +7 -17
- package/dist/auth/tokens.mjs +9 -87
- package/dist/auth.d.mts +1 -4
- package/dist/auth.mjs +1 -3
- package/dist/client/answer.mjs +21 -42
- package/dist/client/client.d.mts +2 -4
- package/dist/client/git-http.mjs +35 -11
- package/dist/client/local.mjs +14 -13
- package/dist/client/push-upload.mjs +39 -12
- package/dist/client/remote.mjs +95 -31
- 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/access.d.mts +8 -8
- package/dist/contracts/actors.d.mts +2 -34
- package/dist/contracts/blobs.d.mts +57 -10
- 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 +23 -19
- package/dist/contracts/commits.d.mts +34 -26
- package/dist/contracts/commits.mjs +9 -1
- package/dist/contracts/engine.d.mts +6 -1
- package/dist/contracts/engine.mjs +10 -1
- package/dist/contracts/files.d.mts +12 -12
- package/dist/contracts/forks.d.mts +27 -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 +39 -7
- package/dist/contracts/git.mjs +3 -2
- package/dist/contracts/grants.d.mts +24 -4
- package/dist/contracts/handlers.d.mts +1 -1
- package/dist/contracts/lfs.d.mts +28 -9
- package/dist/contracts/merges.d.mts +3 -2
- package/dist/contracts/objects.d.mts +103 -35
- package/dist/contracts/operations.d.mts +3 -0
- package/dist/contracts/operations.mjs +12 -2
- package/dist/contracts/push-uploads.d.mts +44 -5
- package/dist/contracts/push-uploads.mjs +7 -3
- package/dist/contracts/queue.d.mts +40 -12
- package/dist/contracts/queue.mjs +3 -4
- package/dist/contracts/refs.d.mts +50 -25
- package/dist/contracts/remote.d.mts +6 -7
- package/dist/contracts/remote.mjs +5 -4
- package/dist/contracts/repo-records.d.mts +1 -0
- package/dist/contracts/repos.d.mts +106 -127
- package/dist/contracts/repos.mjs +33 -4
- package/dist/contracts/result.d.mts +49 -25
- package/dist/contracts/result.mjs +52 -11
- package/dist/contracts/rules.d.mts +22 -22
- package/dist/contracts/server.d.mts +37 -111
- package/dist/contracts/services.d.mts +1 -1
- package/dist/contracts/signin.d.mts +1 -1
- package/dist/contracts/store.d.mts +6 -5
- package/dist/contracts/sync.d.mts +90 -26
- package/dist/contracts/sync.mjs +45 -11
- 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 -22
- package/dist/contracts/tokens.mjs +3 -3
- package/dist/contracts/topics.d.mts +1 -6
- package/dist/contracts/trees.d.mts +12 -12
- package/dist/contracts/work.d.mts +87 -12
- package/dist/contracts/work.mjs +8 -1
- package/dist/core/access.d.mts +1 -2
- package/dist/core/access.mjs +46 -13
- package/dist/core/ancestry.d.mts +10 -0
- package/dist/core/ancestry.mjs +6 -6
- package/dist/core/asked.mjs +43 -5
- package/dist/core/call-names.mjs +7 -1
- package/dist/core/call-services.mjs +13 -4
- package/dist/core/events/deliver.d.mts +1 -2
- package/dist/core/events/deliver.mjs +48 -33
- package/dist/core/events/retired.mjs +119 -0
- package/dist/core/forks.mjs +931 -435
- package/dist/core/hooks/groups.mjs +1 -1
- package/dist/core/imports.mjs +159 -15
- package/dist/core/index-job.mjs +128 -37
- package/dist/core/index-lost.d.mts +1 -2
- package/dist/core/index-lost.mjs +2 -2
- package/dist/core/job-view.mjs +8 -9
- package/dist/core/loose-tally.mjs +1 -1
- package/dist/core/mirror-rows.mjs +19 -4
- package/dist/core/objects/blobs.mjs +129 -3
- package/dist/core/objects/commits.mjs +16 -6
- 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 +10 -6
- package/dist/core/parts.mjs +3 -11
- package/dist/core/promise.mjs +9 -12
- package/dist/core/purge.mjs +316 -42
- package/dist/core/push-decide.mjs +3 -1
- package/dist/core/push-files.d.mts +12 -0
- package/dist/core/push-files.mjs +225 -0
- package/dist/core/push-repo.d.mts +8 -0
- package/dist/core/push-repo.mjs +56 -0
- package/dist/core/push.d.mts +17 -0
- package/dist/core/push.mjs +153 -70
- package/dist/core/receipts.mjs +34 -13
- package/dist/core/ref-index-job.mjs +4 -4
- package/dist/core/ref-view.mjs +61 -7
- package/dist/core/refs.mjs +18 -13
- package/dist/core/registered-rows.mjs +2 -2
- package/dist/core/repack.mjs +46 -28
- package/dist/core/repo-info.mjs +19 -12
- package/dist/core/repos.mjs +50 -22
- 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.d.mts +6 -0
- package/dist/core/view.mjs +51 -26
- package/dist/core/work.mjs +105 -35
- package/dist/effect.d.mts +5 -12
- package/dist/effect.mjs +3 -10
- package/dist/engine/failures.mjs +2 -1
- package/dist/engine/reads.mjs +17 -10
- package/dist/engine/walk.mjs +4 -4
- 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 +3 -3
- package/dist/event-streams/stream.mjs +38 -15
- package/dist/extend.d.mts +4 -5
- package/dist/extend.mjs +3 -2
- package/dist/http/answers.mjs +12 -7
- package/dist/http/core-parts.mjs +129 -64
- package/dist/http/handler.mjs +36 -9
- package/dist/http/node.d.mts +14 -1
- package/dist/http/node.mjs +61 -31
- package/dist/http/parts.d.mts +2 -0
- package/dist/http/push-upload-job.mjs +507 -0
- package/dist/http/push-uploads.d.mts +1 -0
- package/dist/http/push-uploads.mjs +142 -69
- package/dist/http/upload-pack.mjs +10 -9
- package/dist/index.d.mts +27 -28
- package/dist/index.mjs +5 -8
- package/dist/lfs/answer.mjs +37 -0
- package/dist/lfs/base.d.mts +9 -3
- package/dist/lfs/base.mjs +27 -2
- package/dist/lfs/copy.d.mts +60 -0
- package/dist/lfs/copy.mjs +109 -0
- package/dist/lfs/layer.d.mts +15 -1
- package/dist/lfs/layer.mjs +28 -13
- package/dist/lfs/locks.mjs +2 -2
- package/dist/lfs/objects.d.mts +7 -0
- package/dist/lfs/objects.mjs +152 -55
- package/dist/lfs/pointers.mjs +2 -2
- package/dist/lfs/rows.d.mts +13 -0
- package/dist/lfs/rows.mjs +42 -8
- package/dist/lfs/service.d.mts +1 -7
- package/dist/lfs/service.mjs +1 -9
- package/dist/lfs/upkeep.mjs +48 -14
- package/dist/lfs/upload-most.mjs +5 -5
- package/dist/lfs/wire.mjs +6 -31
- package/dist/merges/merges.mjs +2 -2
- package/dist/node.d.mts +3 -3
- package/dist/protocol/bytes/buffers.mjs +13 -5
- package/dist/protocol/bytes/reader.mjs +6 -1
- package/dist/protocol/bytes/sha256-hasher.d.mts +15 -0
- package/dist/protocol/bytes/sha256.d.mts +32 -0
- package/dist/protocol/bytes/sha256.mjs +105 -49
- 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/protocol/wire/advertisement.mjs +9 -4
- package/dist/protocol/wire/lines.d.mts +4 -2
- package/dist/protocol/wire/lines.mjs +11 -5
- package/dist/protocol/wire/push-uploads.mjs +13 -1
- package/dist/protocol/wire/v2.mjs +2 -2
- package/dist/protocol.d.mts +3 -1
- package/dist/protocol.mjs +3 -1
- package/dist/queue/advance.mjs +22 -25
- 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 +2 -22
- package/dist/queue/host.mjs +2 -13
- package/dist/queue/layer.d.mts +2 -1
- package/dist/queue/layer.mjs +11 -4
- 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 +6 -4
- package/dist/rest/blobs.mjs +29 -5
- package/dist/rest/caller.d.mts +4 -4231
- package/dist/rest/caller.mjs +5 -1
- package/dist/rest/client.d.mts +15 -5
- package/dist/rest/client.mjs +23 -2
- package/dist/rest/events.mjs +1 -2
- package/dist/rest/handler.mjs +4 -57
- package/dist/rest/handlers.mjs +68 -9
- package/dist/rest/layer.d.mts +2 -2
- package/dist/rest/layer.mjs +7 -13
- package/dist/rest/me.d.mts +3 -428
- package/dist/rest/paths.mjs +1 -0
- package/dist/rest/work.mjs +8 -0
- package/dist/server/check-fetch.mjs +3 -3
- package/dist/server/edge-node.d.mts +14 -15
- package/dist/server/edge-node.mjs +12 -12
- 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 +6 -11
- package/dist/server/git-layer.mjs +29 -23
- package/dist/server/git-namespace.d.mts +5 -4
- package/dist/server/git-namespace.mjs +3 -2
- package/dist/server/joined.d.mts +21 -40
- package/dist/server/joined.mjs +11 -62
- package/dist/server/lifecycle.mjs +65 -69
- package/dist/server/registry.mjs +28 -3
- package/dist/server/server.mjs +245 -465
- 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/{core/purge.d.mts → storage/batches.d.mts} +4 -4
- package/dist/storage/batches.mjs +344 -0
- package/dist/storage/budget.mjs +2 -2
- 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 +85 -19
- package/dist/storage/counted-bucket.mjs +4 -4
- package/dist/storage/fetch.d.mts +1 -0
- package/dist/storage/fetch.mjs +298 -216
- package/dist/storage/file-limits.mjs +24 -0
- 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 +1 -1
- package/dist/storage/index-build.mjs +185 -84
- package/dist/storage/index-fetch.mjs +128 -74
- 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-reach.mjs +33 -5
- package/dist/storage/index-remap.mjs +208 -65
- package/dist/storage/index-shallow.mjs +5 -3
- package/dist/storage/index-whole.mjs +127 -0
- package/dist/storage/largest-files.mjs +48 -0
- package/dist/storage/layout.mjs +23 -0
- package/dist/storage/lfs-pointers.mjs +10 -1
- package/dist/storage/loose.d.mts +7 -4
- package/dist/storage/loose.mjs +214 -67
- package/dist/storage/memory-budget.mjs +44 -8
- 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 +165 -49
- package/dist/storage/pack-receive.d.mts +1 -1
- package/dist/storage/pack-receive.mjs +85 -27
- package/dist/storage/packs.d.mts +1 -1
- package/dist/storage/packs.mjs +172 -86
- 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 +299 -37
- package/dist/storage/prune-walk.mjs +240 -62
- package/dist/storage/prune.mjs +749 -213
- package/dist/storage/push-allotment.mjs +91 -12
- package/dist/storage/push-uploads.mjs +40 -16
- package/dist/storage/pushed-commits.mjs +4 -2
- package/dist/storage/quarantine.d.mts +1 -1
- package/dist/storage/quarantine.mjs +9 -9
- package/dist/storage/range-cache.mjs +125 -8
- package/dist/storage/ready.d.mts +1 -1
- package/dist/storage/ready.mjs +55 -25
- package/dist/storage/receive-bounds.mjs +51 -15
- package/dist/storage/receive-state.mjs +8 -0
- package/dist/storage/receive-steps.mjs +71 -18
- package/dist/storage/repack-backlog.mjs +6 -3
- package/dist/storage/repack.d.mts +2 -2
- package/dist/storage/repack.mjs +1 -8
- package/dist/storage/rows.d.mts +1 -1
- package/dist/storage/rows.mjs +13 -2
- 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/shallow.d.mts +1 -0
- package/dist/storage/shallow.mjs +26 -4
- package/dist/storage/single-flight.mjs +13 -7
- package/dist/storage/stream-whole.mjs +132 -28
- package/dist/storage/unpack.mjs +371 -79
- package/dist/storage/visible.mjs +31 -3
- package/dist/storage/walk.mjs +194 -39
- 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 +146 -35
- package/dist/store/crossing.mjs +1 -3
- package/dist/store/cursor-seal-namespace.d.mts +2 -0
- package/dist/store/cursor-seal-public.d.mts +5 -0
- package/dist/store/cursor-seal-public.mjs +5 -0
- package/dist/store/cursor-seal.d.mts +16 -3
- package/dist/store/cursor-seal.mjs +40 -18
- package/dist/store/door.mjs +183 -0
- package/dist/store/errors.d.mts +3 -4
- package/dist/store/errors.mjs +24 -34
- 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 +5 -0
- package/dist/store/records.mjs +12 -6
- package/dist/store/repo-record.d.mts +10 -9
- package/dist/store/repo-record.mjs +123 -28
- package/dist/store/reservations.mjs +1 -1
- package/dist/store/scopes.mjs +21 -2
- package/dist/store/settle.mjs +4 -4
- package/dist/sync/bound.d.mts +2 -0
- package/dist/sync/bound.mjs +11 -2
- package/dist/sync/github.d.mts +6 -1
- package/dist/sync/github.mjs +56 -44
- package/dist/sync/http.mjs +36 -1
- package/dist/sync/import.mjs +32 -18
- package/dist/sync/layer.mjs +6 -2
- package/dist/sync/lfs-batch.mjs +118 -0
- package/dist/sync/lfs-copy.mjs +262 -0
- package/dist/sync/mirror.mjs +227 -151
- package/dist/sync/said.mjs +16 -37
- package/dist/sync/smart-http.mjs +4 -2
- package/dist/sync/step.mjs +58 -30
- package/dist/sync/tries.mjs +52 -21
- package/dist/sync.d.mts +2 -2
- 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 +2 -20
- package/dist/topics/layer.d.mts +4 -9
- package/dist/topics/layer.mjs +3 -4
- 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 -9
- package/dist/auth/bridge.mjs +0 -30
- package/dist/auth/helpers.d.mts +0 -17
- 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/core/registered-rows.d.mts +0 -5
- package/dist/core/repack.d.mts +0 -11
- package/dist/http/handler.d.mts +0 -2
- package/dist/lfs/calls.mjs +0 -26
- package/dist/rest/api.d.mts +0 -23
- package/dist/rest/blobs.d.mts +0 -825
- package/dist/rest/commits.d.mts +0 -3510
- package/dist/rest/errors.d.mts +0 -2104
- package/dist/rest/events.d.mts +0 -423
- package/dist/rest/files.d.mts +0 -1330
- package/dist/rest/forks.d.mts +0 -2136
- package/dist/rest/handler.d.mts +0 -21
- package/dist/rest/handlers.d.mts +0 -8
- package/dist/rest/merges.d.mts +0 -473
- package/dist/rest/queue.d.mts +0 -5861
- package/dist/rest/refs.d.mts +0 -2959
- package/dist/rest/repos.d.mts +0 -2539
- package/dist/rest/tags.d.mts +0 -1304
- package/dist/rest/tokens.d.mts +0 -2590
- package/dist/rest/topics.d.mts +0 -2204
- package/dist/rest/trees.d.mts +0 -1693
- package/dist/rest/work.d.mts +0 -1248
- package/dist/rest.d.mts +0 -2
- package/dist/rest.mjs +0 -1
- package/dist/server/lifecycle.d.mts +0 -2
- package/dist/server/registry.d.mts +0 -16
- package/dist/server/server.d.mts +0 -36
- package/dist/storage/repack-job.d.mts +0 -3
- package/dist/store/promises.d.mts +0 -11
- package/dist/store/promises.mjs +0 -327
- package/dist/topics/host.d.mts +0 -7
package/dist/lfs/objects.mjs
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { dropBody } from "../protocol/bytes/reader.mjs";
|
|
2
2
|
import { gathered } from "../protocol/bytes/streams.mjs";
|
|
3
3
|
import { contended, openFor } from "../core/access.mjs";
|
|
4
4
|
import { ownWriter } from "../core/own-writes.mjs";
|
|
@@ -9,16 +9,19 @@ import { utf8 } from "../protocol/bytes/text.mjs";
|
|
|
9
9
|
import { objectId } from "../protocol/objects/object.mjs";
|
|
10
10
|
import { bestEffort, decodeRow } from "../store/errors.mjs";
|
|
11
11
|
import { randomText } from "../store/random.mjs";
|
|
12
|
+
import { bodyUntilAborted } from "../store/bodies.mjs";
|
|
12
13
|
import { bucketCall, bucketDo, bucketFailed, bucketStream } from "../storage/calls.mjs";
|
|
14
|
+
import { CallBudget } from "../store/call-count.mjs";
|
|
13
15
|
import { isLfsOid, lfsPointerText } from "../protocol/objects/lfs-pointer.mjs";
|
|
14
16
|
import { ListedRow, UploadRow, largestObject, lfsCollections, linkLife, listedKey, listedRead, objectKey, stagingId, stagingKey, stagingRead, streamMost, uploadGrace, uploadKey, uploadRead } from "./rows.mjs";
|
|
15
17
|
import { BatchRequest, VerifyRequest, batchMost, bodyOf, lfsAnswer } from "./wire.mjs";
|
|
16
18
|
import { uploadedRow } from "./uploaded.mjs";
|
|
17
19
|
import { pastMost, uploadPieceBytes } from "./upload-most.mjs";
|
|
18
20
|
import { fail, gitError, httpStatus } from "../contracts/result.mjs";
|
|
19
|
-
import * as Clock
|
|
21
|
+
import * as Clock from "effect/Clock";
|
|
20
22
|
import * as Effect from "effect/Effect";
|
|
21
23
|
import * as Option from "effect/Option";
|
|
24
|
+
import * as Result from "effect/Result";
|
|
22
25
|
import { Unavailable } from "@ref0/infra";
|
|
23
26
|
import * as Stream from "effect/Stream";
|
|
24
27
|
import * as DateTime from "effect/DateTime";
|
|
@@ -196,7 +199,7 @@ const downloads = /* @__PURE__ */ Effect.fnUntraced(function* (parts, call, repo
|
|
|
196
199
|
const chained = yield* chainListed(parts.rows, repo, oids);
|
|
197
200
|
const listed = yield* seenListed(call.caller, repo, oids, chained);
|
|
198
201
|
const refused = yield* refusedOf(call, listed);
|
|
199
|
-
const expiresAt = (yield* Clock
|
|
202
|
+
const expiresAt = (yield* Clock.currentTimeMillis) + linkLife;
|
|
200
203
|
const answers = /* @__PURE__ */ new Map();
|
|
201
204
|
for (const { oid, size } of objects) {
|
|
202
205
|
const row = listed.get(oid);
|
|
@@ -234,7 +237,7 @@ const downloads = /* @__PURE__ */ Effect.fnUntraced(function* (parts, call, repo
|
|
|
234
237
|
const uploads = /* @__PURE__ */ Effect.fnUntraced(function* (parts, call, repo, objects) {
|
|
235
238
|
const oids = objects.map(({ oid }) => oid);
|
|
236
239
|
for (let tries = 0; tries < 5; tries += 1) {
|
|
237
|
-
const at = yield* Clock
|
|
240
|
+
const at = yield* Clock.currentTimeMillis;
|
|
238
241
|
const asked = tries === 0 ? repo : void 0;
|
|
239
242
|
const read = yield* objectRows(parts.rows, call.caller, repo, oids, { asked });
|
|
240
243
|
const unseen = yield* unseenRows(call.caller, repo, oids, read.rows);
|
|
@@ -307,7 +310,7 @@ const verify = /* @__PURE__ */ Effect.fnUntraced(function* (parts, call) {
|
|
|
307
310
|
const repo = yield* openFor(call.caller, call.repo, true, void 0, "first-read");
|
|
308
311
|
const writer = yield* ownWriter(call.caller);
|
|
309
312
|
for (let tries = 0; tries < 5; tries += 1) {
|
|
310
|
-
const at = yield* Clock
|
|
313
|
+
const at = yield* Clock.currentTimeMillis;
|
|
311
314
|
const asked = tries === 0 ? repo : void 0;
|
|
312
315
|
const read = yield* objectRows(registered, call.caller, repo, [oid], { asked });
|
|
313
316
|
const rows = read.rows.get(oid);
|
|
@@ -337,9 +340,11 @@ const verify = /* @__PURE__ */ Effect.fnUntraced(function* (parts, call) {
|
|
|
337
340
|
return yield* contended();
|
|
338
341
|
});
|
|
339
342
|
/**
|
|
340
|
-
* `PUT objects/<oid>`, a Worker upload: streams the body to a staging key of its own
|
|
341
|
-
*
|
|
342
|
-
*
|
|
343
|
+
* `PUT objects/<oid>`, a Worker upload: streams the body to a staging key of its own, put with its
|
|
344
|
+
* oid as the SHA-256 the bucket checks, so the Worker never hashes it, and lists the object at that
|
|
345
|
+
* key once the bucket took it. A body that isn't its oid the bucket refuses, keeping nothing of it.
|
|
346
|
+
* Its staging row, added before a byte is written, has upkeep delete the bytes if they're never
|
|
347
|
+
* listed.
|
|
343
348
|
*/
|
|
344
349
|
const receive = /* @__PURE__ */ Effect.fnUntraced(function* (parts, call, oid) {
|
|
345
350
|
if (!isLfsOid(oid)) return yield* fail("INVALID_ARGUMENT", "An oid is a SHA-256, as 64 lowercase hex digits");
|
|
@@ -348,7 +353,7 @@ const receive = /* @__PURE__ */ Effect.fnUntraced(function* (parts, call, oid) {
|
|
|
348
353
|
if (length > parts.uploadMost.bytes) return lfsAnswer(413, { message: pastMost(parts.uploadMost) });
|
|
349
354
|
const { rows: registered, bucket } = parts;
|
|
350
355
|
const repo = yield* openFor(call.caller, call.repo, true, void 0, "first-read");
|
|
351
|
-
const started = yield* Clock
|
|
356
|
+
const started = yield* Clock.currentTimeMillis;
|
|
352
357
|
const read = yield* objectRows(registered, call.caller, repo, [oid], { asked: repo });
|
|
353
358
|
const rows = read.rows.get(oid);
|
|
354
359
|
const unseen = (yield* unseenRows(call.caller, repo, [oid], read.rows)).has(oid);
|
|
@@ -356,47 +361,70 @@ const receive = /* @__PURE__ */ Effect.fnUntraced(function* (parts, call, oid) {
|
|
|
356
361
|
const upload = rows?.upload;
|
|
357
362
|
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" });
|
|
358
363
|
if (upload.size > parts.uploadMost.bytes) return lfsAnswer(413, { message: pastMost(parts.uploadMost) });
|
|
359
|
-
const
|
|
360
|
-
|
|
361
|
-
const
|
|
362
|
-
|
|
363
|
-
|
|
364
|
-
|
|
365
|
-
|
|
366
|
-
|
|
367
|
-
|
|
368
|
-
|
|
369
|
-
|
|
370
|
-
|
|
371
|
-
|
|
372
|
-
});
|
|
373
|
-
const hashed = hashing(call.request.body, upload.size);
|
|
374
|
-
yield* Effect.uninterruptible(bucketDo(bucket.put(key, hashed.body, { size: upload.size }))).pipe(Effect.mapError((error) => hashed.past() ? pastSize(upload.size) : error));
|
|
375
|
-
if ((yield* hashed.hasher.hex) !== oid) {
|
|
376
|
-
yield* dropStaged(parts, repo.internalId, key, staged);
|
|
364
|
+
const [staging] = yield* stagedKeys(registered, repo.internalId, started + uploadGrace, 1);
|
|
365
|
+
if (staging === void 0) return yield* Effect.die(/* @__PURE__ */ new Error("One staging key asked, none made"));
|
|
366
|
+
const { key } = staging;
|
|
367
|
+
const sent = counted(call.request.body, upload.size);
|
|
368
|
+
const put = yield* Effect.result(Effect.uninterruptible(bucketDo(bucket.put(key, sent.body, {
|
|
369
|
+
size: upload.size,
|
|
370
|
+
sha256: oid
|
|
371
|
+
}))));
|
|
372
|
+
if (Result.isFailure(put)) {
|
|
373
|
+
if (sent.past()) return yield* Effect.fail(pastSize(upload.size));
|
|
374
|
+
if (sent.size() < upload.size) return yield* Effect.fail(shortSize(upload.size, sent.size()));
|
|
375
|
+
if (put.failure.code !== "INVALID_ARGUMENT") return yield* Effect.fail(put.failure);
|
|
376
|
+
yield* dropStaged(parts, repo.internalId, staging.row.id);
|
|
377
377
|
return yield* fail("INVALID_ARGUMENT", "The bytes' SHA-256 isn't the oid");
|
|
378
378
|
}
|
|
379
379
|
return yield* listStaged(registered, call.caller, repo, {
|
|
380
380
|
oid,
|
|
381
381
|
size: upload.size,
|
|
382
382
|
key,
|
|
383
|
-
staged,
|
|
383
|
+
staged: staging.row.id,
|
|
384
384
|
deadline: started + streamMost,
|
|
385
385
|
unseen
|
|
386
386
|
});
|
|
387
387
|
});
|
|
388
388
|
/**
|
|
389
|
-
*
|
|
390
|
-
*
|
|
391
|
-
*
|
|
389
|
+
* `count` staging keys in `repo`, each row added with upkeep's wake at `removeAt`: bytes put at a
|
|
390
|
+
* key that no commit lists by then are deleted, as `endStages` does. A Worker upload's: an import's
|
|
391
|
+
* copy stages a key per object, as `LfsCopy.stage` says.
|
|
392
|
+
*/
|
|
393
|
+
const stagedKeys = /* @__PURE__ */ Effect.fnUntraced(function* (rows, repo, removeAt, count) {
|
|
394
|
+
const staging = Array.from({ length: count }, () => {
|
|
395
|
+
const id = randomText(16);
|
|
396
|
+
return {
|
|
397
|
+
key: stagingKey(repo, id),
|
|
398
|
+
row: {
|
|
399
|
+
collection: lfsCollections.staging,
|
|
400
|
+
id: stagingId(removeAt, id)
|
|
401
|
+
}
|
|
402
|
+
};
|
|
403
|
+
});
|
|
404
|
+
if (staging.length === 0) return staging;
|
|
405
|
+
yield* rows.add(repo, {
|
|
406
|
+
put: staging.map(({ key, row }) => ({
|
|
407
|
+
...row,
|
|
408
|
+
value: {
|
|
409
|
+
key,
|
|
410
|
+
removeAt
|
|
411
|
+
}
|
|
412
|
+
})),
|
|
413
|
+
wake: removeAt
|
|
414
|
+
});
|
|
415
|
+
return staging;
|
|
416
|
+
});
|
|
417
|
+
/**
|
|
418
|
+
* Deletes the staging row of bytes the bucket refused, keeping none of them, at the version it's
|
|
419
|
+
* read at (#1940). A failure leaves the row, whose wake has upkeep delete its key at its removeAt,
|
|
420
|
+
* and is no reason to answer it in place of the refusal.
|
|
392
421
|
*/
|
|
393
|
-
const dropStaged = /* @__PURE__ */ Effect.fnUntraced(function* (parts, repo,
|
|
422
|
+
const dropStaged = /* @__PURE__ */ Effect.fnUntraced(function* (parts, repo, staged) {
|
|
394
423
|
const row = {
|
|
395
424
|
collection: lfsCollections.staging,
|
|
396
425
|
id: staged
|
|
397
426
|
};
|
|
398
427
|
yield* bestEffort(Effect.gen(function* () {
|
|
399
|
-
yield* bucketDo(parts.bucket.remove(key));
|
|
400
428
|
const read = yield* parts.rows.read(repo, [row]);
|
|
401
429
|
yield* parts.rows.commit(repo, read.version, { delete: [row] });
|
|
402
430
|
}));
|
|
@@ -410,22 +438,19 @@ const lengthOf = (request) => {
|
|
|
410
438
|
return Number.isSafeInteger(length) ? length : void 0;
|
|
411
439
|
};
|
|
412
440
|
const pastSize = (size) => gitError("INVALID_ARGUMENT", `The bytes run past the ${size} the batch named`);
|
|
441
|
+
const shortSize = (size, sent) => gitError("INVALID_ARGUMENT", `The bytes end at ${sent}, short of the ${size} the batch named`);
|
|
413
442
|
/**
|
|
414
443
|
* An answer to a request whose body isn't needed: the body is let go first, and a cancel that
|
|
415
444
|
* rejects is no reason to fail an upload that's done.
|
|
416
445
|
*/
|
|
417
|
-
const answered = (request) => Effect.
|
|
418
|
-
await request.body?.cancel();
|
|
419
|
-
return lfsAnswer(200, { message: "Already uploaded" });
|
|
420
|
-
});
|
|
446
|
+
const answered = (request) => Effect.as(dropBody(request.body), lfsAnswer(200, { message: "Already uploaded" }));
|
|
421
447
|
/**
|
|
422
|
-
* `body` as it streams to the bucket, gathered into pieces of `uploadPieceBytes
|
|
423
|
-
*
|
|
424
|
-
*
|
|
425
|
-
*
|
|
448
|
+
* `body` as it streams to the bucket, gathered into pieces of `uploadPieceBytes` and counted,
|
|
449
|
+
* failing past `most` bytes, or at its end short of them, before the bucket checks its hash. No
|
|
450
|
+
* piece reaches more than one byte past what `most` leaves, so a body that runs past it is read no
|
|
451
|
+
* further than that byte's chunk.
|
|
426
452
|
*/
|
|
427
|
-
const
|
|
428
|
-
const hasher = nativeSha256Hasher();
|
|
453
|
+
const counted = (body, most) => {
|
|
429
454
|
let size = 0;
|
|
430
455
|
const read = Stream.fromReadableStream({
|
|
431
456
|
evaluate: () => body === null ? new ReadableStream({ start: (controller) => controller.close() }) : gathered(body, (given) => Math.min(uploadPieceBytes, Math.max(1, most - given + 1))),
|
|
@@ -434,21 +459,23 @@ const hashing = (body, most) => {
|
|
|
434
459
|
cause
|
|
435
460
|
})
|
|
436
461
|
});
|
|
462
|
+
const sized = Stream.mapEffect(read, (chunk) => {
|
|
463
|
+
size += chunk.length;
|
|
464
|
+
if (size > most) return Effect.fail(pastSize(most));
|
|
465
|
+
return Effect.succeed(chunk);
|
|
466
|
+
});
|
|
467
|
+
const ended = Stream.suspend(() => size < most ? Stream.fail(shortSize(most, size)) : Stream.empty);
|
|
437
468
|
return {
|
|
438
|
-
body: Stream.
|
|
439
|
-
size += chunk.length;
|
|
440
|
-
if (size > most) return Effect.fail(pastSize(most));
|
|
441
|
-
return Effect.as(hasher.write(chunk), chunk);
|
|
442
|
-
}),
|
|
469
|
+
body: Stream.concat(sized, ended),
|
|
443
470
|
past: () => size > most,
|
|
444
|
-
|
|
471
|
+
size: () => size
|
|
445
472
|
};
|
|
446
473
|
};
|
|
447
474
|
/** Lists a Worker upload's bytes at their staging key, in the commit that drops its staging row. */
|
|
448
475
|
const listStaged = /* @__PURE__ */ Effect.fnUntraced(function* (registered, caller, repo, staged) {
|
|
449
476
|
const writer = yield* ownWriter(caller);
|
|
450
477
|
for (let tries = 0; tries < 5; tries += 1) {
|
|
451
|
-
const at = yield* Clock
|
|
478
|
+
const at = yield* Clock.currentTimeMillis;
|
|
452
479
|
const own = writer === void 0 ? [] : [uploadedRow(writer, staged.oid, at)];
|
|
453
480
|
const read = yield* objectRows(registered, caller, repo, [staged.oid], { also: [stagingRead(staged.staged)] });
|
|
454
481
|
if (read.rows.get(staged.oid)?.listed !== void 0) {
|
|
@@ -460,7 +487,7 @@ const listStaged = /* @__PURE__ */ Effect.fnUntraced(function* (registered, call
|
|
|
460
487
|
})).ok) return answer;
|
|
461
488
|
continue;
|
|
462
489
|
}
|
|
463
|
-
if ((read.also[0] ?? []).length === 0 || (yield* Clock
|
|
490
|
+
if ((read.also[0] ?? []).length === 0 || (yield* Clock.currentTimeMillis) > staged.deadline) return yield* fail("DEADLINE_EXCEEDED", "The upload ran too long", { hint: "Upload it again" });
|
|
464
491
|
if ((yield* registered.commit(repo.internalId, read.version, {
|
|
465
492
|
put: [{
|
|
466
493
|
...listedKey(staged.oid),
|
|
@@ -500,15 +527,85 @@ const objectOf = /* @__PURE__ */ Effect.fnUntraced(function* (parts, read) {
|
|
|
500
527
|
},
|
|
501
528
|
request: read.request
|
|
502
529
|
});
|
|
503
|
-
const
|
|
504
|
-
if (
|
|
505
|
-
const bytes = signal === void 0 ? stream : stream.pipeThrough(new TransformStream(), { signal });
|
|
530
|
+
const bytes = yield* Effect.uninterruptible(Effect.map(bucketStream(parts.bucket, listed.key), (stream) => stream === void 0 || signal === void 0 ? stream : bodyUntilAborted(stream, signal)));
|
|
531
|
+
if (bytes === void 0) return yield* fail("DATA_LOSS", `LFS object ${oid}'s bytes are missing`);
|
|
506
532
|
return {
|
|
507
533
|
oid,
|
|
508
534
|
size: listed.size,
|
|
509
535
|
bytes
|
|
510
536
|
};
|
|
511
537
|
});
|
|
538
|
+
/** `objectsOf`'s handle's refusal once its signal is aborted. */
|
|
539
|
+
const handleEnded = fail("FAILED_PRECONDITION", "The read of many LFS objects has ended", { context: { reason: "handle-ended" } });
|
|
540
|
+
/** Fails as `handleEnded` once `signal` is aborted, and waits until then. */
|
|
541
|
+
const endedBy = (signal) => Effect.callback((resume) => {
|
|
542
|
+
const end = () => resume(handleEnded);
|
|
543
|
+
if (signal.aborted) return end();
|
|
544
|
+
signal.addEventListener("abort", end, { once: true });
|
|
545
|
+
return Effect.sync(() => signal.removeEventListener("abort", end));
|
|
546
|
+
});
|
|
547
|
+
/**
|
|
548
|
+
* Many objects at once, for one caller: every read but the bytes' made before it answers, so a
|
|
549
|
+
* caller that must know its reads before it streams, as an archive's 200, knows them. It opens the
|
|
550
|
+
* repo once, lists the objects up the fork chain once, asks the caller's view of every pointer
|
|
551
|
+
* once and the host's fetch rules of each object it lists, each asked once. `readable` is what
|
|
552
|
+
* the caller may read, in the order asked, each once: an object no repo in the chain lists, of
|
|
553
|
+
* another size, unseen in a narrowed view or that a rule answers `NOT_FOUND` for is left out, and
|
|
554
|
+
* a rule's other refusal fails the call. `open` reads one of `readable`'s from the bucket, one call,
|
|
555
|
+
* in the budget the call was made in; it fails `FAILED_PRECONDITION` for an oid outside
|
|
556
|
+
* `readable`, which this call never answered may be read, or once `signal` is aborted, which
|
|
557
|
+
* also interrupts an open waiting for the bucket and cancels an opened stream. 1 to `batchMost`
|
|
558
|
+
* objects.
|
|
559
|
+
*/
|
|
560
|
+
const objectsOf = /* @__PURE__ */ Effect.fnUntraced(function* (parts, read) {
|
|
561
|
+
const { caller, signal } = read;
|
|
562
|
+
if (read.objects.length === 0 || read.objects.length > 1e3) return yield* fail("INVALID_ARGUMENT", `A read of many LFS objects names 1 to ${batchMost}`);
|
|
563
|
+
const repo = yield* openFor(caller, read.repo, false, read.internalId, "first-read");
|
|
564
|
+
const asked = read.objects.filter(({ oid, size }) => isLfsOid(oid) && validSize(size));
|
|
565
|
+
const oids = [...new Set(asked.map(({ oid }) => oid))];
|
|
566
|
+
const chained = yield* chainListed(parts.rows, repo, oids);
|
|
567
|
+
const listed = yield* seenListed(caller, repo, oids, chained);
|
|
568
|
+
const readable = /* @__PURE__ */ new Map();
|
|
569
|
+
const checked = /* @__PURE__ */ new Set();
|
|
570
|
+
for (const { oid, size } of asked) {
|
|
571
|
+
const row = listed.get(oid);
|
|
572
|
+
if (row === void 0 || row.size !== size || checked.has(oid)) continue;
|
|
573
|
+
checked.add(oid);
|
|
574
|
+
const target = {
|
|
575
|
+
kind: "lfs",
|
|
576
|
+
oid,
|
|
577
|
+
size: row.size
|
|
578
|
+
};
|
|
579
|
+
const refusal = yield* readRefusal(read.repo, {
|
|
580
|
+
caller,
|
|
581
|
+
target,
|
|
582
|
+
request: read.request
|
|
583
|
+
});
|
|
584
|
+
if (refusal?.code === "NOT_FOUND") continue;
|
|
585
|
+
if (refusal !== void 0) return yield* Effect.fail(refusal);
|
|
586
|
+
readable.set(oid, row);
|
|
587
|
+
}
|
|
588
|
+
const budget = yield* Effect.serviceOption(CallBudget);
|
|
589
|
+
const opened = (oid, row) => Effect.flatMap(Effect.uninterruptible(Effect.map(bucketStream(parts.bucket, row.key), (stream) => stream === void 0 ? void 0 : bodyUntilAborted(stream, signal))), (bytes) => bytes === void 0 ? fail("DATA_LOSS", `LFS object ${oid}'s bytes are missing`) : Effect.succeed({
|
|
590
|
+
oid,
|
|
591
|
+
size: row.size,
|
|
592
|
+
bytes
|
|
593
|
+
}));
|
|
594
|
+
const open = (oid) => Effect.suspend(() => {
|
|
595
|
+
if (signal.aborted) return handleEnded;
|
|
596
|
+
const row = readable.get(oid);
|
|
597
|
+
if (row === void 0) return fail("FAILED_PRECONDITION", `LFS object ${oid} isn't one this read may open`, { context: { reason: "not-readable" } });
|
|
598
|
+
const opening = Option.isSome(budget) ? Effect.provideService(opened(oid, row), CallBudget, budget.value) : opened(oid, row);
|
|
599
|
+
return Effect.raceFirst(opening, endedBy(signal));
|
|
600
|
+
});
|
|
601
|
+
return {
|
|
602
|
+
readable: [...readable].map(([oid, row]) => ({
|
|
603
|
+
oid,
|
|
604
|
+
size: row.size
|
|
605
|
+
})),
|
|
606
|
+
open
|
|
607
|
+
};
|
|
608
|
+
});
|
|
512
609
|
/**
|
|
513
610
|
* `GET objects/<oid>`, a Worker download: a listed object's bytes, the repo's own or a source's,
|
|
514
611
|
* as `objectOf` reads them. Its fetch rules are asked again, though the batch that gave the link
|
|
@@ -530,4 +627,4 @@ const send = /* @__PURE__ */ Effect.fnUntraced(function* (parts, call, oid) {
|
|
|
530
627
|
}
|
|
531
628
|
});
|
|
532
629
|
});
|
|
533
|
-
export { batch, listedOf, objectOf, receive, send, verify };
|
|
630
|
+
export { batch, listedOf, objectOf, objectsOf, receive, send, stagedKeys, verify };
|
package/dist/lfs/pointers.mjs
CHANGED
|
@@ -10,7 +10,7 @@ import { lfsPointerText } from "../protocol/objects/lfs-pointer.mjs";
|
|
|
10
10
|
import { lfsOidAt, lfsSizeAt, pointersOfBlob } from "../storage/lfs-pointers.mjs";
|
|
11
11
|
import { listedOf } from "./objects.mjs";
|
|
12
12
|
import { uploadedOf } from "./uploaded.mjs";
|
|
13
|
-
import * as Clock
|
|
13
|
+
import * as Clock from "effect/Clock";
|
|
14
14
|
import * as Effect from "effect/Effect";
|
|
15
15
|
// src/lfs/pointers.ts
|
|
16
16
|
/**
|
|
@@ -117,7 +117,7 @@ const unprovenOf = /* @__PURE__ */ Effect.fnUntraced(function* (rows, input, ent
|
|
|
117
117
|
const unseen = [...blobs].flatMap(([blob, oid]) => seen.has(blob) ? [] : [oid]);
|
|
118
118
|
if (unseen.length === 0) return unproven;
|
|
119
119
|
const writer = yield* ownWriter(input.caller);
|
|
120
|
-
const at = yield* Clock
|
|
120
|
+
const at = yield* Clock.currentTimeMillis;
|
|
121
121
|
const own = writer === void 0 ? /* @__PURE__ */ new Set() : yield* uploadedOf(rows, repo, writer, unseen, at);
|
|
122
122
|
for (const oid of unseen) if (!own.has(oid)) unproven.add(oid);
|
|
123
123
|
return unproven;
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import "../contracts/ids.mjs";
|
|
2
|
+
import * as Schema from "effect/Schema";
|
|
3
|
+
import { Key, Moment, Read } from "@ref0/infra";
|
|
4
|
+
/**
|
|
5
|
+
* A listed object: its bytes are at `key`, checked. A signed upload's are at its upload row's
|
|
6
|
+
* `objectKey`, and a Worker upload's stay at the staging key they streamed to, which only they
|
|
7
|
+
* were ever written to.
|
|
8
|
+
*/
|
|
9
|
+
export declare const ListedRow: Schema.Struct<{
|
|
10
|
+
readonly size: Schema.Int;
|
|
11
|
+
readonly key: Schema.String;
|
|
12
|
+
}>;
|
|
13
|
+
export type ListedRow = typeof ListedRow.Type;
|
package/dist/lfs/rows.mjs
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { millis } from "../contracts/
|
|
1
|
+
import { millis } from "../contracts/time.mjs";
|
|
2
2
|
import * as Schema from "effect/Schema";
|
|
3
3
|
// src/lfs/rows.ts
|
|
4
4
|
/**
|
|
@@ -13,9 +13,14 @@ const lfsCollections = {
|
|
|
13
13
|
objects: "lfs/objects",
|
|
14
14
|
/** Each LFS object an upload link was given for, by its oid and its uploader, until listed. */
|
|
15
15
|
uploads: "lfs/uploads",
|
|
16
|
-
/** A Worker upload's staging key, by its due `removeAt` and its ID. */
|
|
16
|
+
/** A Worker upload's or an import copy's staging key, by its due `removeAt` and its ID. */
|
|
17
17
|
staging: "lfs/staging",
|
|
18
|
-
/**
|
|
18
|
+
/** Each object an import's copy staged, by its oid, until the copy lists it or upkeep ends it. */
|
|
19
|
+
copies: "lfs/copies",
|
|
20
|
+
/**
|
|
21
|
+
* Bytes upkeep is deleting, which no listing names: a signed upload's, by its oid and
|
|
22
|
+
* generation, or a stage's, by its staging row's ID.
|
|
23
|
+
*/
|
|
19
24
|
ending: "lfs/ending",
|
|
20
25
|
/** Each LFS lock, by its path's SHA-256. */
|
|
21
26
|
locks: "lfs/locks",
|
|
@@ -62,19 +67,35 @@ const UploadRow = /* @__PURE__ */ Schema.Struct({
|
|
|
62
67
|
*/
|
|
63
68
|
generation: Schema.String
|
|
64
69
|
});
|
|
65
|
-
/**
|
|
70
|
+
/**
|
|
71
|
+
* A staging key, which upkeep deletes at `removeAt` unless a listing names it: a Worker upload's,
|
|
72
|
+
* or an import copy's, which names its `oid`.
|
|
73
|
+
*/
|
|
66
74
|
const StagingRow = /* @__PURE__ */ Schema.Struct({
|
|
67
75
|
key: Schema.String,
|
|
76
|
+
removeAt: Schema.Int,
|
|
77
|
+
oid: Schema.optionalKey(Schema.String)
|
|
78
|
+
});
|
|
79
|
+
/**
|
|
80
|
+
* The key an import's copy of an object put, or will put, its bytes at, its staging row's ID and
|
|
81
|
+
* that row's `removeAt` (#2397): a try after one that died between its put and its commit finds the
|
|
82
|
+
* bytes there and lists them, downloading nothing. Upkeep drops it with its staging row.
|
|
83
|
+
*/
|
|
84
|
+
const CopyRow = /* @__PURE__ */ Schema.Struct({
|
|
85
|
+
key: Schema.String,
|
|
86
|
+
staged: Schema.String,
|
|
68
87
|
removeAt: Schema.Int
|
|
69
88
|
});
|
|
70
89
|
/**
|
|
71
90
|
* How long a Worker upload may stream: past it, its bytes aren't listed, so upkeep, which deletes
|
|
72
|
-
* them only at `removeAt`, a day after it started, never deletes bytes a listing names.
|
|
91
|
+
* them only at `removeAt`, a day after it started, never deletes bytes a listing names. An import's
|
|
92
|
+
* copy puts again to a stage's key only while the stage has this long left, so the put, which its
|
|
93
|
+
* try's lease ends far sooner, lands before upkeep may end the stage.
|
|
73
94
|
*/
|
|
74
95
|
const streamMost = /* @__PURE__ */ millis("12 hours");
|
|
75
96
|
/**
|
|
76
|
-
*
|
|
77
|
-
*
|
|
97
|
+
* Bytes upkeep is deleting: nothing lists them, since the commit that put the row dropped their
|
|
98
|
+
* upload row or their staging row. Upkeep drops it once the delete of `key` returns.
|
|
78
99
|
*/
|
|
79
100
|
const EndingRow = /* @__PURE__ */ Schema.Struct({ key: Schema.String });
|
|
80
101
|
const LockRow = /* @__PURE__ */ Schema.Struct({
|
|
@@ -89,10 +110,19 @@ const LockRow = /* @__PURE__ */ Schema.Struct({
|
|
|
89
110
|
const objectKey = (repo, oid, generation) => `lfs/${repo}/${oid}.${generation}`;
|
|
90
111
|
/** A Worker upload's bytes as they stream, before they're checked. */
|
|
91
112
|
const stagingKey = (repo, id) => `lfs/${repo}/staging/${id}`;
|
|
113
|
+
/**
|
|
114
|
+
* An import copy's bytes, at a generation of its own: one per copy row, so a delete of an ended
|
|
115
|
+
* stage's key, however late it lands, never reaches the bytes a later copy put and listed.
|
|
116
|
+
*/
|
|
117
|
+
const copyKey = (repo, oid, generation) => `lfs/${repo}/copy/${oid}.${generation}`;
|
|
92
118
|
const listedKey = (oid) => ({
|
|
93
119
|
collection: lfsCollections.objects,
|
|
94
120
|
id: oid
|
|
95
121
|
});
|
|
122
|
+
const copyRowKey = (oid) => ({
|
|
123
|
+
collection: lfsCollections.copies,
|
|
124
|
+
id: oid
|
|
125
|
+
});
|
|
96
126
|
/**
|
|
97
127
|
* Who an upload row is for: `ownWriter`'s SHA-256 of the caller's actor ID, or this for a caller
|
|
98
128
|
* with none. Each uploader's row has its own generation, so its signed links write a key no other
|
|
@@ -130,8 +160,12 @@ const listedRead = (oid) => ({
|
|
|
130
160
|
collection: lfsCollections.objects,
|
|
131
161
|
id: oid
|
|
132
162
|
});
|
|
163
|
+
const copyRead = (oid) => ({
|
|
164
|
+
collection: lfsCollections.copies,
|
|
165
|
+
id: oid
|
|
166
|
+
});
|
|
133
167
|
const uploadRead = (oid, uploader) => ({
|
|
134
168
|
collection: lfsCollections.uploads,
|
|
135
169
|
id: uploadId(oid, uploader)
|
|
136
170
|
});
|
|
137
|
-
export { EndingRow, ListedRow, LockRow, StagingRow, UploadRow, anonymousUploader, endingKey, largestObject, lfsCollections, linkLife, listedKey, listedRead, lockKey, lockRead, objectKey, stagingId, stagingKey, stagingRead, streamMost, uploadGrace, uploadKey, uploadOid, uploadRead, uploadedKept };
|
|
171
|
+
export { CopyRow, EndingRow, ListedRow, LockRow, StagingRow, UploadRow, anonymousUploader, copyKey, copyRead, copyRowKey, endingKey, largestObject, lfsCollections, linkLife, listedKey, listedRead, lockKey, lockRead, objectKey, stagingId, stagingKey, stagingRead, streamMost, uploadGrace, uploadKey, uploadOid, uploadRead, uploadedKept };
|
package/dist/lfs/service.d.mts
CHANGED
|
@@ -1,4 +1,3 @@
|
|
|
1
|
-
import { LfsFeature, LfsOptions } from "../contracts/lfs.mjs";
|
|
2
1
|
import { GitError } from "../contracts/result.mjs";
|
|
3
2
|
import "../core/parts.mjs";
|
|
4
3
|
import { LfsCall } from "./objects.mjs";
|
|
@@ -9,9 +8,4 @@ export interface LfsRoute extends LfsCall {
|
|
|
9
8
|
readonly route: string;
|
|
10
9
|
}
|
|
11
10
|
/** Git LFS's API for a server's repos, its objects in `bucket`. */
|
|
12
|
-
export type LfsService = (call: LfsRoute) => Effect.Effect<Response, GitError>;
|
|
13
|
-
/**
|
|
14
|
-
* Turns on Git LFS, its objects in the adapter's bucket: a server without it has no LFS. `options`
|
|
15
|
-
* win over the adapter's `RequestLimits`, as `LfsOptions` says.
|
|
16
|
-
*/
|
|
17
|
-
export declare const lfs: (options?: LfsOptions) => LfsFeature;
|
|
11
|
+
export type LfsService = (call: LfsRoute) => Effect.Effect<Response, GitError>;
|
package/dist/lfs/service.mjs
CHANGED
|
@@ -4,14 +4,6 @@ import { batch, receive, send, verify } from "./objects.mjs";
|
|
|
4
4
|
import { lfsAnswer } from "./wire.mjs";
|
|
5
5
|
import * as Effect from "effect/Effect";
|
|
6
6
|
// src/lfs/service.ts
|
|
7
|
-
/**
|
|
8
|
-
* Turns on Git LFS, its objects in the adapter's bucket: a server without it has no LFS. `options`
|
|
9
|
-
* win over the adapter's `RequestLimits`, as `LfsOptions` says.
|
|
10
|
-
*/
|
|
11
|
-
const lfs = (options = {}) => ({
|
|
12
|
-
...options,
|
|
13
|
-
kind: "lfs"
|
|
14
|
-
});
|
|
15
7
|
const methodNotAllowed = (allow) => Effect.succeed(lfsAnswer(405, { message: "Method not allowed" }, { allow }));
|
|
16
8
|
/** LFS's routes over `parts`, provided `needs`, the server's services, which `openRepo` reads. */
|
|
17
9
|
const lfsService = (needs, parts) => (call) => Effect.provideContext(served(parts, call), needs);
|
|
@@ -35,4 +27,4 @@ const served = (parts, call) => {
|
|
|
35
27
|
if (unlocking !== void 0) return method === "POST" ? unlock(parts, call, unlocking) : methodNotAllowed("POST");
|
|
36
28
|
return fail("NOT_FOUND", "No such LFS route");
|
|
37
29
|
};
|
|
38
|
-
export {
|
|
30
|
+
export { lfsService };
|
package/dist/lfs/upkeep.mjs
CHANGED
|
@@ -1,13 +1,15 @@
|
|
|
1
1
|
import { bucketDo } from "../storage/calls.mjs";
|
|
2
2
|
import { decodeRow } from "../store/errors.mjs";
|
|
3
|
-
import { EndingRow, ListedRow, StagingRow, UploadRow, endingKey, lfsCollections, listedRead, objectKey, uploadOid } from "./rows.mjs";
|
|
3
|
+
import { CopyRow, EndingRow, ListedRow, StagingRow, UploadRow, copyRead, copyRowKey, endingKey, lfsCollections, listedRead, objectKey, stagingRead, uploadOid } from "./rows.mjs";
|
|
4
4
|
import { uploadedSweepOf, uploadedSweepRead } from "./uploaded.mjs";
|
|
5
5
|
import * as Effect from "effect/Effect";
|
|
6
6
|
// src/lfs/upkeep.ts
|
|
7
7
|
/**
|
|
8
8
|
* LFS's part of a repo's `git.repack`: it deletes the bytes no listing will name. A Worker
|
|
9
|
-
* upload's staging key goes at its row's `removeAt`, a day after it began, when
|
|
10
|
-
* long ended
|
|
9
|
+
* upload's or an import copy's staging key goes at its row's `removeAt`, a day after it began, when
|
|
10
|
+
* its stream has long ended: the commit that drops the row, and an import copy's copy row, puts an
|
|
11
|
+
* ending row naming the key, so the import's next copy of the object stages a key of its own. A
|
|
12
|
+
* signed upload's object key goes at its upload row's `removeAt`, a day after its
|
|
11
13
|
* last link expired, if the object is still unlisted or listed at another key: the commit that
|
|
12
14
|
* drops the upload row puts
|
|
13
15
|
* an ending row naming the key, so verify, which lists only the key its upload row names, never
|
|
@@ -60,7 +62,7 @@ const upkeepStep = /* @__PURE__ */ Effect.fnUntraced(function* (upkeep) {
|
|
|
60
62
|
...stage
|
|
61
63
|
})));
|
|
62
64
|
const dueStages = stages.filter((stage) => stage.removeAt <= upkeep.at);
|
|
63
|
-
if (dueStages.length > 0) return yield* endStages(upkeep,
|
|
65
|
+
if (dueStages.length > 0) return yield* endStages(upkeep, dueStages);
|
|
64
66
|
const uploads = yield* dueUploads(upkeep);
|
|
65
67
|
if (uploads.ids.length > 0) return yield* endUploads(upkeep, uploads.ids);
|
|
66
68
|
const sweep = upkeep.deleted ? void 0 : uploadedSweepOf(uploaded, upkeep.at);
|
|
@@ -86,17 +88,48 @@ const endObjects = /* @__PURE__ */ Effect.fnUntraced(function* (upkeep, version,
|
|
|
86
88
|
})) });
|
|
87
89
|
return did;
|
|
88
90
|
});
|
|
89
|
-
/**
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
91
|
+
/**
|
|
92
|
+
* Drops each due staging row, read again at one version with its object's listed and copy rows,
|
|
93
|
+
* and the copy row that names it, and for a key no listing names, puts an ending row in the same
|
|
94
|
+
* commit, then deletes the key as `endObjects` does. A row a listing dropped since is left alone.
|
|
95
|
+
* So a delete, however late it lands, reaches only a key no row names, and a step of the import
|
|
96
|
+
* that staged before the commit fails its own, at the version this one moved.
|
|
97
|
+
*/
|
|
98
|
+
const endStages = /* @__PURE__ */ Effect.fnUntraced(function* (upkeep, stages) {
|
|
99
|
+
const snapshot = yield* upkeep.rows.read(upkeep.repo, stages.flatMap(({ id, oid }) => oid === void 0 ? [stagingRead(id)] : [
|
|
100
|
+
stagingRead(id),
|
|
101
|
+
listedRead(oid),
|
|
102
|
+
copyRead(oid)
|
|
103
|
+
]));
|
|
104
|
+
const found = snapshot.results.map((rows) => rows[0]);
|
|
105
|
+
const dropped = [];
|
|
106
|
+
const ended = [];
|
|
107
|
+
for (const { id, key, oid } of stages) {
|
|
108
|
+
const [staged, listedRow, copyRow] = found.splice(0, oid === void 0 ? 1 : 3);
|
|
109
|
+
if (staged === void 0) continue;
|
|
110
|
+
dropped.push({
|
|
111
|
+
collection: lfsCollections.staging,
|
|
112
|
+
id
|
|
113
|
+
});
|
|
114
|
+
const copy = copyRow === void 0 ? void 0 : yield* copyOf(copyRow);
|
|
115
|
+
if (oid !== void 0 && copy?.staged === id) dropped.push(copyRowKey(oid));
|
|
116
|
+
if ((listedRow === void 0 ? void 0 : yield* listedOf(listedRow))?.key !== key) ended.push({
|
|
117
|
+
collection: lfsCollections.ending,
|
|
118
|
+
id,
|
|
119
|
+
key
|
|
120
|
+
});
|
|
121
|
+
}
|
|
122
|
+
if (dropped.length === 0) return did;
|
|
123
|
+
const committed = yield* upkeep.rows.commit(upkeep.repo, snapshot.version, {
|
|
124
|
+
put: ended.map(({ collection, id, key }) => ({
|
|
125
|
+
collection,
|
|
126
|
+
id,
|
|
127
|
+
value: { key }
|
|
128
|
+
})),
|
|
129
|
+
delete: dropped
|
|
94
130
|
});
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
id: stage.id
|
|
98
|
-
})) });
|
|
99
|
-
return did;
|
|
131
|
+
if (!committed.ok || ended.length === 0) return did;
|
|
132
|
+
return yield* endObjects(upkeep, committed.version, ended);
|
|
100
133
|
});
|
|
101
134
|
/** Up to a page of the upload rows that are due, by ID, and when the soonest of the rest is. */
|
|
102
135
|
const dueUploads = /* @__PURE__ */ Effect.fnUntraced(function* (upkeep) {
|
|
@@ -126,6 +159,7 @@ const dueUploads = /* @__PURE__ */ Effect.fnUntraced(function* (upkeep) {
|
|
|
126
159
|
});
|
|
127
160
|
const uploadOf = (row) => decodeRow(UploadRow, row, `LFS object ${row.id}'s upload`);
|
|
128
161
|
const listedOf = (row) => decodeRow(ListedRow, row, `LFS object ${row.id}`);
|
|
162
|
+
const copyOf = (row) => decodeRow(CopyRow, row, `LFS copy ${row.id}`);
|
|
129
163
|
/**
|
|
130
164
|
* Drops each due upload row, by its ID, read again at one version. On a signed bucket, an object
|
|
131
165
|
* still unlisted, or listed at another key, as another uploader's bytes are, gets its ending row in
|
package/dist/lfs/upload-most.mjs
CHANGED
|
@@ -3,18 +3,18 @@ import { largestObject } from "./rows.mjs";
|
|
|
3
3
|
/**
|
|
4
4
|
* The largest Git LFS upload through the server, `workerUploadMost`, for a bucket that signs no
|
|
5
5
|
* links: the least of what the platform's body cap passes on, what its CPU cap lets the upload
|
|
6
|
-
*
|
|
6
|
+
* stream to the bucket, and `largestObject`. A larger one is refused before a byte streams, at the
|
|
7
7
|
* batch, so git-lfs never starts it.
|
|
8
8
|
*/
|
|
9
9
|
/** The share of a request's CPU an upload may spend: the rest is its rows', its put's and the runtime's. */
|
|
10
10
|
const cpuShare = .8;
|
|
11
11
|
/**
|
|
12
12
|
* The bytes an upload through a Worker gathers from its body's chunks before each goes on to its
|
|
13
|
-
*
|
|
14
|
-
* paid for once over (run 46342279485, #2296): one piece an upload, held as it streams.
|
|
13
|
+
* put, which checks its SHA-256, since a client's body reaches a Worker in chunks of at most
|
|
14
|
+
* 4,096 B, each paid for once over (run 46342279485, #2296): one piece an upload, held as it streams.
|
|
15
15
|
*/
|
|
16
16
|
const uploadPieceBytes = 1024 ** 2;
|
|
17
|
-
/** The bytes `cpuMs` of CPU
|
|
17
|
+
/** The bytes `cpuMs` of CPU streams to a checked put, at `uploadMsPerMiB` within `cpuShare` of it. */
|
|
18
18
|
const cpuBytes = (cpuMs) => Math.floor(cpuShare * cpuMs / 22 * 1024 ** 2);
|
|
19
19
|
/** The largest upload `caps` let finish: `largestObject` where neither binds below it. */
|
|
20
20
|
const uploadMostOf = (caps) => {
|
|
@@ -39,7 +39,7 @@ const capsRefusal = (caps) => {
|
|
|
39
39
|
/** What each cap that sets the largest upload is, as a refusal names it. */
|
|
40
40
|
const setBy = {
|
|
41
41
|
body: "the largest body its platform passes on",
|
|
42
|
-
cpu: "what its CPU cap lets it
|
|
42
|
+
cpu: "what its CPU cap lets it stream to the bucket",
|
|
43
43
|
object: "R2's largest single put"
|
|
44
44
|
};
|
|
45
45
|
/** Why an upload of more than `most` is refused, and what takes it. */
|