Catch indexdb database destroy
authorChocobozzz <me@florianbigard.com>
Tue, 15 May 2018 14:52:19 +0000 (16:52 +0200)
committerChocobozzz <me@florianbigard.com>
Wed, 16 May 2018 07:42:55 +0000 (09:42 +0200)
client/src/assets/player/peertube-chunk-store.ts

index 005e98a81203b36ea3113013fed54762c02600d0..84fbaf1460c16723746ef5ae0aef9a7a783838a7 100644 (file)
@@ -183,25 +183,21 @@ export class PeertubeChunkStore extends EventEmitter {
 
   private checkExpiration () {
     this.expirationDB.transaction('rw', this.expirationDB.databases, async () => {
-      try {
-        // Update our database expiration since we are alive
-        await this.expirationDB.databases.put({
-          name: this.databaseName,
-          expiration: new Date().getTime() + PeertubeChunkStore.CLEANER_EXPIRATION_MS
-        })
+      // Update our database expiration since we are alive
+      await this.expirationDB.databases.put({
+        name: this.databaseName,
+        expiration: new Date().getTime() + PeertubeChunkStore.CLEANER_EXPIRATION_MS
+      })
 
-        const now = new Date().getTime()
-        const databasesToDeleteInfo = await this.expirationDB.databases.where('expiration').below(now).toArray()
+      const now = new Date().getTime()
+      const databasesToDeleteInfo = await this.expirationDB.databases.where('expiration').below(now).toArray()
 
-        for (const databaseToDeleteInfo of databasesToDeleteInfo) {
-          await this.dropDatabase(databaseToDeleteInfo.name)
+      for (const databaseToDeleteInfo of databasesToDeleteInfo) {
+        await this.dropDatabase(databaseToDeleteInfo.name)
 
-          await this.expirationDB.databases.where({ name: databaseToDeleteInfo.name }).delete()
-        }
-      } catch (err) {
-        console.error('Cannot check expiration.', err)
+        await this.expirationDB.databases.where({ name: databaseToDeleteInfo.name }).delete()
       }
-    })
+    }).catch(err => console.error('Cannot check expiration.', err))
   }
 
   private dropDatabase (databaseName: string) {
@@ -209,6 +205,7 @@ export class PeertubeChunkStore extends EventEmitter {
 
     console.log('Deleting %s.', databaseName)
     return dbToDelete.delete()
+      .catch(err => console.error('Cannot delete %s.', databaseName))
   }
 
   private nextTick (cb, err, val?) {