mirror of
https://github.com/NoCrypt/migu.git
synced 2026-08-19 05:35:46 +00:00
fix: parsing leak
This commit is contained in:
parent
b92738f8ef
commit
f455a9cffb
2 changed files with 13 additions and 5 deletions
|
|
@ -1,6 +1,6 @@
|
|||
{
|
||||
"name": "Miru",
|
||||
"version": "3.1.18",
|
||||
"version": "3.1.19",
|
||||
"author": "ThaUnknown_ <ThaUnknown@users.noreply.github.com>",
|
||||
"description": "Stream anime torrents, real-time with no waiting for downloads.",
|
||||
"main": "src/index.js",
|
||||
|
|
|
|||
|
|
@ -104,11 +104,12 @@ class TorrentClient extends WebTorrent {
|
|||
switch (data.type) {
|
||||
case 'current': {
|
||||
this.current?.removeListener('done', this.parseSubtitles.bind(this))
|
||||
this.cancelParse()
|
||||
this.parserInstance?.destroy()
|
||||
this.parserInstance = null
|
||||
this.current = null
|
||||
this.parsed = false
|
||||
if (data) {
|
||||
if (data.data) {
|
||||
this.current = this?.get(data.data.infoHash)?.files.find(file => file.path === data.data.path)
|
||||
if (this.current?.name.endsWith('.mkv')) {
|
||||
if (this.current.done) this.parseSubtitles()
|
||||
|
|
@ -149,9 +150,9 @@ class TorrentClient extends WebTorrent {
|
|||
const finish = () => {
|
||||
console.log('Sub parsing finished')
|
||||
this.parsed = true
|
||||
this.parser?.destroy()
|
||||
this.parser = undefined
|
||||
fileStream?.destroy()
|
||||
stream?.destroy()
|
||||
stream = undefined
|
||||
}
|
||||
parser.once('tracks', tracks => {
|
||||
if (!tracks.length) finish()
|
||||
|
|
@ -159,10 +160,15 @@ class TorrentClient extends WebTorrent {
|
|||
parser.once('finish', finish)
|
||||
console.log('Sub parsing started')
|
||||
const fileStream = this.current.createReadStream()
|
||||
let stream = fileStream.pipe(parser)
|
||||
this.parser = fileStream.pipe(parser)
|
||||
}
|
||||
}
|
||||
|
||||
cancelParse () {
|
||||
this.parser?.destroy()
|
||||
this.parser = undefined
|
||||
}
|
||||
|
||||
parseFonts (file) {
|
||||
const stream = new SubtitleParser()
|
||||
this.handleSubtitleParser(stream)
|
||||
|
|
@ -205,6 +211,8 @@ class TorrentClient extends WebTorrent {
|
|||
predestroy () {
|
||||
this.destroy()
|
||||
this.server.close()
|
||||
this.parser?.destroy()
|
||||
this.parser = undefined
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Reference in a new issue