fix: capacitor torrent path

This commit is contained in:
ThaUnknown 2024-03-29 23:18:52 +01:00
parent 6e426630f4
commit db08cff1a1
4 changed files with 9 additions and 8 deletions

View file

@ -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",

View file

@ -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)

View file

@ -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) {

View file

@ -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,
@ -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])