amalgm 0.1.176 → 0.1.177
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/package.json
CHANGED
|
@@ -146,7 +146,10 @@ function readCheckpointValue(baseOid, value) {
|
|
|
146
146
|
}
|
|
147
147
|
|
|
148
148
|
function ownPublishedCard(card) {
|
|
149
|
-
const own = require('./wall').readWall().find((entry) =>
|
|
149
|
+
const own = require('./wall').readWall().find((entry) => (
|
|
150
|
+
entry.machine === machineId()
|
|
151
|
+
&& entry.cards?.some((candidate) => candidate.replica === card.replica)
|
|
152
|
+
));
|
|
150
153
|
const published = own?.cards?.find((candidate) => candidate.replica === card.replica);
|
|
151
154
|
if (
|
|
152
155
|
!published
|
|
@@ -38,12 +38,12 @@ function ensureDirs() {
|
|
|
38
38
|
fs.mkdirSync(REQUESTS, { recursive: true });
|
|
39
39
|
}
|
|
40
40
|
|
|
41
|
-
function payloadFile(key) {
|
|
42
|
-
return path.join(PAYLOADS, `${sha256(Buffer.from(key))}.json`);
|
|
41
|
+
function payloadFile(resourceId, key) {
|
|
42
|
+
return path.join(PAYLOADS, `${sha256(Buffer.from(`${resourceId}\n${key}`))}.json`);
|
|
43
43
|
}
|
|
44
44
|
|
|
45
|
-
function manifestFile(
|
|
46
|
-
const key = sha256(Buffer.from(`${
|
|
45
|
+
function manifestFile(resourceId, oid) {
|
|
46
|
+
const key = sha256(Buffer.from(`${resourceId}\n${oid}`));
|
|
47
47
|
return path.join(MANIFESTS, `${key}.json`);
|
|
48
48
|
}
|
|
49
49
|
|
|
@@ -127,14 +127,14 @@ async function prepareBundle(worktreeRoot, repoKey, resourceId, oid, file) {
|
|
|
127
127
|
function publishPayload(key, bytesInput, repoKey) {
|
|
128
128
|
ensureDirs();
|
|
129
129
|
const bytes = Buffer.isBuffer(bytesInput) ? bytesInput : Buffer.from(bytesInput);
|
|
130
|
-
const
|
|
131
|
-
let manifest = readJson(file);
|
|
130
|
+
const project = require('./wall').projectForRepo(repoKey);
|
|
132
131
|
const checksum = sha256(bytes);
|
|
132
|
+
if (!project?.resourceId) {
|
|
133
|
+
return { kind: 'pending', contract: PAYLOAD_CONTRACT, checksum };
|
|
134
|
+
}
|
|
135
|
+
const file = payloadFile(project.resourceId, key);
|
|
136
|
+
let manifest = readJson(file);
|
|
133
137
|
if (!manifest || manifest.checksum !== checksum) {
|
|
134
|
-
const project = require('./wall').projectForRepo(repoKey);
|
|
135
|
-
if (!project?.resourceId) {
|
|
136
|
-
return { kind: 'pending', contract: PAYLOAD_CONTRACT, checksum };
|
|
137
|
-
}
|
|
138
138
|
manifest = {
|
|
139
139
|
contract: PAYLOAD_CONTRACT,
|
|
140
140
|
resourceId: project.resourceId,
|
|
@@ -154,7 +154,9 @@ function publishPayload(key, bytesInput, repoKey) {
|
|
|
154
154
|
|
|
155
155
|
async function bundleSourceFor(worktreeRoot, repoKey, oid) {
|
|
156
156
|
if (!oid || !repoKey) return null;
|
|
157
|
-
const
|
|
157
|
+
const project = require('./wall').projectForRepo(repoKey);
|
|
158
|
+
if (!project?.resourceId) return { kind: 'pending' };
|
|
159
|
+
const file = manifestFile(project.resourceId, oid);
|
|
158
160
|
const manifest = readJson(file);
|
|
159
161
|
if (manifest?.contract === CONTRACT && manifest.oid === oid) {
|
|
160
162
|
return manifest.chunks.every((chunk) => chunk.uploaded)
|
|
@@ -162,8 +164,6 @@ async function bundleSourceFor(worktreeRoot, repoKey, oid) {
|
|
|
162
164
|
: { kind: 'pending' };
|
|
163
165
|
}
|
|
164
166
|
|
|
165
|
-
const project = require('./wall').projectForRepo(repoKey);
|
|
166
|
-
if (!project?.resourceId) return { kind: 'pending' };
|
|
167
167
|
if (!preparing.has(file)) {
|
|
168
168
|
const promise = prepareBundle(worktreeRoot, repoKey, project.resourceId, oid, file)
|
|
169
169
|
.catch((error) => console.warn(`[RepoObjects] bundle ${oid} failed:`, error.message))
|
|
@@ -105,6 +105,8 @@ function treeNodeLimitError(limit) {
|
|
|
105
105
|
function skippedTreeResult(workspaceId, limit, nodeCount = null) {
|
|
106
106
|
return {
|
|
107
107
|
workspaceId,
|
|
108
|
+
created: 0,
|
|
109
|
+
nodes: [],
|
|
108
110
|
skipped: 'node_limit',
|
|
109
111
|
maxNodes: limit,
|
|
110
112
|
...(nodeCount == null ? {} : { nodeCount }),
|
|
@@ -155,7 +157,7 @@ function enrollWorkspace(identifier, options = {}) {
|
|
|
155
157
|
const rootStats = fs.statSync(rootPath);
|
|
156
158
|
if (!rootStats.isDirectory()) throw invalid('workspace path is not a folder', 409);
|
|
157
159
|
if (isGitOwnedPath(rootPath)) {
|
|
158
|
-
return { workspaceId: workspace.id, skipped: 'git-owned' };
|
|
160
|
+
return { workspaceId: workspace.id, created: 0, nodes: [], skipped: 'git-owned' };
|
|
159
161
|
}
|
|
160
162
|
|
|
161
163
|
const maxNodes = treeNodeLimit(options);
|