diff options
Diffstat (limited to 'client/src/assets/player/webtorrent/peertube-chunk-store.ts')
-rw-r--r-- | client/src/assets/player/webtorrent/peertube-chunk-store.ts | 8 |
1 files changed, 5 insertions, 3 deletions
diff --git a/client/src/assets/player/webtorrent/peertube-chunk-store.ts b/client/src/assets/player/webtorrent/peertube-chunk-store.ts index 66762bef8..93ca8e1d8 100644 --- a/client/src/assets/player/webtorrent/peertube-chunk-store.ts +++ b/client/src/assets/player/webtorrent/peertube-chunk-store.ts | |||
@@ -36,7 +36,7 @@ export class PeertubeChunkStore extends EventEmitter { | |||
36 | 36 | ||
37 | chunkLength: number | 37 | chunkLength: number |
38 | 38 | ||
39 | private pendingPut: { id: number, buf: Buffer, cb: Function }[] = [] | 39 | private pendingPut: { id: number, buf: Buffer, cb: (err?: Error) => void }[] = [] |
40 | // If the store is full | 40 | // If the store is full |
41 | private memoryChunks: { [ id: number ]: Buffer | true } = {} | 41 | private memoryChunks: { [ id: number ]: Buffer | true } = {} |
42 | private databaseName: string | 42 | private databaseName: string |
@@ -54,7 +54,7 @@ export class PeertubeChunkStore extends EventEmitter { | |||
54 | this.databaseName = 'webtorrent-chunks-' | 54 | this.databaseName = 'webtorrent-chunks-' |
55 | 55 | ||
56 | if (!opts) opts = {} | 56 | if (!opts) opts = {} |
57 | if (opts.torrent && opts.torrent.infoHash) this.databaseName += opts.torrent.infoHash | 57 | if (opts.torrent?.infoHash) this.databaseName += opts.torrent.infoHash |
58 | else this.databaseName += '-default' | 58 | else this.databaseName += '-default' |
59 | 59 | ||
60 | this.setMaxListeners(100) | 60 | this.setMaxListeners(100) |
@@ -106,7 +106,9 @@ export class PeertubeChunkStore extends EventEmitter { | |||
106 | } catch (err) { | 106 | } catch (err) { |
107 | console.log('Cannot bulk insert chunks. Store them in memory.', { err }) | 107 | console.log('Cannot bulk insert chunks. Store them in memory.', { err }) |
108 | 108 | ||
109 | processing.forEach(p => this.memoryChunks[ p.id ] = p.buf) | 109 | processing.forEach(p => { |
110 | this.memoryChunks[p.id] = p.buf | ||
111 | }) | ||
110 | } finally { | 112 | } finally { |
111 | processing.forEach(p => p.cb()) | 113 | processing.forEach(p => p.cb()) |
112 | } | 114 | } |