Skip to content

Commit

Permalink
feat: fallback to memory store if FSA is unsupported
Browse files Browse the repository at this point in the history
  • Loading branch information
ThaUnknown committed May 30, 2023
1 parent fbc9b8f commit 93f1013
Showing 1 changed file with 3 additions and 1 deletion.
4 changes: 3 additions & 1 deletion lib/torrent.js
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,8 @@ try {

const IDLE_CALLBACK = typeof window !== 'undefined' && typeof window.requestIdleCallback === 'function' && window.requestIdleCallback

const FALLBACK_STORE = typeof navigator === 'undefined' || navigator.storage?.getDirectory ? FSChunkStore : MemoryChunkStore

export default class Torrent extends EventEmitter {
constructor (torrentId, client, opts) {
super()
Expand All @@ -80,7 +82,7 @@ export default class Torrent extends EventEmitter {
this.addUID = opts.addUID || false
this.rootDir = opts.rootDir || null
this.skipVerify = !!opts.skipVerify
this._store = opts.store || FSChunkStore
this._store = opts.store || FALLBACK_STORE
this._preloadedStore = opts.preloadedStore || null
this._storeCacheSlots = opts.storeCacheSlots !== undefined ? opts.storeCacheSlots : 20
this._destroyStoreOnDestroy = opts.destroyStoreOnDestroy || false
Expand Down

0 comments on commit 93f1013

Please sign in to comment.