File tree Expand file tree Collapse file tree 1 file changed +14
-2
lines changed
packages/app/server/api/snapshots/[snapshotId] Expand file tree Collapse file tree 1 file changed +14
-2
lines changed Original file line number Diff line number Diff line change @@ -6,11 +6,16 @@ import SuperJSON from 'superjson'
66
77export default defineEventHandler ( async ( event ) => {
88 const mq = getMq ( )
9+ const { snapshotId } = getRouterParams ( event , {
10+ decode : true ,
11+ } ) as {
12+ snapshotId : string
13+ }
914 const { id, location, description, tags } = await readBody ( event )
1015 const storage = await getSnapshotStorage ( mq )
11- const snapshot = await storage . findById ( id )
16+ const snapshot = await storage . findById ( snapshotId )
1217 if ( ! snapshot ) {
13- throw new Error ( `Snapshot ${ id } not found` )
18+ throw new Error ( `Snapshot ${ snapshotId } not found` )
1419 }
1520
1621 // Copy resources
@@ -23,9 +28,16 @@ export default defineEventHandler(async (event) => {
2328 . filter ( file => fs . statSync ( file ) . isDirectory ( ) )
2429 }
2530
31+ // Rename
32+
33+ if ( snapshot . id !== id ) {
34+ await storage . remove ( snapshot . id )
35+ }
36+
2637 // Update in storage
2738
2839 Object . assign ( snapshot , {
40+ id,
2941 location,
3042 description,
3143 tags,
You can’t perform that action at this time.
0 commit comments