@ref0/git 0.11.0 → 0.14.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 +8 -7
- package/dist/auth/auth.d.mts +2 -2
- package/dist/auth/auth.mjs +3 -6
- package/dist/auth/authorize.mjs +1 -17
- package/dist/auth/helpers.mjs +3 -11
- package/dist/auth/host-services.mjs +11 -0
- package/dist/auth/policy.d.mts +27 -7
- package/dist/auth/policy.mjs +8 -4
- package/dist/auth/tokens-layer.d.mts +1 -2
- package/dist/auth/tokens-layer.mjs +2 -3
- package/dist/auth/tokens-public.d.mts +3 -3
- package/dist/auth/tokens.d.mts +1 -8
- package/dist/auth/tokens.mjs +1 -8
- package/dist/auth.d.mts +1 -4
- package/dist/auth.mjs +1 -3
- package/dist/client/git-http.mjs +18 -4
- package/dist/client/push-upload.mjs +33 -7
- package/dist/client/remote.mjs +94 -28
- package/dist/client/slice-push.d.mts +1 -1
- package/dist/contracts/access.d.mts +8 -8
- package/dist/contracts/actors.d.mts +2 -34
- package/dist/contracts/blobs.d.mts +2 -2
- package/dist/contracts/client.d.mts +8 -3
- package/dist/contracts/commits.d.mts +10 -2
- package/dist/contracts/commits.mjs +9 -1
- package/dist/contracts/files.d.mts +2 -2
- package/dist/contracts/forks.d.mts +14 -3
- package/dist/contracts/git.d.mts +41 -12
- package/dist/contracts/git.mjs +3 -2
- package/dist/contracts/lfs.d.mts +0 -7
- package/dist/contracts/objects.d.mts +80 -10
- 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/refs.d.mts +28 -6
- package/dist/contracts/remote.mjs +1 -3
- package/dist/contracts/repo-records.d.mts +1 -0
- package/dist/contracts/repos.d.mts +90 -2
- package/dist/contracts/repos.mjs +29 -2
- package/dist/contracts/result.d.mts +30 -23
- package/dist/contracts/result.mjs +24 -9
- package/dist/contracts/rules.d.mts +22 -22
- package/dist/contracts/server.d.mts +28 -77
- package/dist/contracts/signin.d.mts +1 -1
- package/dist/contracts/sync.d.mts +90 -19
- package/dist/contracts/sync.mjs +34 -10
- package/dist/contracts/tokens.d.mts +1 -6
- package/dist/contracts/tokens.mjs +1 -2
- package/dist/contracts/topics.d.mts +0 -5
- package/dist/contracts/work.d.mts +66 -2
- package/dist/contracts/work.mjs +8 -1
- package/dist/core/access.d.mts +1 -0
- package/dist/core/access.mjs +34 -13
- package/dist/core/ancestry.d.mts +9 -0
- package/dist/core/ancestry.mjs +6 -6
- package/dist/core/asked.mjs +68 -0
- package/dist/core/call-names.mjs +1 -0
- package/dist/core/call-services.mjs +2 -1
- package/dist/core/events/deliver.d.mts +1 -0
- package/dist/core/events/deliver.mjs +15 -3
- package/dist/core/forks.mjs +42 -16
- package/dist/core/imports.mjs +156 -13
- package/dist/core/index-job.mjs +9 -6
- package/dist/core/job-view.mjs +8 -9
- package/dist/core/mirror-rows.mjs +19 -4
- package/dist/core/objects/commits.mjs +16 -6
- package/dist/core/objects/reading.mjs +17 -9
- package/dist/core/parts.d.mts +8 -2
- package/dist/core/parts.mjs +1 -4
- package/dist/core/purge.mjs +76 -6
- package/dist/core/push-decide.mjs +1 -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 +107 -32
- package/dist/core/receipts.mjs +26 -10
- package/dist/core/ref-view.mjs +59 -5
- package/dist/core/refs.mjs +18 -10
- package/dist/core/registered-rows.mjs +7 -5
- package/dist/core/repack.mjs +16 -11
- package/dist/core/repo-info.mjs +16 -9
- package/dist/core/repos.mjs +30 -14
- package/dist/core/saved-caller-views.d.mts +18 -0
- package/dist/core/saved-caller-views.mjs +17 -4
- package/dist/core/saved-callers-public.d.mts +3 -3
- package/dist/core/saved-callers-public.mjs +3 -2
- package/dist/core/saved-callers.d.mts +7 -0
- package/dist/core/seam.mjs +2 -2
- package/dist/core/view.d.mts +6 -0
- package/dist/core/view.mjs +45 -12
- package/dist/core/work.mjs +47 -22
- package/dist/effect.d.mts +3 -1
- package/dist/effect.mjs +3 -1
- package/dist/engine/reads.mjs +13 -6
- 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 +1 -1
- package/dist/event-streams/stream.mjs +1 -1
- package/dist/extend.d.mts +4 -3
- package/dist/extend.mjs +3 -2
- package/dist/http/answers.mjs +4 -2
- package/dist/http/core-parts.mjs +64 -15
- package/dist/http/handler.mjs +2 -2
- package/dist/http/node.mjs +5 -4
- package/dist/http/parts.d.mts +1 -0
- package/dist/http/push-upload-job.mjs +503 -0
- package/dist/http/push-uploads.d.mts +1 -0
- package/dist/http/push-uploads.mjs +120 -59
- package/dist/http/upload-pack.mjs +7 -6
- package/dist/index.d.mts +23 -24
- package/dist/index.mjs +4 -7
- package/dist/lfs/base.d.mts +7 -3
- package/dist/lfs/base.mjs +2 -1
- package/dist/lfs/copy.d.mts +46 -0
- package/dist/lfs/copy.mjs +26 -0
- package/dist/lfs/layer.mjs +4 -2
- package/dist/lfs/locks.mjs +14 -9
- package/dist/lfs/objects.d.mts +6 -0
- package/dist/lfs/objects.mjs +95 -61
- package/dist/lfs/rows.d.mts +13 -0
- package/dist/lfs/service.d.mts +1 -7
- package/dist/lfs/service.mjs +1 -9
- package/dist/lfs/upload-most.mjs +5 -5
- package/dist/node.d.mts +2 -2
- 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/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 +1 -1
- package/dist/queue/calls.mjs +21 -1
- package/dist/queue/host.d.mts +1 -7
- package/dist/queue/host.mjs +1 -7
- package/dist/queue/layer.mjs +1 -1
- package/dist/queue/trim.mjs +1 -1
- package/dist/rest/blobs.d.mts +16 -8
- package/dist/rest/blobs.mjs +1 -1
- package/dist/rest/caller.d.mts +49 -9
- package/dist/rest/caller.mjs +1 -1
- package/dist/rest/client.d.mts +10 -3
- package/dist/rest/client.mjs +4 -0
- package/dist/rest/commits.d.mts +272 -239
- package/dist/rest/errors.d.mts +24 -4
- package/dist/rest/events.d.mts +9 -6
- package/dist/rest/events.mjs +1 -2
- package/dist/rest/files.d.mts +112 -100
- package/dist/rest/forks.d.mts +146 -122
- package/dist/rest/handler.mjs +4 -57
- package/dist/rest/handlers.d.mts +1 -1
- package/dist/rest/handlers.mjs +18 -4
- package/dist/rest/layer.mjs +10 -2
- package/dist/rest/me.d.mts +8 -4
- package/dist/rest/merges.d.mts +8 -4
- package/dist/rest/paths.mjs +1 -0
- package/dist/rest/queue.d.mts +292 -236
- package/dist/rest/refs.d.mts +98 -69
- package/dist/rest/repos.d.mts +133 -105
- package/dist/rest/tags.d.mts +100 -88
- package/dist/rest/tokens.d.mts +192 -168
- package/dist/rest/topics.d.mts +154 -134
- package/dist/rest/trees.d.mts +32 -16
- package/dist/rest/work.d.mts +467 -20
- package/dist/rest/work.mjs +8 -0
- package/dist/server/edge-node.d.mts +9 -13
- package/dist/server/edge-node.mjs +9 -12
- package/dist/server/git-layer.d.mts +1 -6
- package/dist/server/git-layer.mjs +2 -2
- package/dist/server/git-namespace.d.mts +4 -4
- package/dist/server/joined.d.mts +15 -22
- package/dist/server/joined.mjs +5 -29
- package/dist/server/lifecycle.mjs +107 -23
- package/dist/server/registry.mjs +9 -1
- package/dist/server/server.mjs +139 -216
- package/dist/storage/budget.mjs +2 -2
- package/dist/storage/clean-up.mjs +13 -10
- package/dist/storage/fetch.mjs +13 -8
- package/dist/storage/file-limits.mjs +24 -0
- package/dist/storage/index-build.d.mts +1 -0
- package/dist/storage/index-build.mjs +106 -62
- package/dist/storage/index-fetch.mjs +16 -3
- package/dist/storage/index-reach.mjs +33 -5
- package/dist/storage/index-remap.mjs +8 -1
- package/dist/storage/index-shallow.mjs +5 -3
- package/dist/storage/largest-files.mjs +48 -0
- package/dist/storage/lfs-pointers.mjs +10 -1
- package/dist/storage/loose.mjs +3 -1
- package/dist/storage/memory-budget.mjs +154 -8
- package/dist/storage/merge-cut.mjs +5 -4
- package/dist/storage/pack-reads.mjs +246 -34
- package/dist/storage/pack-receive.mjs +83 -25
- package/dist/storage/packs.mjs +37 -21
- package/dist/storage/prune-keep.mjs +203 -34
- package/dist/storage/prune-seen.mjs +11 -6
- package/dist/storage/prune-walk.mjs +219 -81
- package/dist/storage/prune.mjs +629 -196
- package/dist/storage/push-uploads.mjs +36 -12
- package/dist/storage/quarantine.mjs +9 -7
- package/dist/storage/ready.mjs +47 -19
- package/dist/storage/receive-bounds.mjs +29 -8
- package/dist/storage/receive-state.mjs +8 -0
- package/dist/storage/receive-steps.mjs +71 -18
- package/dist/storage/repack.d.mts +1 -1
- package/dist/storage/repack.mjs +1 -8
- package/dist/storage/rows.mjs +12 -1
- package/dist/storage/shallow.d.mts +1 -0
- package/dist/storage/shallow.mjs +26 -4
- package/dist/storage/stream-whole.mjs +5 -2
- package/dist/storage/visible.mjs +29 -1
- package/dist/storage/walk.mjs +2 -1
- package/dist/store/catalogue.mjs +1 -0
- 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 -2
- package/dist/store/cursor-seal.mjs +26 -14
- package/dist/store/errors.mjs +9 -1
- package/dist/store/records.d.mts +2 -0
- package/dist/store/records.mjs +9 -6
- package/dist/store/repo-record.d.mts +27 -0
- package/dist/store/repo-record.mjs +141 -4
- package/dist/store/scopes.mjs +10 -2
- 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 +63 -42
- package/dist/sync/http.mjs +36 -1
- package/dist/sync/import.mjs +4 -2
- package/dist/sync/layer.mjs +6 -2
- package/dist/sync/lfs-batch.mjs +119 -0
- package/dist/sync/lfs-copy.mjs +251 -0
- package/dist/sync/mirror.mjs +227 -147
- package/dist/sync/said.mjs +204 -0
- package/dist/sync/smart-http.mjs +4 -2
- package/dist/sync/step.mjs +33 -13
- package/dist/sync/tries.mjs +71 -24
- package/dist/sync.d.mts +2 -2
- package/dist/topics/advance.mjs +10 -3
- package/dist/topics/host.mjs +1 -19
- package/dist/topics/layer.mjs +1 -1
- package/package.json +3 -8
- package/dist/auth/bridge.mjs +0 -30
- package/dist/auth/helpers.d.mts +0 -17
- package/dist/core/purge.d.mts +0 -8
- package/dist/core/registered-rows.d.mts +0 -4
- package/dist/core/repack.d.mts +0 -11
- package/dist/http/handler.d.mts +0 -2
- package/dist/rest/handler.d.mts +0 -21
- package/dist/rest.d.mts +0 -2
- package/dist/rest.mjs +0 -1
- 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/topics/host.d.mts +0 -7
|
@@ -21,6 +21,7 @@ import { eachHeldRow, gitObjectOf, rowHeaders, rowSizes, rowsStartingWith, start
|
|
|
21
21
|
import { LeavingRow, decodeHeld } from "./rows.mjs";
|
|
22
22
|
import { SingleFlight } from "./single-flight.mjs";
|
|
23
23
|
import { allotted, keptOrLeft } from "./allotted.mjs";
|
|
24
|
+
import { fileBytesMost } from "./file-limits.mjs";
|
|
24
25
|
import * as Effect from "effect/Effect";
|
|
25
26
|
import * as Option from "effect/Option";
|
|
26
27
|
import * as Cause from "effect/Cause";
|
|
@@ -32,11 +33,6 @@ import * as Fiber from "effect/Fiber";
|
|
|
32
33
|
// src/storage/pack-reads.ts
|
|
33
34
|
/** The largest object `packs()` reads whole: a file past it is stored and sent as it is. */
|
|
34
35
|
const packObjectBytes = 16777216;
|
|
35
|
-
/**
|
|
36
|
-
* The largest file `packs()` takes, GitHub's limit: a blob sent whole, hashed as it streams and
|
|
37
|
-
* never held, and sent back as it is stored.
|
|
38
|
-
*/
|
|
39
|
-
const packFileBytes = 104857600;
|
|
40
36
|
/** How `packs()` resolves an entry, on a receive and on a read. */
|
|
41
37
|
const packIndexerLimits = {
|
|
42
38
|
objectBytes: packObjectBytes,
|
|
@@ -45,10 +41,14 @@ const packIndexerLimits = {
|
|
|
45
41
|
nameBytes: 4 * packObjectBytes,
|
|
46
42
|
chainReads: 64
|
|
47
43
|
};
|
|
48
|
-
/**
|
|
44
|
+
/**
|
|
45
|
+
* How large an entry's header may say it is, for reads of headers alone: a file's to `fileBytesMost`,
|
|
46
|
+
* the most a push's `refuseAbove` may let in. A file past `packObjectBytes` is sent as it's stored,
|
|
47
|
+
* never read whole.
|
|
48
|
+
*/
|
|
49
49
|
const headerLimits = {
|
|
50
50
|
...packIndexerLimits,
|
|
51
|
-
objectBytes:
|
|
51
|
+
objectBytes: fileBytesMost
|
|
52
52
|
};
|
|
53
53
|
/**
|
|
54
54
|
* What one operation's reads keep of the objects they resolve, across every pack it reads: a
|
|
@@ -863,6 +863,22 @@ const readInto = (bucket, key, most, named) => bucketDo(Effect.suspend(() => {
|
|
|
863
863
|
}), Effect.map(() => bytes.subarray(0, at)), Effect.catchIf((error) => Predicate.isTagged(error, "NotFound"), () => Effect.succeed(void 0)));
|
|
864
864
|
}));
|
|
865
865
|
/**
|
|
866
|
+
* Why a reader under `indexFloor` refused: a lookup needed a pack whose index its room let go of,
|
|
867
|
+
* which a prune walk's try takes as its end, to go on in a try of its own.
|
|
868
|
+
*/
|
|
869
|
+
var IndexReloaded = class extends Error {};
|
|
870
|
+
/** The refusal of a load of `pack`'s index, which a reader's room let go of. */
|
|
871
|
+
const indexReloaded = (pack) => {
|
|
872
|
+
const message = `Pack ${pack}'s index was let go of by the reader's room, which loads a pack once`;
|
|
873
|
+
return gitError("RESOURCE_EXHAUSTED", message, { cause: new IndexReloaded(message) });
|
|
874
|
+
};
|
|
875
|
+
/** Whether `error` is a reader's refusal to load again an index its room let go of. */
|
|
876
|
+
const isIndexReloaded = (error) => error.cause instanceof IndexReloaded;
|
|
877
|
+
/** Why a reader under `indexFloor` refused: a load past its caller's calls, as `canLoad` says. */
|
|
878
|
+
var IndexShort = class extends Error {};
|
|
879
|
+
/** Whether `error` is a reader's refusal to load an index past its caller's calls. */
|
|
880
|
+
const isIndexShort = (error) => error.cause instanceof IndexShort;
|
|
881
|
+
/**
|
|
866
882
|
* One operation's reads of a repo's objects under `packs()`: its rows first, a small push's,
|
|
867
883
|
* then each pack its list names, by the pack's `.idx`. An object is resolved from the pack's
|
|
868
884
|
* neighbourhoods the operation keeps, each delta's base from the same pack, and hashed again
|
|
@@ -881,18 +897,117 @@ const packReader = (input) => {
|
|
|
881
897
|
const charged = /* @__PURE__ */ new Set();
|
|
882
898
|
const charging = new SingleFlight();
|
|
883
899
|
const loadings = /* @__PURE__ */ new Set();
|
|
900
|
+
const { indexFloor } = input;
|
|
901
|
+
const roomHeld = /* @__PURE__ */ new Map();
|
|
902
|
+
const letGo = /* @__PURE__ */ new Set();
|
|
903
|
+
let roomBytes = 0;
|
|
904
|
+
const unlisted = /* @__PURE__ */ new Set();
|
|
884
905
|
/**
|
|
885
|
-
* `
|
|
886
|
-
* granted, so a read at once on the reader waits on the
|
|
887
|
-
* interrupted charge is asked again by the next read,
|
|
906
|
+
* `bytes` charged to the reader's allotment once a reader under `id`, a pack's or the room's,
|
|
907
|
+
* those `tells` told: marked only once granted, so a read at once on the reader waits on the
|
|
908
|
+
* charge before it loads, and a refused or interrupted charge is asked again by the next read,
|
|
909
|
+
* never skipped.
|
|
888
910
|
*/
|
|
889
|
-
const
|
|
890
|
-
if (charged.has(
|
|
891
|
-
const granted = yield* charging.run(
|
|
892
|
-
charged.add(
|
|
893
|
-
for (const told of loadings) told(
|
|
911
|
+
const chargeOnce = Effect.fnUntraced(function* (id, bytes, tells) {
|
|
912
|
+
if (charged.has(id)) return;
|
|
913
|
+
const granted = yield* charging.run(id, Effect.tap(memory.index(bytes), () => Effect.sync(() => {
|
|
914
|
+
charged.add(id);
|
|
915
|
+
if (tells) for (const told of loadings) told(id);
|
|
894
916
|
})));
|
|
895
|
-
if (Option.isNone(granted)) yield*
|
|
917
|
+
if (Option.isNone(granted)) yield* chargeOnce(id, bytes, tells);
|
|
918
|
+
});
|
|
919
|
+
/** `pack`'s `.idx` and `.rev` charged once a reader, each pack's own, as `chargeOnce` says. */
|
|
920
|
+
const charge = (pack) => chargeOnce(pack.id, indexBytes(pack), true);
|
|
921
|
+
/** The room's least recently used let go of until `bytes` more fit in `floor`. */
|
|
922
|
+
const makeRoom = (bytes, floor) => {
|
|
923
|
+
for (const id of kept.keys()) {
|
|
924
|
+
if (roomBytes + bytes <= floor) return;
|
|
925
|
+
kept.delete(id);
|
|
926
|
+
roomBytes -= roomHeld.get(id) ?? 0;
|
|
927
|
+
roomHeld.delete(id);
|
|
928
|
+
letGo.add(id);
|
|
929
|
+
}
|
|
930
|
+
};
|
|
931
|
+
/**
|
|
932
|
+
* Under `indexFloor`, `pack`'s `.idx` and `.rev` from the room, made its most recently used: on
|
|
933
|
+
* its first load, the floor charged once for the reader, then the least recently used let go
|
|
934
|
+
* until it fits, before the load, so the reader never holds past the floor while it reads. One
|
|
935
|
+
* the room let go of fails as `indexReloaded`, and one past `canLoad` as `indexShort`.
|
|
936
|
+
*/
|
|
937
|
+
const roomed = Effect.fnUntraced(function* (pack, { bytes: floor, canLoad }) {
|
|
938
|
+
const known = kept.get(pack.id);
|
|
939
|
+
if (known !== void 0) {
|
|
940
|
+
kept.delete(pack.id);
|
|
941
|
+
kept.set(pack.id, known);
|
|
942
|
+
return known;
|
|
943
|
+
}
|
|
944
|
+
if (letGo.has(pack.id)) return yield* Effect.fail(indexReloaded(pack.id));
|
|
945
|
+
if (canLoad?.() === false) {
|
|
946
|
+
const message = `Pack ${pack.id}'s index would load past its reader's calls`;
|
|
947
|
+
return yield* Effect.fail(gitError("RESOURCE_EXHAUSTED", message, { cause: new IndexShort(message) }));
|
|
948
|
+
}
|
|
949
|
+
yield* chargeOnce("", floor, false);
|
|
950
|
+
const bytes = indexBytes(pack);
|
|
951
|
+
makeRoom(bytes, floor);
|
|
952
|
+
for (const told of loadings) told(pack.id);
|
|
953
|
+
const loaded = yield* indexes.load(bucket, pack);
|
|
954
|
+
const raced = kept.get(pack.id);
|
|
955
|
+
if (raced !== void 0) return raced;
|
|
956
|
+
makeRoom(bytes, floor);
|
|
957
|
+
kept.set(pack.id, loaded);
|
|
958
|
+
roomHeld.set(pack.id, bytes);
|
|
959
|
+
roomBytes += bytes;
|
|
960
|
+
return loaded;
|
|
961
|
+
});
|
|
962
|
+
/**
|
|
963
|
+
* The listed packs in the order a lookup under `indexFloor` looks in them: those the room holds,
|
|
964
|
+
* then those it never loaded, then those it let go of, each in their listed order, so a lookup
|
|
965
|
+
* loads a pack the room let go of only when what's left of it may be there.
|
|
966
|
+
*/
|
|
967
|
+
const roomOrder = () => {
|
|
968
|
+
const held = [];
|
|
969
|
+
const fresh = [];
|
|
970
|
+
const gone = [];
|
|
971
|
+
for (const pack of listed.packs) (kept.has(pack.id) ? held : letGo.has(pack.id) ? gone : fresh).push(pack);
|
|
972
|
+
return [
|
|
973
|
+
...held,
|
|
974
|
+
...fresh,
|
|
975
|
+
...gone
|
|
976
|
+
];
|
|
977
|
+
};
|
|
978
|
+
/**
|
|
979
|
+
* Each listed pack that holds some of `oids`, visited with them by offset, in listed order, each
|
|
980
|
+
* pack's index loaded as `indexed` loads it. Under `indexFloor`, in the room's order, each
|
|
981
|
+
* visited while its index is the room's, before the next pack's loads, so a lookup holds one
|
|
982
|
+
* pack's index at a time, and those no listed pack holds are kept in `unlisted`, up to the
|
|
983
|
+
* floor's. Answers those of `oids` no listed pack holds. A pack in `skip` isn't looked in: its
|
|
984
|
+
* caller proved it holds none of `oids`.
|
|
985
|
+
*/
|
|
986
|
+
const byPacks = Effect.fnUntraced(function* (oids, visit, skip) {
|
|
987
|
+
const asked = [...new Set(oids)];
|
|
988
|
+
const known = asked.filter((oid) => unlisted.has(oid));
|
|
989
|
+
let left = known.length === 0 ? asked : asked.filter((oid) => !unlisted.has(oid));
|
|
990
|
+
for (const pack of indexFloor === void 0 ? listed.packs : roomOrder()) {
|
|
991
|
+
if (left.length === 0) return known;
|
|
992
|
+
if (skip?.has(pack.id) === true) continue;
|
|
993
|
+
const loaded = indexFloor === void 0 ? yield* indexed(pack) : yield* roomed(pack, indexFloor);
|
|
994
|
+
const entries = [];
|
|
995
|
+
left = left.filter((oid) => {
|
|
996
|
+
const object = loaded.index.find(oid);
|
|
997
|
+
if (object === void 0) return true;
|
|
998
|
+
entries.push({
|
|
999
|
+
oid,
|
|
1000
|
+
offset: object.offset,
|
|
1001
|
+
crc32: object.crc32
|
|
1002
|
+
});
|
|
1003
|
+
return false;
|
|
1004
|
+
});
|
|
1005
|
+
if (entries.length > 0) yield* visit(loaded, entries.sort((a, b) => a.offset - b.offset));
|
|
1006
|
+
}
|
|
1007
|
+
if (indexFloor !== void 0) {
|
|
1008
|
+
for (const oid of left) if (unlisted.size < indexFloor.unlisted) unlisted.add(oid);
|
|
1009
|
+
}
|
|
1010
|
+
return [...known, ...left];
|
|
896
1011
|
});
|
|
897
1012
|
const unnamed = (pack) => !named.has(pack.id);
|
|
898
1013
|
/** The packs the repo lists now that `listed` didn't, such as a merge's that folded rows. */
|
|
@@ -949,11 +1064,12 @@ const packReader = (input) => {
|
|
|
949
1064
|
const look = Effect.fnUntraced(function* (packs, held, going = false) {
|
|
950
1065
|
for (const listedPack of packs) {
|
|
951
1066
|
if (left.length === 0) break;
|
|
952
|
-
const
|
|
953
|
-
|
|
954
|
-
|
|
1067
|
+
const room = held === kept ? indexFloor : void 0;
|
|
1068
|
+
const known = room === void 0 ? held.get(listedPack.id) : void 0;
|
|
1069
|
+
if (room === void 0 && known === void 0) yield* charge(listedPack);
|
|
1070
|
+
const indexed = room !== void 0 ? Option.some(yield* roomed(listedPack, room)) : known === void 0 ? yield* indexes.load(bucket, listedPack).pipe(Effect.asSome, Effect.catch((error) => going && error.code === "DATA_LOSS" ? Effect.succeedNone : Effect.fail(error))) : Option.some(known);
|
|
955
1071
|
if (Option.isNone(indexed)) continue;
|
|
956
|
-
held.set(listedPack.id, indexed.value);
|
|
1072
|
+
if (room === void 0) held.set(listedPack.id, indexed.value);
|
|
957
1073
|
left = left.filter((oid) => {
|
|
958
1074
|
const object = indexed.value.index.find(oid);
|
|
959
1075
|
if (object === void 0) return true;
|
|
@@ -1010,7 +1126,24 @@ const packReader = (input) => {
|
|
|
1010
1126
|
const where = yield* located(oids, take, skip);
|
|
1011
1127
|
for (const [oid, { indexed, offset }] of where) yield* take(yield* wholeAt(oid, indexed, offset));
|
|
1012
1128
|
});
|
|
1013
|
-
|
|
1129
|
+
/**
|
|
1130
|
+
* `each` under `indexFloor`: the listed packs' objects a pack at a time, each read whole while its
|
|
1131
|
+
* pack's index is the room's; then, as `located` orders them, the rows of those no listed pack
|
|
1132
|
+
* holds, then the packs listed since and those leaving.
|
|
1133
|
+
*/
|
|
1134
|
+
const eachInRoom = Effect.fnUntraced(function* (oids, take) {
|
|
1135
|
+
const left = yield* byPacks(oids, (indexed, entries) => Effect.forEach(entries, ({ oid, offset }) => Effect.flatMap(wholeAt(oid, indexed, offset), take), { discard: true }));
|
|
1136
|
+
if (left.length === 0) return;
|
|
1137
|
+
const inRows = /* @__PURE__ */ new Set();
|
|
1138
|
+
yield* rows(left, (object) => {
|
|
1139
|
+
inRows.add(object.oid);
|
|
1140
|
+
return take(object);
|
|
1141
|
+
});
|
|
1142
|
+
const missing = left.filter((oid) => !inRows.has(oid));
|
|
1143
|
+
if (missing.length === 0) return;
|
|
1144
|
+
for (const [oid, { indexed, offset }] of yield* found(missing, "beyond")) yield* take(yield* wholeAt(oid, indexed, offset));
|
|
1145
|
+
});
|
|
1146
|
+
const each = indexFloor === void 0 ? eachOf() : eachInRoom;
|
|
1014
1147
|
/** Which of `oids` the repo holds, read whole, through `take`'s reads. */
|
|
1015
1148
|
const heldOf = (take) => Effect.fnUntraced(function* (oids) {
|
|
1016
1149
|
const objects = /* @__PURE__ */ new Map();
|
|
@@ -1198,13 +1331,13 @@ const packReader = (input) => {
|
|
|
1198
1331
|
*/
|
|
1199
1332
|
const storedOf = Effect.fnUntraced(function* (oids, skip) {
|
|
1200
1333
|
const entries = /* @__PURE__ */ new Map();
|
|
1201
|
-
|
|
1334
|
+
const add = Effect.fnUntraced(function* (oid, indexed, at) {
|
|
1202
1335
|
const { pack } = indexed;
|
|
1336
|
+
const { offset, crc32 } = at;
|
|
1203
1337
|
const end = entryEnd(indexed, offset);
|
|
1204
1338
|
if (end === void 0 || end <= offset) return yield* Effect.fail(lost(`Pack ${pack.id}'s reverse index has no entry at ${offset}`));
|
|
1205
1339
|
const holds = yield* holdsAt(indexed, offset);
|
|
1206
|
-
if (holds
|
|
1207
|
-
entries.set(oid, {
|
|
1340
|
+
if (holds !== void 0) entries.set(oid, {
|
|
1208
1341
|
oid,
|
|
1209
1342
|
pack,
|
|
1210
1343
|
offset,
|
|
@@ -1212,7 +1345,13 @@ const packReader = (input) => {
|
|
|
1212
1345
|
crc32,
|
|
1213
1346
|
holds
|
|
1214
1347
|
});
|
|
1215
|
-
}
|
|
1348
|
+
});
|
|
1349
|
+
const left = indexFloor === void 0 || skip !== void 0 ? oids : yield* byPacks(oids, (indexed, at) => Effect.forEach(at, (each) => add(each.oid, indexed, each), { discard: true }));
|
|
1350
|
+
const from = left === oids ? "all" : "beyond";
|
|
1351
|
+
for (const [oid, place] of byPlace(yield* found(left, from, skip))) yield* add(oid, place.indexed, {
|
|
1352
|
+
oid,
|
|
1353
|
+
...place
|
|
1354
|
+
});
|
|
1216
1355
|
return entries;
|
|
1217
1356
|
});
|
|
1218
1357
|
const read = (entry, at) => {
|
|
@@ -1314,19 +1453,27 @@ const packReader = (input) => {
|
|
|
1314
1453
|
/** Those of `oids` stored as whole blobs, by their entries' headers, none of them read. */
|
|
1315
1454
|
const wholeBlobs = Effect.fnUntraced(function* (oids) {
|
|
1316
1455
|
const blobs = /* @__PURE__ */ new Set();
|
|
1317
|
-
|
|
1456
|
+
const add = Effect.fnUntraced(function* (oid, indexed, offset) {
|
|
1318
1457
|
const holds = yield* holdsAt(indexed, offset);
|
|
1319
1458
|
if (holds?.kind === "whole" && holds.type === "blob") blobs.add(oid);
|
|
1320
|
-
}
|
|
1459
|
+
});
|
|
1460
|
+
const left = yield* byPacks(oids, (indexed, at) => Effect.forEach(at, ({ oid, offset }) => add(oid, indexed, offset), { discard: true }));
|
|
1461
|
+
for (const [oid, { indexed, offset }] of byPlace(yield* found(left, "beyond"))) yield* add(oid, indexed, offset);
|
|
1321
1462
|
return blobs;
|
|
1322
1463
|
});
|
|
1323
1464
|
/**
|
|
1324
|
-
* `oids` in the order whose reads take the fewest blocks: the listed packs'
|
|
1325
|
-
* offset, from their `.idx` alone with no header read,
|
|
1465
|
+
* `oids` in the order whose reads take the fewest blocks, a group a pack: the listed packs'
|
|
1466
|
+
* objects by offset, from their `.idx` alone with no header read, the pack looked in last first,
|
|
1467
|
+
* then the rest as they came, as one group (#662). Under `indexFloor`, the pack looked in last,
|
|
1468
|
+
* and those before it the room still holds, are read without a load, and a batch that takes from
|
|
1469
|
+
* one group needs one pack's index.
|
|
1326
1470
|
*/
|
|
1327
|
-
const
|
|
1328
|
-
const
|
|
1329
|
-
|
|
1471
|
+
const inPackGroups = Effect.fnUntraced(function* (oids) {
|
|
1472
|
+
const groups = [];
|
|
1473
|
+
const left = yield* byPacks(oids, (_, entries) => Effect.sync(() => void groups.push(entries.map(({ oid }) => oid))));
|
|
1474
|
+
groups.reverse();
|
|
1475
|
+
if (left.length > 0) groups.push(left);
|
|
1476
|
+
return groups;
|
|
1330
1477
|
});
|
|
1331
1478
|
/**
|
|
1332
1479
|
* Lets go of what the reader holds: its read cache and the indexes it kept. Its blocks stay
|
|
@@ -1337,6 +1484,10 @@ const packReader = (input) => {
|
|
|
1337
1484
|
const release = () => {
|
|
1338
1485
|
wholeAt.clear();
|
|
1339
1486
|
kept.clear();
|
|
1487
|
+
roomHeld.clear();
|
|
1488
|
+
letGo.clear();
|
|
1489
|
+
unlisted.clear();
|
|
1490
|
+
roomBytes = 0;
|
|
1340
1491
|
};
|
|
1341
1492
|
/**
|
|
1342
1493
|
* A listed pack's `.idx` and `.rev` as this reader holds them: loaded and charged as its own
|
|
@@ -1344,6 +1495,7 @@ const packReader = (input) => {
|
|
|
1344
1495
|
* walk read them once between them, and none when the cache holds them.
|
|
1345
1496
|
*/
|
|
1346
1497
|
const indexed = Effect.fnUntraced(function* (pack) {
|
|
1498
|
+
if (indexFloor !== void 0) return yield* roomed(pack, indexFloor);
|
|
1347
1499
|
const known = kept.get(pack.id);
|
|
1348
1500
|
if (known !== void 0) return known;
|
|
1349
1501
|
yield* charge(pack);
|
|
@@ -1352,6 +1504,64 @@ const packReader = (input) => {
|
|
|
1352
1504
|
return loaded;
|
|
1353
1505
|
});
|
|
1354
1506
|
/**
|
|
1507
|
+
* Where each of `oids` is for a prune walk's seen set, as `byPacks` finds it: its pack's ID and
|
|
1508
|
+
* its rank there, in the order it visits the packs. Under `indexFloor`, by the first in the
|
|
1509
|
+
* room's order, so an object two packs hold may be placed by either. A pack in `skip` isn't
|
|
1510
|
+
* looked in: its caller proved it holds none of `oids`.
|
|
1511
|
+
*/
|
|
1512
|
+
const ranks = Effect.fnUntraced(function* (oids, skip) {
|
|
1513
|
+
const at = /* @__PURE__ */ new Map();
|
|
1514
|
+
yield* byPacks(oids, ({ pack, index }, entries) => Effect.sync(() => {
|
|
1515
|
+
for (const { oid } of entries) {
|
|
1516
|
+
const rank = index.rankOf(oid);
|
|
1517
|
+
if (rank !== void 0) at.set(oid, {
|
|
1518
|
+
pack: pack.id,
|
|
1519
|
+
rank
|
|
1520
|
+
});
|
|
1521
|
+
}
|
|
1522
|
+
}), skip);
|
|
1523
|
+
return at;
|
|
1524
|
+
});
|
|
1525
|
+
/**
|
|
1526
|
+
* For a prune walk's history: the first listed pack that holds some of `oids`, of those the room
|
|
1527
|
+
* holds and then those it never loaded, in listed order, with the rank there of each it holds,
|
|
1528
|
+
* so a walk reads what one pack holds before it loads the next (#2230). A pack the room let go
|
|
1529
|
+
* of isn't looked in: what only it holds waits for a reader of its own. With none, `unlisted`
|
|
1530
|
+
* says whether every listed pack was looked in, none let go of, which proves no listed pack holds
|
|
1531
|
+
* them: they're then kept as `unlisted` are, up to the floor's.
|
|
1532
|
+
*/
|
|
1533
|
+
const nextPack = Effect.fnUntraced(function* (oids) {
|
|
1534
|
+
const asked = [...new Set(oids)].filter((oid) => !unlisted.has(oid));
|
|
1535
|
+
const placed = /* @__PURE__ */ new Map();
|
|
1536
|
+
const every = letGo.size === 0;
|
|
1537
|
+
if (asked.length === 0) return {
|
|
1538
|
+
placed,
|
|
1539
|
+
unlisted: true
|
|
1540
|
+
};
|
|
1541
|
+
for (const pack of indexFloor === void 0 ? listed.packs : roomOrder()) {
|
|
1542
|
+
if (letGo.has(pack.id)) break;
|
|
1543
|
+
const { index } = yield* indexed(pack);
|
|
1544
|
+
for (const oid of asked) {
|
|
1545
|
+
const rank = index.rankOf(oid);
|
|
1546
|
+
if (rank !== void 0) placed.set(oid, {
|
|
1547
|
+
pack: pack.id,
|
|
1548
|
+
rank
|
|
1549
|
+
});
|
|
1550
|
+
}
|
|
1551
|
+
if (placed.size > 0) return {
|
|
1552
|
+
placed,
|
|
1553
|
+
unlisted: false
|
|
1554
|
+
};
|
|
1555
|
+
}
|
|
1556
|
+
if (every && indexFloor !== void 0) {
|
|
1557
|
+
for (const oid of asked) if (unlisted.size < indexFloor.unlisted) unlisted.add(oid);
|
|
1558
|
+
}
|
|
1559
|
+
return {
|
|
1560
|
+
placed,
|
|
1561
|
+
unlisted: every
|
|
1562
|
+
};
|
|
1563
|
+
});
|
|
1564
|
+
/**
|
|
1355
1565
|
* `ObjectReader.startingWith`: the IDs that start with `prefix` in the listed packs and the rows;
|
|
1356
1566
|
* then, unless the rows were read at the listing's own version, in the packs listed since and
|
|
1357
1567
|
* those leaving, where a merge that folded rows after this read's listing put them. Each pack is
|
|
@@ -1424,7 +1634,9 @@ const packReader = (input) => {
|
|
|
1424
1634
|
object,
|
|
1425
1635
|
objects,
|
|
1426
1636
|
wholeBlobs,
|
|
1427
|
-
|
|
1637
|
+
inPackGroups,
|
|
1638
|
+
nextPack,
|
|
1639
|
+
ranks,
|
|
1428
1640
|
release
|
|
1429
1641
|
};
|
|
1430
1642
|
return input.visible === void 0 ? reads : narrowedTo(reads, input.visible);
|
|
@@ -1476,4 +1688,4 @@ const narrowedTo = (reads, visible) => {
|
|
|
1476
1688
|
wholeBlobs: (oids) => Effect.flatMap(only(oids), reads.wholeBlobs)
|
|
1477
1689
|
};
|
|
1478
1690
|
};
|
|
1479
|
-
export { PackBlocks, PackIndexes, blockBytes, blockHeld, blocksHeld, entryEnd, hashedNowMost, hashedRunMost, headerLimits, indexBytes, indexSeedShare,
|
|
1691
|
+
export { IndexReloaded, IndexShort, PackBlocks, PackIndexes, blockBytes, blockHeld, blocksHeld, entryEnd, hashedNowMost, hashedRunMost, headerLimits, indexBytes, indexSeedShare, isIndexReloaded, isIndexShort, loadedLookup, packIndexerLimits, packObjectBytes, packObjects, packReader, rangedLookup, readCacheBytes, seedBytes };
|
|
@@ -18,6 +18,8 @@ import { packPutOptions, startPut } from "./merge.mjs";
|
|
|
18
18
|
import { repoTypes } from "./held-types.mjs";
|
|
19
19
|
import { checkedFilesRefused, checkedOverflow, checkedRecords, fsckRefusal, receiveChecked } from "./fsck.mjs";
|
|
20
20
|
import { packFiles } from "./layout.mjs";
|
|
21
|
+
import { fileBytesMost, fileRefuseBytes } from "./file-limits.mjs";
|
|
22
|
+
import { LargestFiles } from "./largest-files.mjs";
|
|
21
23
|
import { ReceivedPointers, pointersRecords } from "./lfs-pointers.mjs";
|
|
22
24
|
import { boundaryNotInPack, linkReader, segmentCut, segmentTooLarge, tagTargetMissing, wrongType } from "./links.mjs";
|
|
23
25
|
import { noRows } from "./object-rows.mjs";
|
|
@@ -30,7 +32,7 @@ import { checkRow, checkRowAt, sweepHeld, sweepRowAt, sweepRows } from "./receiv
|
|
|
30
32
|
import { pushPackTooLarge, pushUploadMost } from "./push-uploads.mjs";
|
|
31
33
|
import { chainUnitsOf, receiveTable, receiveTableBytes } from "./receive-table.mjs";
|
|
32
34
|
import { rootsCollected } from "./roots.mjs";
|
|
33
|
-
import {
|
|
35
|
+
import { packIndexerLimits, packObjectBytes, packReader } from "./pack-reads.mjs";
|
|
34
36
|
import { dropRefused, openQuarantine, stillOpen } from "./quarantine.mjs";
|
|
35
37
|
import { malformedPack, ofsRefused, readFailure } from "./unpack.mjs";
|
|
36
38
|
import { oidBytes } from "../protocol/packs/idx.mjs";
|
|
@@ -39,12 +41,47 @@ import * as Result from "effect/Result";
|
|
|
39
41
|
import * as Data from "effect/Data";
|
|
40
42
|
// src/storage/pack-receive.ts
|
|
41
43
|
/**
|
|
42
|
-
* How large the reader lets an entry be: a whole one to `
|
|
44
|
+
* How large the reader lets an entry be: a whole one to `fileBytesMost`, kept only if it's a blob,
|
|
45
|
+
* so a file past a push's `refuseAbove` is named, then refused by core with its path (#2395).
|
|
43
46
|
* Anything else, and any delta, is resolved whole, within `packObjectBytes`.
|
|
44
47
|
*/
|
|
45
48
|
const receiveLimits = {
|
|
46
49
|
...packIndexerLimits,
|
|
47
|
-
objectBytes:
|
|
50
|
+
objectBytes: fileBytesMost
|
|
51
|
+
};
|
|
52
|
+
/**
|
|
53
|
+
* The steps of a staged receive that lists no largest files, an import's: a file past
|
|
54
|
+
* `fileRefuseBytes` is refused as it's read, by its offset alone. A push upload's steps list them,
|
|
55
|
+
* carried from step to step, and read an entry to what the try's CPU leaves past its share, as
|
|
56
|
+
* `StepInput.largest` says (#2468).
|
|
57
|
+
*/
|
|
58
|
+
const stepLimits = {
|
|
59
|
+
...packIndexerLimits,
|
|
60
|
+
objectBytes: fileRefuseBytes
|
|
61
|
+
};
|
|
62
|
+
/**
|
|
63
|
+
* A push upload's step's limits, from the largest entry it reads, `entryMost`, as
|
|
64
|
+
* `StepInput.largest` says: the reader takes a whole entry to it, and each delta's instructions to
|
|
65
|
+
* `deltaBytes` or it if less; the indexer resolves and names a delta's result to the least of its
|
|
66
|
+
* own limits and it. So on a host whose try reads a smaller entry than `packObjectBytes`, no delta
|
|
67
|
+
* costs more than its largest entry (#2500). The indexer's `deltaBytes` stays
|
|
68
|
+
* `packIndexerLimits`': it bounds a chain's instructions together as it reads them again, each
|
|
69
|
+
* delta's already held to the reader's.
|
|
70
|
+
*/
|
|
71
|
+
const listingLimits = (entryMost) => {
|
|
72
|
+
const { objectBytes, deltaBytes, nameBytes } = packIndexerLimits;
|
|
73
|
+
return {
|
|
74
|
+
reader: {
|
|
75
|
+
...packIndexerLimits,
|
|
76
|
+
deltaBytes: Math.min(deltaBytes, entryMost),
|
|
77
|
+
objectBytes: entryMost
|
|
78
|
+
},
|
|
79
|
+
indexer: {
|
|
80
|
+
...packIndexerLimits,
|
|
81
|
+
objectBytes: Math.min(objectBytes, entryMost),
|
|
82
|
+
nameBytes: Math.min(nameBytes, entryMost)
|
|
83
|
+
}
|
|
84
|
+
};
|
|
48
85
|
};
|
|
49
86
|
/** What the reader may hold besides the entries it hands on: its inflater and buffers. */
|
|
50
87
|
const readerBytes = 1048576;
|
|
@@ -153,25 +190,28 @@ const tooDeep = (offset, links) => gitError("RESOURCE_EXHAUSTED", `The delta at
|
|
|
153
190
|
hint: deepHint,
|
|
154
191
|
context: { reason: "too-large" }
|
|
155
192
|
});
|
|
156
|
-
/** What a pusher does so Git sends each file past `packObjectBytes` whole, past its next gc too, or keeps it out of the pack with Git LFS. */
|
|
157
|
-
const wholeHint = "Set `git config core.bigFileThreshold 16m`, run `git repack -adf`, then push again, or track the file with Git LFS";
|
|
158
193
|
/**
|
|
159
|
-
*
|
|
160
|
-
*
|
|
194
|
+
* What a pusher does so Git sends each file past `most` whole, past its next gc too, or keeps it
|
|
195
|
+
* out of the pack with Git LFS: `packObjectBytes`' 16m, or a smaller host's step's in KiB.
|
|
196
|
+
*/
|
|
197
|
+
const wholeHintOf = (most) => `Set \`git config core.bigFileThreshold ${most % 1048576 === 0 ? `${most / 1048576}m` : `${Math.floor(most / 1024)}k`}\`, run \`git repack -adf\`, then push again, or track the file with Git LFS`;
|
|
198
|
+
/**
|
|
199
|
+
* A delta whose base or result is past `most`, `packObjectBytes` or a push upload's step's largest
|
|
200
|
+
* entry: Git sends one for a file it holds as a delta, so its hint has Git hold files that size whole. Its reason is its own, not
|
|
161
201
|
* `object-too-large`: the same file sent whole is taken, so a pack that names its base outside it
|
|
162
202
|
* fails where one holding the file alone lands.
|
|
163
203
|
*/
|
|
164
|
-
const deltaTooLarge = (offset) => gitError("RESOURCE_EXHAUSTED", `The delta at ${offset} is of an object past the ${
|
|
165
|
-
hint:
|
|
204
|
+
const deltaTooLarge = (offset, most) => gitError("RESOURCE_EXHAUSTED", `The delta at ${offset} is of an object past the ${most.toLocaleString("en-US")} bytes this server resolves`, {
|
|
205
|
+
hint: wholeHintOf(most),
|
|
166
206
|
context: { reason: "delta-too-large" }
|
|
167
207
|
});
|
|
168
208
|
/** A whole object past `packObjectBytes` that isn't a file. */
|
|
169
209
|
const wholeTooLarge = (offset, kind) => gitError("RESOURCE_EXHAUSTED", `The ${kind} at ${offset} is past the ${packObjectBytes.toLocaleString("en-US")} bytes this server reads whole`, { context: { reason: "object-too-large" } });
|
|
170
210
|
/** A file past `packObjectBytes` that a tree names as its `.gitmodules` or `.gitattributes`. */
|
|
171
211
|
const checkedTooLarge = (offset) => gitError("RESOURCE_EXHAUSTED", `The .gitmodules or .gitattributes at ${offset} is past the ${packObjectBytes.toLocaleString("en-US")} bytes this server reads to check it`, { context: { reason: "object-too-large" } });
|
|
172
|
-
/** An entry the indexer found no place for, as the push's refusal. */
|
|
173
|
-
const unindexable = (offset, why) => {
|
|
174
|
-
if (why === "too big") return deltaTooLarge(offset);
|
|
212
|
+
/** An entry the indexer found no place for, as the push's refusal, `most` the largest it resolves. */
|
|
213
|
+
const unindexable = (offset, why, most = packObjectBytes) => {
|
|
214
|
+
if (why === "too big") return deltaTooLarge(offset, most);
|
|
175
215
|
if (why === "too deep") return gitError("RESOURCE_EXHAUSTED", `The delta at ${offset} is in too long a chain`, {
|
|
176
216
|
hint: deepHint,
|
|
177
217
|
context: { reason: "too-large" }
|
|
@@ -226,7 +266,8 @@ const startUpload = (bucket, key, input) => Effect.map(startPut(bucket, key, pac
|
|
|
226
266
|
*/
|
|
227
267
|
const receivePack = /* @__PURE__ */ Effect.fnUntraced(function* (input) {
|
|
228
268
|
const { store, bucket, listed, at, prune, receive } = input;
|
|
229
|
-
|
|
269
|
+
const most = input.objectsMost ?? receiveTableMost;
|
|
270
|
+
if (receive.objects > most) return yield* Effect.fail(tooMany(receive.objects, most));
|
|
230
271
|
const past = segmentTooLarge(receive);
|
|
231
272
|
if (past !== void 0) return yield* Effect.fail(past);
|
|
232
273
|
const opened = yield* openQuarantine({
|
|
@@ -393,6 +434,12 @@ const storePack = /* @__PURE__ */ Effect.fnUntraced(function* (input, opened, st
|
|
|
393
434
|
}, step && stepOf(step, carried?.state.links));
|
|
394
435
|
const checked = carried?.checked ?? receiveChecked();
|
|
395
436
|
const pointers = memory.pointers;
|
|
437
|
+
const listing = step === void 0 || step.largest !== void 0;
|
|
438
|
+
const largest = new LargestFiles(carried?.state.largest);
|
|
439
|
+
const limited = step?.largest === void 0 ? void 0 : listingLimits(step.largest.entryMost);
|
|
440
|
+
let inflated = 0;
|
|
441
|
+
const resolveMost = limited?.indexer.objectBytes ?? 16777216;
|
|
442
|
+
const refused = (offset, why) => unindexable(offset, why, resolveMost);
|
|
396
443
|
const indexer = new PackIndexer({
|
|
397
444
|
entryAt: (offset, before) => {
|
|
398
445
|
if (state.stored === void 0 || state.sweepAt !== void 0 && offset !== state.sweepAt) return deferring;
|
|
@@ -406,7 +453,7 @@ const storePack = /* @__PURE__ */ Effect.fnUntraced(function* (input, opened, st
|
|
|
406
453
|
},
|
|
407
454
|
allot: memory.outside,
|
|
408
455
|
held: (offset) => state.held?.get(offset)
|
|
409
|
-
}, packIndexerLimits, new IndexerCache(memory.cache));
|
|
456
|
+
}, limited?.indexer ?? packIndexerLimits, new IndexerCache(memory.cache));
|
|
410
457
|
const malformedDelta = (error) => malformedPack(error.message);
|
|
411
458
|
/**
|
|
412
459
|
* The pack's own object `oid`, as the table finds it by its hash: its slot, with a found row so
|
|
@@ -504,7 +551,7 @@ const storePack = /* @__PURE__ */ Effect.fnUntraced(function* (input, opened, st
|
|
|
504
551
|
});
|
|
505
552
|
return checkBytesFrom(oid, type, next, shallowCommit, boundaryCommit, graphed, 0);
|
|
506
553
|
};
|
|
507
|
-
const checkResolved = (oid, type, offset, resolved) => resolved.kind === "unindexable" ? Effect.fail(
|
|
554
|
+
const checkResolved = (oid, type, offset, resolved) => resolved.kind === "unindexable" ? Effect.fail(refused(offset, resolved.why)) : checkBytes(oid, type, resolved.object.bytes);
|
|
508
555
|
/** The object at `offset`, `oid` of `type`, checked as `checkBytes` says, or deferred for sweeps. */
|
|
509
556
|
const check = (oid, type, offset) => {
|
|
510
557
|
const resolved = indexer.resolve(offset);
|
|
@@ -514,13 +561,13 @@ const storePack = /* @__PURE__ */ Effect.fnUntraced(function* (input, opened, st
|
|
|
514
561
|
/** A check that waited for the sweeps: the object at `offset`, its ID hashed again from its bytes. */
|
|
515
562
|
const checkAt = Effect.fnUntraced(function* (offset, type) {
|
|
516
563
|
const resolved = yield* stepEffect(indexer.resolve(offset));
|
|
517
|
-
if (resolved.kind === "unindexable") return yield* Effect.fail(
|
|
564
|
+
if (resolved.kind === "unindexable") return yield* Effect.fail(refused(offset, resolved.why));
|
|
518
565
|
const { bytes } = resolved.object;
|
|
519
566
|
const checkedBytes = checkBytes(idOf(type, bytes), type, bytes);
|
|
520
567
|
if (checkedBytes !== void 0) yield* checkedBytes;
|
|
521
568
|
});
|
|
522
569
|
const readPointerResolved = (oid, offset, resolved) => {
|
|
523
|
-
if (resolved.kind === "unindexable") return Effect.fail(
|
|
570
|
+
if (resolved.kind === "unindexable") return Effect.fail(refused(offset, resolved.why));
|
|
524
571
|
if (lfsPointerOfBlob(resolved.object.bytes) === void 0) return void 0;
|
|
525
572
|
return pointers.add(oid, resolved.object.bytes);
|
|
526
573
|
};
|
|
@@ -554,7 +601,7 @@ const storePack = /* @__PURE__ */ Effect.fnUntraced(function* (input, opened, st
|
|
|
554
601
|
*/
|
|
555
602
|
const placed = (indexed, ended) => {
|
|
556
603
|
const whole = state.large.get(indexed.offset);
|
|
557
|
-
if (whole === void 0 || indexed.oid === void 0) return Effect.fail(
|
|
604
|
+
if (whole === void 0 || indexed.oid === void 0) return Effect.fail(refused(indexed.offset, indexed.why));
|
|
558
605
|
const { kind, size } = whole;
|
|
559
606
|
if (kind !== "blob") return Effect.fail(wholeTooLarge(indexed.offset, kind));
|
|
560
607
|
return {
|
|
@@ -577,7 +624,10 @@ const storePack = /* @__PURE__ */ Effect.fnUntraced(function* (input, opened, st
|
|
|
577
624
|
});
|
|
578
625
|
const slot = recorded.add(object.oid, object.offset, type);
|
|
579
626
|
if (chain !== void 0) recorded.setChain(slot, chain.links, chain.units, chain.base);
|
|
580
|
-
if (type === "blob")
|
|
627
|
+
if (type === "blob") {
|
|
628
|
+
largest.add(object.oid, indexed.size);
|
|
629
|
+
return ReceivedPointers.mayHold(indexed.size) ? readPointer(object.oid, object.offset) : void 0;
|
|
630
|
+
}
|
|
581
631
|
return check(object.oid, type, object.offset);
|
|
582
632
|
};
|
|
583
633
|
const settleObject = (recorded, indexed, chain, until) => {
|
|
@@ -598,6 +648,7 @@ const storePack = /* @__PURE__ */ Effect.fnUntraced(function* (input, opened, st
|
|
|
598
648
|
const indexed = given.kind === "unindexable" ? placed(given, ended) : given;
|
|
599
649
|
if (Effect.isEffect(indexed)) return indexed;
|
|
600
650
|
const { object } = indexed;
|
|
651
|
+
if (indexed.base !== void 0) inflated += indexed.size;
|
|
601
652
|
const base = indexed.base === void 0 || ended.base?.kind !== "oid" ? void 0 : {
|
|
602
653
|
oid: ended.base.oid,
|
|
603
654
|
offset: indexed.base
|
|
@@ -623,7 +674,7 @@ const storePack = /* @__PURE__ */ Effect.fnUntraced(function* (input, opened, st
|
|
|
623
674
|
const records = state.table;
|
|
624
675
|
const base = ended.base?.kind === "oid" ? ended.base.oid : void 0;
|
|
625
676
|
let slot = base === void 0 ? void 0 : recordOf(base);
|
|
626
|
-
if (records !== void 0 && base !== void 0 && slot === void 0) return records.awaited(base, ended.offset) ? void 0 : yield* Effect.fail(
|
|
677
|
+
if (records !== void 0 && base !== void 0 && slot === void 0) return records.awaited(base, ended.offset) ? void 0 : yield* Effect.fail(refused(ended.offset, "base not before"));
|
|
627
678
|
const sibling = slot !== void 0 && slot === state.walked;
|
|
628
679
|
state.walked = slot;
|
|
629
680
|
for (let link = 0, until = ended.offset; records !== void 0 && slot !== void 0; link += 1) {
|
|
@@ -652,7 +703,8 @@ const storePack = /* @__PURE__ */ Effect.fnUntraced(function* (input, opened, st
|
|
|
652
703
|
const sink = {
|
|
653
704
|
begin: (header) => {
|
|
654
705
|
state.count = header.count;
|
|
655
|
-
|
|
706
|
+
const most = input.objectsMost ?? receiveTableMost;
|
|
707
|
+
if (state.count > most) return Effect.fail(tooMany(state.count, most));
|
|
656
708
|
const sizing = room.take(receiveTableBytes(state.count)) ?? Effect.void;
|
|
657
709
|
return Effect.map(sizing, () => {
|
|
658
710
|
state.table = receiveTable(state.count);
|
|
@@ -672,9 +724,10 @@ const storePack = /* @__PURE__ */ Effect.fnUntraced(function* (input, opened, st
|
|
|
672
724
|
indexer.data(bytes);
|
|
673
725
|
},
|
|
674
726
|
entryEnd: (ended) => {
|
|
727
|
+
inflated += ended.size;
|
|
675
728
|
const done = entryEnded(ended);
|
|
676
729
|
if (step === void 0) return done;
|
|
677
|
-
const pauseAfter = () => ended.index + 1 < state.count && step.pause(ended.index + 1, ended.offset + ended.compressed) ? "pause" : void 0;
|
|
730
|
+
const pauseAfter = () => ended.index + 1 < state.count && step.pause(ended.index + 1, ended.offset + ended.compressed, inflated) ? "pause" : void 0;
|
|
678
731
|
return done === void 0 ? pauseAfter() : Effect.map(done, pauseAfter);
|
|
679
732
|
}
|
|
680
733
|
};
|
|
@@ -707,6 +760,7 @@ const storePack = /* @__PURE__ */ Effect.fnUntraced(function* (input, opened, st
|
|
|
707
760
|
linkedRows: [...state.linkedRows],
|
|
708
761
|
parents: [...state.parents],
|
|
709
762
|
large: [...state.large],
|
|
763
|
+
...step?.largest !== void 0 && { largest: largest.finish() },
|
|
710
764
|
...ended && { joining: {
|
|
711
765
|
leftOut: ended.leftOut,
|
|
712
766
|
otherRuns: ended.otherRuns
|
|
@@ -731,7 +785,8 @@ const storePack = /* @__PURE__ */ Effect.fnUntraced(function* (input, opened, st
|
|
|
731
785
|
const teed = { read: body.read.pipe(Effect.mapError(readFailure), Effect.tap((piece) => piece === void 0 || upload === void 0 ? Effect.void : upload.send(piece))) };
|
|
732
786
|
const hasher = step === void 0 ? nativeSha1Hasher() : stagedHash(step.staged.checksum);
|
|
733
787
|
const indexed = Effect.gen(function* () {
|
|
734
|
-
const
|
|
788
|
+
const limits = step === void 0 ? receiveLimits : limited?.reader ?? stepLimits;
|
|
789
|
+
const read = yield* readPackFrom(teed, hasher, sink, limits, meter, resume).pipe(Effect.mapError((error) => error instanceof DeltaError ? malformedDelta(error) : readFailure(error)), Effect.ensuring(body.cancel));
|
|
735
790
|
if (upload !== void 0 && !("paused" in read)) yield* upload.finish(read.bytes);
|
|
736
791
|
return read;
|
|
737
792
|
}).pipe(Effect.onError(() => upload?.abort ?? Effect.void));
|
|
@@ -749,7 +804,7 @@ const storePack = /* @__PURE__ */ Effect.fnUntraced(function* (input, opened, st
|
|
|
749
804
|
/** A deferred entry read again in a sweep: its header, its data, then its end as it streamed. */
|
|
750
805
|
const sweepEntry = Effect.fnUntraced(function* (row) {
|
|
751
806
|
const entry = yield* reader.blocks.entryAt(pack, row.offset, (each) => memory.outside(each.size));
|
|
752
|
-
if (entry === "too big") return yield* Effect.fail(
|
|
807
|
+
if (entry === "too big") return yield* Effect.fail(refused(row.offset, "too big"));
|
|
753
808
|
const ended = {
|
|
754
809
|
...entry.entry,
|
|
755
810
|
compressed: row.compressed,
|
|
@@ -873,7 +928,7 @@ const storePack = /* @__PURE__ */ Effect.fnUntraced(function* (input, opened, st
|
|
|
873
928
|
if (slot === void 0 || state.table === void 0) return void 0;
|
|
874
929
|
const offset = state.table.offsetAt(slot);
|
|
875
930
|
const resolved = yield* stepEffect(indexer.resolve(offset));
|
|
876
|
-
if (resolved.kind === "unindexable") return yield* Effect.fail(state.large.has(offset) ? checkedTooLarge(offset) :
|
|
931
|
+
if (resolved.kind === "unindexable") return yield* Effect.fail(state.large.has(offset) ? checkedTooLarge(offset) : refused(offset, resolved.why));
|
|
877
932
|
const { kind, bytes } = resolved.object;
|
|
878
933
|
if (idOf(kind, bytes) !== oid) return yield* Effect.fail(foundWrongly);
|
|
879
934
|
return {
|
|
@@ -1001,6 +1056,9 @@ const storePack = /* @__PURE__ */ Effect.fnUntraced(function* (input, opened, st
|
|
|
1001
1056
|
};
|
|
1002
1057
|
const rooted = roots?.roots();
|
|
1003
1058
|
if (rooted !== void 0) quarantine.roots = rooted;
|
|
1059
|
+
const kept = listing ? largest.finish() : void 0;
|
|
1060
|
+
if (kept?.largest !== void 0) quarantine.largest = kept.largest;
|
|
1061
|
+
if (kept?.largestPartial === true) quarantine.largestPartial = true;
|
|
1004
1062
|
if (leftOut.length > 0) quarantine.cut = leftOut;
|
|
1005
1063
|
if (named && state.linkedRows.size <= 64) quarantine.linked = {
|
|
1006
1064
|
packs: [...state.linkedPacks],
|