@@ -68,10 +68,6 @@ function getInstanceOfY(room) {
68
68
}
69
69
return yInstances [ room ] ;
70
70
}
71
- function removeInstanceOfY ( room ) {
72
- delete yInstances [ room ] ;
73
- delete metadata [ room ] ;
74
- }
75
71
76
72
function getSha1Hash ( plaintext ) {
77
73
const sha1 = crypto . createHash ( 'sha1' ) ;
@@ -97,13 +93,7 @@ router.post('/deletePage', async (req, res) => {
97
93
res . setHeader ( 'Access-Control-Allow-Origin' , '*' ) ;
98
94
res . setHeader ( 'Content-Type' , 'application/json' ) ;
99
95
const room = req . body ;
100
- const yPromise = yInstances [ room ] ;
101
- if ( ! yPromise ) {
102
- res . end ( JSON . stringify ( { status : 'FAILURE' , msg : 'No y instance' } ) ) ;
103
- return ;
104
- }
105
96
try {
106
- const y = await yPromise ;
107
97
const roomMetadata = metadata [ room ] ;
108
98
if ( ! roomMetadata ) {
109
99
res . end ( JSON . stringify ( { status : 'FAILURE' , msg : 'No metadata' } ) ) ;
@@ -113,17 +103,12 @@ router.post('/deletePage', async (req, res) => {
113
103
res . end ( JSON . stringify ( { status : 'FAILURE' , msg : 'There are still users on this page' } ) ) ;
114
104
return ;
115
105
}
116
- try {
117
- await y . destroy ( ) ;
118
- removeInstanceOfY ( room ) ;
119
- res . end ( JSON . stringify ( { status : 'SUCCESS' , msg : `Delete ${ room } ` } ) ) ;
120
- } catch ( ex ) {
121
- console . error ( ex ) ;
122
- res . end ( JSON . stringify ( { status : 'FAILURE' , msg : 'Y instance destroy error' } ) ) ;
123
- }
106
+ await LevelDBLib . deleteDatabase ( 'y-leveldb-databases' , room ) ;
107
+ delete metadata [ room ] ;
108
+ res . end ( JSON . stringify ( { status : 'SUCCESS' , msg : `Delete ${ room } ` } ) ) ;
124
109
} catch ( ex ) {
125
110
console . error ( ex ) ;
126
- res . end ( JSON . stringify ( { status : 'FAILURE' , msg : ex } ) ) ;
111
+ res . end ( JSON . stringify ( { status : 'FAILURE' , msg : 'Failed to delete database' } ) ) ;
127
112
}
128
113
} ) ;
129
114
0 commit comments