aboutsummaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
authorChocobozzz <me@florianbigard.com>2018-05-15 16:52:19 +0200
committerChocobozzz <me@florianbigard.com>2018-05-16 09:42:55 +0200
commit4935a6a1fd38a31c42d1ae8b1e03aa40c475a89c (patch)
tree9bfabbca9567f97d4a2f3f64df82d1ac8745116a
parente998cf3cc757b58f06adae7a367e88b494c609d2 (diff)
downloadPeerTube-4935a6a1fd38a31c42d1ae8b1e03aa40c475a89c.tar.gz
PeerTube-4935a6a1fd38a31c42d1ae8b1e03aa40c475a89c.tar.zst
PeerTube-4935a6a1fd38a31c42d1ae8b1e03aa40c475a89c.zip
Catch indexdb database destroy
-rw-r--r--client/src/assets/player/peertube-chunk-store.ts27
1 files changed, 12 insertions, 15 deletions
diff --git a/client/src/assets/player/peertube-chunk-store.ts b/client/src/assets/player/peertube-chunk-store.ts
index 005e98a81..84fbaf146 100644
--- a/client/src/assets/player/peertube-chunk-store.ts
+++ b/client/src/assets/player/peertube-chunk-store.ts
@@ -183,25 +183,21 @@ export class PeertubeChunkStore extends EventEmitter {
183 183
184 private checkExpiration () { 184 private checkExpiration () {
185 this.expirationDB.transaction('rw', this.expirationDB.databases, async () => { 185 this.expirationDB.transaction('rw', this.expirationDB.databases, async () => {
186 try { 186 // Update our database expiration since we are alive
187 // Update our database expiration since we are alive 187 await this.expirationDB.databases.put({
188 await this.expirationDB.databases.put({ 188 name: this.databaseName,
189 name: this.databaseName, 189 expiration: new Date().getTime() + PeertubeChunkStore.CLEANER_EXPIRATION_MS
190 expiration: new Date().getTime() + PeertubeChunkStore.CLEANER_EXPIRATION_MS 190 })
191 })
192 191
193 const now = new Date().getTime() 192 const now = new Date().getTime()
194 const databasesToDeleteInfo = await this.expirationDB.databases.where('expiration').below(now).toArray() 193 const databasesToDeleteInfo = await this.expirationDB.databases.where('expiration').below(now).toArray()
195 194
196 for (const databaseToDeleteInfo of databasesToDeleteInfo) { 195 for (const databaseToDeleteInfo of databasesToDeleteInfo) {
197 await this.dropDatabase(databaseToDeleteInfo.name) 196 await this.dropDatabase(databaseToDeleteInfo.name)
198 197
199 await this.expirationDB.databases.where({ name: databaseToDeleteInfo.name }).delete() 198 await this.expirationDB.databases.where({ name: databaseToDeleteInfo.name }).delete()
200 }
201 } catch (err) {
202 console.error('Cannot check expiration.', err)
203 } 199 }
204 }) 200 }).catch(err => console.error('Cannot check expiration.', err))
205 } 201 }
206 202
207 private dropDatabase (databaseName: string) { 203 private dropDatabase (databaseName: string) {
@@ -209,6 +205,7 @@ export class PeertubeChunkStore extends EventEmitter {
209 205
210 console.log('Deleting %s.', databaseName) 206 console.log('Deleting %s.', databaseName)
211 return dbToDelete.delete() 207 return dbToDelete.delete()
208 .catch(err => console.error('Cannot delete %s.', databaseName))
212 } 209 }
213 210
214 private nextTick (cb, err, val?) { 211 private nextTick (cb, err, val?) {