Skip to content

Commit 8aa344b

Browse files
Merge branch 'main' into test/snapshots
2 parents 41a3176 + 60ea91b commit 8aa344b

6 files changed

Lines changed: 53 additions & 0 deletions

File tree

src/commands/snapshot.ts

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,20 +6,23 @@ import {
66
createSnapshotMissionControl,
77
deleteSnapshotMissionControl,
88
downloadSnapshotMissionControl,
9+
listSnapshotMissionControl,
910
restoreSnapshotMissionControl,
1011
uploadSnapshotMissionControl
1112
} from '../services/modules/snapshot/snapshot.mission-control.services';
1213
import {
1314
createSnapshotOrbiter,
1415
deleteSnapshotOrbiter,
1516
downloadSnapshotOrbiter,
17+
listSnapshotOrbiter,
1618
restoreSnapshotOrbiter,
1719
uploadSnapshotOrbiter
1820
} from '../services/modules/snapshot/snapshot.orbiter.services';
1921
import {
2022
createSnapshotSatellite,
2123
deleteSnapshotSatellite,
2224
downloadSnapshotSatellite,
25+
listSnapshotSatellite,
2326
restoreSnapshotSatellite,
2427
uploadSnapshotSatellite
2528
} from '../services/modules/snapshot/snapshot.satellite.services';
@@ -44,6 +47,14 @@ export const snapshot = async (args?: string[]) => {
4447
orbiterFn: restoreSnapshotOrbiter
4548
});
4649
break;
50+
case 'list':
51+
await executeSnapshotFn({
52+
args,
53+
satelliteFn: listSnapshotSatellite,
54+
missionControlFn: listSnapshotMissionControl,
55+
orbiterFn: listSnapshotOrbiter
56+
});
57+
break;
4758
case 'delete':
4859
await executeSnapshotFn({
4960
args,

src/help/snapshot.help.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@ Subcommands:
1515
${magenta('create')} Create a snapshot of your current state.
1616
${magenta('delete')} Delete an existing snapshot.
1717
${magenta('download')} Download a snapshot to offline files.
18+
${magenta('list')} List the existing snapshot.
1819
${magenta('upload')} ${SNAPSHOT_UPLOAD_DESCRIPTION}
1920
${magenta('restore')} Restore a previously created snapshot.
2021

src/services/modules/snapshot/snapshot.mission-control.services.ts

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ import {
66
createSnapshot,
77
deleteSnapshot,
88
downloadSnapshot,
9+
listSnapshot,
910
restoreSnapshot,
1011
uploadSnapshot
1112
} from './snapshot.services';
@@ -22,6 +23,12 @@ export const restoreSnapshotMissionControl = async () => {
2223
});
2324
};
2425

26+
export const listSnapshotMissionControl = async () => {
27+
await executeSnapshotFn({
28+
fn: listSnapshot
29+
});
30+
};
31+
2532
export const deleteSnapshotMissionControl = async () => {
2633
await executeSnapshotFn({
2734
fn: deleteSnapshot

src/services/modules/snapshot/snapshot.orbiter.services.ts

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ import {
44
createSnapshot,
55
deleteSnapshot,
66
downloadSnapshot,
7+
listSnapshot,
78
restoreSnapshot,
89
uploadSnapshot
910
} from './snapshot.services';
@@ -20,6 +21,12 @@ export const restoreSnapshotOrbiter = async () => {
2021
});
2122
};
2223

24+
export const listSnapshotOrbiter = async () => {
25+
await executeSnapshotFn({
26+
fn: listSnapshot
27+
});
28+
};
29+
2330
export const deleteSnapshotOrbiter = async () => {
2431
await executeSnapshotFn({
2532
fn: deleteSnapshot

src/services/modules/snapshot/snapshot.satellite.services.ts

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ import {
77
createSnapshot,
88
deleteSnapshot,
99
downloadSnapshot,
10+
listSnapshot,
1011
restoreSnapshot,
1112
uploadSnapshot
1213
} from './snapshot.services';
@@ -23,6 +24,12 @@ export const restoreSnapshotSatellite = async () => {
2324
});
2425
};
2526

27+
export const listSnapshotSatellite = async () => {
28+
await executeSnapshotFn({
29+
fn: listSnapshot
30+
});
31+
};
32+
2633
export const deleteSnapshotSatellite = async () => {
2734
await executeSnapshotFn({
2835
fn: deleteSnapshot

src/services/modules/snapshot/snapshot.services.ts

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -67,6 +67,26 @@ export const restoreSnapshot = async ({
6767
});
6868
};
6969

70+
export const listSnapshot = async ({
71+
canisterId: cId,
72+
segment
73+
}: {
74+
canisterId: string;
75+
segment: AssetKey;
76+
}) => {
77+
const canisterId = Principal.fromText(cId);
78+
79+
const result = await loadSnapshotAndAssertExist({canisterId, segment});
80+
81+
if (result.result === 'not_found') {
82+
return;
83+
}
84+
85+
const {snapshotId: existingSnapshotId} = result;
86+
87+
console.log(`🪣 Snapshot found: 0x${encodeSnapshotId(existingSnapshotId)}`);
88+
};
89+
7090
export const deleteSnapshot = async ({
7191
canisterId: cId,
7292
segment

0 commit comments

Comments
 (0)