@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
|
@@ -0,0 +1,251 @@
|
|
|
1
|
+
import { gitError } from "../contracts/result.mjs";
|
|
2
|
+
import { importLfsPagesMost, importRow, lfsMissedHeld, lfsPageKey, lfsPageRow, missedCounted, noImportLfs, readLfsPage } from "../core/imports.mjs";
|
|
3
|
+
import { CoreParts } from "../core/parts.mjs";
|
|
4
|
+
import { largestObject } from "../lfs/rows.mjs";
|
|
5
|
+
import { lfsOidAt, lfsSizeAt, pointersOfRecord, pointersRecords } from "../storage/lfs-pointers.mjs";
|
|
6
|
+
import { storeCall } from "../store/errors.mjs";
|
|
7
|
+
import { newChangeId, repoScope } from "../store/scopes.mjs";
|
|
8
|
+
import { lfsCopyBytes } from "./bound.mjs";
|
|
9
|
+
import { letGo, lfsDownloads } from "./lfs-batch.mjs";
|
|
10
|
+
import { bodyUntil } from "./http.mjs";
|
|
11
|
+
import { remoteOf, senderOf } from "./tries.mjs";
|
|
12
|
+
import * as Effect from "effect/Effect";
|
|
13
|
+
import * as Result from "effect/Result";
|
|
14
|
+
import * as Stream from "effect/Stream";
|
|
15
|
+
// src/sync/lfs-copy.ts
|
|
16
|
+
/**
|
|
17
|
+
* `row` with the pointers a segment's receive `found` kept as pages beside it, `put` in the commit
|
|
18
|
+
* that lands the segment, when `copying`: on a server without LFS, `row` as it was. Past
|
|
19
|
+
* `importLfsPagesMost` pages, the pointers are counted missing, unnamed.
|
|
20
|
+
*/
|
|
21
|
+
const withLfsPages = (row, found, copying) => {
|
|
22
|
+
const none = [];
|
|
23
|
+
if (!copying) return {
|
|
24
|
+
row,
|
|
25
|
+
put: none
|
|
26
|
+
};
|
|
27
|
+
const lfs = row.lfs ?? noImportLfs;
|
|
28
|
+
const records = found === void 0 ? [] : pointersRecords(found);
|
|
29
|
+
const kept = records.slice(0, Math.max(0, importLfsPagesMost - lfs.pages));
|
|
30
|
+
const dropped = records.slice(kept.length).reduce((sum, record) => sum + record.byteLength / 57, 0);
|
|
31
|
+
const put = kept.map((record, at) => lfsPageRow(lfs.pages + at, record));
|
|
32
|
+
return {
|
|
33
|
+
row: {
|
|
34
|
+
...row,
|
|
35
|
+
lfs: {
|
|
36
|
+
...lfs,
|
|
37
|
+
pages: lfs.pages + kept.length,
|
|
38
|
+
missing: lfs.missing + dropped
|
|
39
|
+
}
|
|
40
|
+
},
|
|
41
|
+
put
|
|
42
|
+
};
|
|
43
|
+
};
|
|
44
|
+
/**
|
|
45
|
+
* What one step asks for: the distinct objects of `pointers` from entry `from`, up to
|
|
46
|
+
* `lfsBatchMost` of them, or until the next would take the step past `lfsCopyBytes`, an object
|
|
47
|
+
* past it alone; and `end`, the entry after the last taken. An object past `largestObject` is
|
|
48
|
+
* never downloaded, so it takes none of the bytes.
|
|
49
|
+
*/
|
|
50
|
+
const takenFrom = (pointers, from) => {
|
|
51
|
+
const wanted = [];
|
|
52
|
+
const seen = /* @__PURE__ */ new Set();
|
|
53
|
+
let bytes = 0;
|
|
54
|
+
let end = from;
|
|
55
|
+
for (; end < pointers.count; end += 1) {
|
|
56
|
+
const oid = lfsOidAt(pointers, end);
|
|
57
|
+
if (seen.has(oid)) continue;
|
|
58
|
+
const size = lfsSizeAt(pointers, end);
|
|
59
|
+
const taking = size > largestObject ? 0 : size;
|
|
60
|
+
if (wanted.length === 100) break;
|
|
61
|
+
if (wanted.length > 0 && bytes + taking > lfsCopyBytes) break;
|
|
62
|
+
seen.add(oid);
|
|
63
|
+
wanted.push({
|
|
64
|
+
oid,
|
|
65
|
+
size
|
|
66
|
+
});
|
|
67
|
+
bytes += taking;
|
|
68
|
+
}
|
|
69
|
+
return {
|
|
70
|
+
wanted,
|
|
71
|
+
end
|
|
72
|
+
};
|
|
73
|
+
};
|
|
74
|
+
const pageUnreadable = (page) => gitError("DATA_LOSS", `The import's page ${page} of LFS pointers isn't a page of pointers`);
|
|
75
|
+
const copyRaced = () => gitError("UNAVAILABLE", "Another write moved the import while its LFS copy ran", { hint: "The job tries again" });
|
|
76
|
+
const downloadUnanswered = /* @__PURE__ */ gitError("UNAVAILABLE", "The source's LFS download didn't answer", { hint: "The job tries again" });
|
|
77
|
+
/** A download refused, by its status alone: an expired link's 401 or 403, or the store's 5xx. */
|
|
78
|
+
const downloadRefused = (status) => gitError("UNAVAILABLE", `The source's LFS download answered ${status}`, { hint: "The job tries again, with fresh links" });
|
|
79
|
+
/** The copy's progress, which a claim taken again refuses: the sample's dropped, as `report`'s. */
|
|
80
|
+
const reported = (context, lfs) => context.progress({
|
|
81
|
+
phase: "lfs",
|
|
82
|
+
measures: [{
|
|
83
|
+
unit: "objects",
|
|
84
|
+
completed: lfs.copied
|
|
85
|
+
}, {
|
|
86
|
+
unit: "bytes",
|
|
87
|
+
completed: lfs.bytes
|
|
88
|
+
}]
|
|
89
|
+
});
|
|
90
|
+
/**
|
|
91
|
+
* One offer's bytes, piped from its link to `staging`'s key as they come: `landed`, `not-found`
|
|
92
|
+
* for a link that answers 404 or 410, or `other-bytes` for bytes the bucket refused as not the
|
|
93
|
+
* oid's or not its size. Any other refusal fails, so the job tries again with fresh links.
|
|
94
|
+
*/
|
|
95
|
+
const downloaded = /* @__PURE__ */ Effect.fnUntraced(function* (send, offer, staging, copy, signal) {
|
|
96
|
+
const request = new Request(offer.href, {
|
|
97
|
+
headers: offer.header,
|
|
98
|
+
signal
|
|
99
|
+
});
|
|
100
|
+
const response = yield* Effect.mapError(send(request), () => downloadUnanswered);
|
|
101
|
+
const { body } = response;
|
|
102
|
+
if (response.status === 404 || response.status === 410) {
|
|
103
|
+
yield* letGo(response);
|
|
104
|
+
return "not-found";
|
|
105
|
+
}
|
|
106
|
+
if (response.status !== 200 || body === null) {
|
|
107
|
+
yield* letGo(response);
|
|
108
|
+
return yield* Effect.fail(downloadRefused(response.status));
|
|
109
|
+
}
|
|
110
|
+
const bytes = Stream.fromReadableStream({
|
|
111
|
+
evaluate: () => bodyUntil(body, signal),
|
|
112
|
+
onError: () => downloadUnanswered
|
|
113
|
+
});
|
|
114
|
+
const put = yield* Effect.result(copy.put(staging, bytes, offer.size, offer.oid));
|
|
115
|
+
if (Result.isSuccess(put)) return "landed";
|
|
116
|
+
if (put.failure.code === "INVALID_ARGUMENT") return "other-bytes";
|
|
117
|
+
return yield* Effect.fail(put.failure);
|
|
118
|
+
});
|
|
119
|
+
/**
|
|
120
|
+
* The copy's commit at `version`: each object in `landed` listed and its staging row dropped,
|
|
121
|
+
* each in `missed` the record doesn't name yet counted, and named, as `missedCounted` says, and
|
|
122
|
+
* the cursor moved to `cursor`, the page's row deleted once it's past. Without a cursor, the
|
|
123
|
+
* landed objects alone, as a step that failed partway keeps them, so its next try skips them.
|
|
124
|
+
*/
|
|
125
|
+
const committed = /* @__PURE__ */ Effect.fnUntraced(function* (attempt, copy, version, row, lfs, landed, missed, cursor) {
|
|
126
|
+
const { store } = yield* CoreParts;
|
|
127
|
+
const writes = copy.listing(landed);
|
|
128
|
+
const held = yield* lfsMissedHeld(store, attempt.internalId, missed.map(({ oid }) => oid));
|
|
129
|
+
const counted = missedCounted(lfs, missed, held);
|
|
130
|
+
const passed = cursor !== void 0 && cursor.end >= cursor.count;
|
|
131
|
+
const moved = cursor === void 0 ? {} : passed ? {
|
|
132
|
+
page: lfs.page + 1,
|
|
133
|
+
entry: 0
|
|
134
|
+
} : {
|
|
135
|
+
page: lfs.page,
|
|
136
|
+
entry: cursor.end
|
|
137
|
+
};
|
|
138
|
+
const next = {
|
|
139
|
+
...lfs,
|
|
140
|
+
...moved,
|
|
141
|
+
copied: lfs.copied + landed.length,
|
|
142
|
+
bytes: lfs.bytes + landed.reduce((sum, { size }) => sum + size, 0),
|
|
143
|
+
missing: counted.missing,
|
|
144
|
+
named: counted.named
|
|
145
|
+
};
|
|
146
|
+
if (!(yield* storeCall(() => store.commit(repoScope(attempt.internalId), {
|
|
147
|
+
id: newChangeId(),
|
|
148
|
+
expect: version,
|
|
149
|
+
put: [
|
|
150
|
+
importRow({
|
|
151
|
+
...row,
|
|
152
|
+
lfs: next
|
|
153
|
+
}),
|
|
154
|
+
...writes.put,
|
|
155
|
+
...counted.put
|
|
156
|
+
],
|
|
157
|
+
delete: [...writes.delete, ...passed ? [lfsPageKey(lfs.page)] : []]
|
|
158
|
+
}))).ok) return yield* Effect.fail(copyRaced());
|
|
159
|
+
return next;
|
|
160
|
+
});
|
|
161
|
+
/**
|
|
162
|
+
* Each distinct object of `pointers` from `from` but those `listed`, missing as a source with no
|
|
163
|
+
* LFS API leaves it: `too-large` for one LFS keeps none of anyway.
|
|
164
|
+
*/
|
|
165
|
+
const restMissing = (pointers, from, listed) => {
|
|
166
|
+
const missed = /* @__PURE__ */ new Map();
|
|
167
|
+
for (let at = from; at < pointers.count; at += 1) {
|
|
168
|
+
const oid = lfsOidAt(pointers, at);
|
|
169
|
+
if (!listed.has(oid) && !missed.has(oid)) {
|
|
170
|
+
const size = lfsSizeAt(pointers, at);
|
|
171
|
+
missed.set(oid, {
|
|
172
|
+
oid,
|
|
173
|
+
size,
|
|
174
|
+
reason: size > largestObject ? "too-large" : "no-lfs"
|
|
175
|
+
});
|
|
176
|
+
}
|
|
177
|
+
}
|
|
178
|
+
return [...missed.values()];
|
|
179
|
+
};
|
|
180
|
+
/**
|
|
181
|
+
* One step of the copy, at the import's record as read at `version`: the objects `takenFrom` the
|
|
182
|
+
* cursor's page that the repo doesn't list, asked of the source in one batch, each download piped
|
|
183
|
+
* to its own staging key, one at a time, then one commit. A source with no LFS API gives none, so
|
|
184
|
+
* the rest of the page is missing with them. A download that fails keeps what landed before it
|
|
185
|
+
* and fails the try, whose next asks a fresh batch from the cursor.
|
|
186
|
+
*/
|
|
187
|
+
const copyLfs = /* @__PURE__ */ Effect.fnUntraced(function* (attempt, version, row, lfs, copy) {
|
|
188
|
+
const { bound, internalId, context } = attempt;
|
|
189
|
+
const { store } = yield* CoreParts;
|
|
190
|
+
const pointers = pointersOfRecord(yield* readLfsPage(store, internalId, lfs.page));
|
|
191
|
+
if (pointers === void 0) return yield* Effect.fail(pageUnreadable(lfs.page));
|
|
192
|
+
yield* reported(context, lfs);
|
|
193
|
+
const { wanted, end } = takenFrom(pointers, lfs.entry);
|
|
194
|
+
const listed = yield* copy.listed(internalId, wanted.map(({ oid }) => oid));
|
|
195
|
+
const unlisted = wanted.filter(({ oid }) => !listed.has(oid));
|
|
196
|
+
const tooLarge = unlisted.flatMap(({ oid, size }) => size > largestObject ? [{
|
|
197
|
+
oid,
|
|
198
|
+
size,
|
|
199
|
+
reason: "too-large"
|
|
200
|
+
}] : []);
|
|
201
|
+
const asked = unlisted.filter(({ size }) => size <= largestObject);
|
|
202
|
+
if (asked.length === 0) return yield* committed(attempt, copy, version, row, lfs, [], tooLarge, {
|
|
203
|
+
end,
|
|
204
|
+
count: pointers.count
|
|
205
|
+
});
|
|
206
|
+
const remote = yield* remoteOf(bound, row.source, context.signal, "read");
|
|
207
|
+
const send = yield* senderOf(remote);
|
|
208
|
+
const batch = yield* lfsDownloads(send, remote, asked, context.signal);
|
|
209
|
+
if (batch.kind === "no-lfs") {
|
|
210
|
+
const missed = restMissing(pointers, lfs.entry, listed);
|
|
211
|
+
return yield* committed(attempt, copy, version, row, lfs, [], missed, {
|
|
212
|
+
end: pointers.count,
|
|
213
|
+
count: pointers.count
|
|
214
|
+
});
|
|
215
|
+
}
|
|
216
|
+
const missed = [...tooLarge];
|
|
217
|
+
const downloads = [];
|
|
218
|
+
for (const offer of batch.offers) if (offer.kind === "download") downloads.push(offer);
|
|
219
|
+
else missed.push({
|
|
220
|
+
oid: offer.oid,
|
|
221
|
+
size: offer.size,
|
|
222
|
+
reason: offer.reason
|
|
223
|
+
});
|
|
224
|
+
const staged = yield* copy.stage(internalId, downloads.length);
|
|
225
|
+
const landed = [];
|
|
226
|
+
for (const [index, offer] of downloads.entries()) {
|
|
227
|
+
const staging = staged[index];
|
|
228
|
+
if (staging === void 0) break;
|
|
229
|
+
const outcome = yield* Effect.result(downloaded(send, offer, staging, copy, context.signal));
|
|
230
|
+
if (Result.isFailure(outcome)) {
|
|
231
|
+
if (landed.length > 0) yield* committed(attempt, copy, version, row, lfs, landed, []);
|
|
232
|
+
return yield* Effect.fail(outcome.failure);
|
|
233
|
+
}
|
|
234
|
+
const { oid, size } = offer;
|
|
235
|
+
if (outcome.success === "landed") landed.push({
|
|
236
|
+
oid,
|
|
237
|
+
size,
|
|
238
|
+
staging
|
|
239
|
+
});
|
|
240
|
+
else missed.push({
|
|
241
|
+
oid,
|
|
242
|
+
size,
|
|
243
|
+
reason: outcome.success
|
|
244
|
+
});
|
|
245
|
+
}
|
|
246
|
+
return yield* committed(attempt, copy, version, row, lfs, landed, missed, {
|
|
247
|
+
end,
|
|
248
|
+
count: pointers.count
|
|
249
|
+
});
|
|
250
|
+
});
|
|
251
|
+
export { copyLfs, takenFrom, withLfsPages };
|