Skip to content

Commit

Permalink
fix: capacitor torrent path
Browse files Browse the repository at this point in the history
  • Loading branch information
ThaUnknown committed Mar 29, 2024
1 parent 6e42663 commit db08cff
Show file tree
Hide file tree
Showing 4 changed files with 9 additions and 8 deletions.
2 changes: 1 addition & 1 deletion capacitor/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "capacitor",
"version": "1.0.9",
"version": "1.0.12",
"private": true,
"scripts": {
"build:native": "cd public/nodejs/ && npm install && docker build -t android-build:latest . && docker run -v ${PWD}:/app/ -it android-build:latest /bin/bash /app/setup-deps.sh",
Expand Down
6 changes: 3 additions & 3 deletions capacitor/src/main.js
Original file line number Diff line number Diff line change
Expand Up @@ -26,9 +26,9 @@ channel.on('port-init', data => {
}

channel.on('ipc', a => port.onmessage(a))
channel.emit('port', ({
channel.emit('port', {
ports: [port]
}))
})
})

globalThis.client = new TorrentClient(channel, storageQuota, 'node', { torrentPath: env.TMPDIR })
globalThis.client = new TorrentClient(channel, storageQuota, 'node', env.TMPDIR)
4 changes: 2 additions & 2 deletions common/modules/torrent.js
Original file line number Diff line number Diff line change
Expand Up @@ -57,12 +57,12 @@ client.on('files', ({ detail }) => {

client.on('error', ({ detail }) => {
console.error(detail)
toast.error('Torrent Error', { description: detail.message || detail })
toast.error('Torrent Error', { description: '' + (detail.message || detail) })
})

client.on('warn', ({ detail }) => {
console.error(detail)
toast.warning('Torrent Warning', { description: detail.message || detail })
toast.warning('Torrent Warning', { description: '' + (detail.message || detail) })
})

export async function add (torrentID, hide) {
Expand Down
5 changes: 3 additions & 2 deletions common/modules/webtorrent.js
Original file line number Diff line number Diff line change
Expand Up @@ -39,8 +39,8 @@ export default class TorrentClient extends WebTorrent {
playerProcess = null
torrentPath = ''

constructor (ipc, storageQuota, serverMode, settingOverrides = {}, controller) {
const settings = { ...defaults, ...storedSettings, ...settingOverrides }
constructor (ipc, storageQuota, serverMode, torrentPath, controller) {
const settings = { ...defaults, ...storedSettings }
super({
dht: !settings.torrentDHT,
maxConns: settings.maxConns,
Expand All @@ -49,6 +49,7 @@ export default class TorrentClient extends WebTorrent {
torrentPort: settings.torrentPort || 0,
dhtPort: settings.dhtPort || 0
})
this.torrentPath = torrentPath
this._ready = new Promise(resolve => {
ipc.on('port', ({ ports }) => {
this.message = ports[0].postMessage.bind(ports[0])
Expand Down

0 comments on commit db08cff

Please sign in to comment.