fix: process leak

This commit is contained in:
ThaUnknown 2022-12-02 01:52:14 +01:00
parent 389549d93d
commit 34de2bd295
3 changed files with 11 additions and 27 deletions

View file

@ -1,6 +1,6 @@
{
"name": "Miru",
"version": "3.3.1",
"version": "3.3.2",
"author": "ThaUnknown_ <ThaUnknown@users.noreply.github.com>",
"description": "Stream anime torrents, real-time with no waiting for downloads.",
"main": "src/index.js",

View file

@ -97,6 +97,15 @@ ipcMain.on('devtools', () => {
function createWindow () {
// Create the browser window.
webtorrentWindow = new BrowserWindow({
show: false,
webPreferences: {
nodeIntegration: true,
contextIsolation: false,
enableRemoteModule: true,
backgroundThrottling: false
}
})
mainWindow = new BrowserWindow({
width: 1600,
height: 900,
@ -111,15 +120,6 @@ function createWindow () {
icon: path.join(__dirname, '/renderer/public/logo.ico'),
show: false
})
webtorrentWindow = new BrowserWindow({
show: false,
webPreferences: {
nodeIntegration: true,
contextIsolation: false,
enableRemoteModule: true,
backgroundThrottling: false
}
})
mainWindow.setMenuBarVisibility(false)
protocol.registerHttpProtocol('miru', (req, cb) => {
@ -141,8 +141,6 @@ function createWindow () {
callback(headers)
})
// This block of code is intended for development purpose only.
// Delete this entire block of code when you are ready to package the application.
if (process.env.NODE_ENV !== 'development ') {
// Load production build
webtorrentWindow.loadFile(path.join(__dirname, '/renderer/dist/webtorrent.html'))
@ -162,6 +160,7 @@ function createWindow () {
// in an array if your app supports multi windows, this is the time
// when you should delete the corresponding element.
mainWindow = null
app.quit()
})
let crashcount = 0
@ -196,13 +195,6 @@ function createWindow () {
// Some APIs can only be used after this event occurs.
app.on('ready', createWindow)
// Quit when all windows are closed.
app.on('window-all-closed', () => {
// On macOS it is common for applications and their menu bar
// to stay active until the user quits explicitly with Cmd + Q
if (process.platform !== 'darwin') app.quit()
})
app.on('activate', () => {
// On macOS it's common to re-create a window in the app when the
// dock icon is clicked and there are no other windows open.

View file

@ -147,14 +147,6 @@ async function resolveTitle (name) {
function getParseObjTitle (obj) {
let title = obj.anime_title
const match = title.match(/ S(\d{1,2})E(\d{1,2})v\d/)
if (match) {
obj.episode_number = match[2]
obj.anime_season = match[1]
obj.anime_title = title.replace(/ S(\d{1,2})E(\d{1,2})v\d/, '')
title = obj.anime_title
}
if (obj.anime_year) title += ` ${obj.anime_year}`
if (obj.anime_season > 1) title += ' S' + obj.anime_season
return title