diff options
Diffstat (limited to 'client/src')
-rw-r--r-- | client/src/assets/player/peertube-chunk-store.ts | 27 |
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?) { |