@rigxyz/tapd 0.6.8 → 0.6.10

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/bin.js CHANGED
@@ -17,6 +17,7 @@ import {
17
17
  importStateDbPath,
18
18
  init,
19
19
  isSyncPaused,
20
+ isVersionPrunedError,
20
21
  join,
21
22
  list,
22
23
  loadIgnore,
@@ -31,7 +32,7 @@ import {
31
32
  revoke,
32
33
  safeResolveRigPath,
33
34
  start
34
- } from "./chunk-S5AVBVLP.js";
35
+ } from "./chunk-Q3PIHOTA.js";
35
36
 
36
37
  // src/bin.ts
37
38
  import { join as pathJoin, resolve } from "path";
@@ -215,6 +216,18 @@ var PathCurrentlyDeletedError = class extends Error {
215
216
  path;
216
217
  lastCursor;
217
218
  };
219
+ var VersionPrunedError = class extends Error {
220
+ constructor(path, cursor) {
221
+ super(
222
+ "That version is no longer kept. Rig keeps every version from the last week, one an hour for 90 days, then one a day."
223
+ );
224
+ this.path = path;
225
+ this.cursor = cursor;
226
+ this.name = "VersionPrunedError";
227
+ }
228
+ path;
229
+ cursor;
230
+ };
218
231
  var HashMismatchError = class extends Error {
219
232
  constructor(path, expected, actual) {
220
233
  super(`Hash mismatch restoring "${path}": expected ${expected}, got ${actual}`);
@@ -259,7 +272,13 @@ async function restore(opts) {
259
272
  throw new PathNeverExistedError(opts.path);
260
273
  }
261
274
  const client = clientFor3(opts.rootDir, opts.fetch);
262
- const dl = await client.downloadUrl(writeEvent.hash);
275
+ let dl;
276
+ try {
277
+ dl = await client.downloadUrl(writeEvent.hash);
278
+ } catch (err) {
279
+ if (isVersionPrunedError(err)) throw new VersionPrunedError(opts.path, writeEvent.id);
280
+ throw err;
281
+ }
263
282
  const bytes = await client.getObjectBytes(dl.downloadUrl);
264
283
  const actualHash = `sha256:${sha256Hex(bytes)}`;
265
284
  if (actualHash !== writeEvent.hash) {
@@ -285,7 +304,7 @@ import { existsSync as existsSync4 } from "fs";
285
304
  import { join as join4 } from "path";
286
305
 
287
306
  // src/version.ts
288
- var TAPD_VERSION = "0.6.8";
307
+ var TAPD_VERSION = "0.6.10";
289
308
 
290
309
  // src/status.ts
291
310
  var STATE_KEY_LAST_APPLY_ERROR = "last_apply_error";
@@ -1399,6 +1418,11 @@ async function runRestore(flags2) {
1399
1418
  else console.error(kleur.red("error:"), err.message);
1400
1419
  process.exit(1);
1401
1420
  }
1421
+ if (err instanceof VersionPrunedError) {
1422
+ if (json) printJsonError("version_pruned", err.message);
1423
+ else console.error(kleur.red("error:"), err.message);
1424
+ process.exit(1);
1425
+ }
1402
1426
  if (err instanceof HashMismatchError) {
1403
1427
  if (json) printJsonError("hash_mismatch", err.message);
1404
1428
  else console.error(kleur.red("error:"), err.message);