Skip to content

Commit

Permalink
fix: clear download timeout when close the window
Browse files Browse the repository at this point in the history
  • Loading branch information
chenfan0 committed Aug 23, 2024
1 parent 9023a5b commit 15761c2
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 21 deletions.
37 changes: 17 additions & 20 deletions src/main/ffmpeg/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -48,22 +48,26 @@ export const downloadDepProgressInfo: IDownloadDepProgressInfo = {
showRetry: false
}

const setFfmpegAndFfprobePath = (dirname: string) => {
const ffmpegPath = isMac
? path.resolve(dirname, 'ffmpeg-mac/ffmpeg')
: path.resolve(dirname, 'ffmpeg-win/ffmpeg.exe')
const ffprobePath = isMac
? path.resolve(dirname, 'ffmpeg-mac/ffprobe')
: path.resolve(dirname, 'ffmpeg-win/ffprobe.exe')
ffmpeg.setFfmpegPath(ffmpegPath)
ffmpeg.setFfprobePath(ffprobePath)
ffmpeg.ffmpegPath = ffmpegPath
ffmpeg.ffprobePath = ffprobePath
}

export async function makeSureDependenciesExist(
dirname: string,
isFfmpegExist: boolean,
isFFprobeExist: boolean
) {
if (isFfmpegExist && isFFprobeExist) {
const ffmpegPath = isMac
? path.resolve(dirname, 'ffmpeg-mac/ffmpeg')
: path.resolve(dirname, 'ffmpeg-win/ffmpeg.exe')
const ffprobePath = isMac
? path.resolve(dirname, 'ffmpeg-mac/ffprobe')
: path.resolve(dirname, 'ffmpeg-win/ffprobe.exe')
ffmpeg.setFfmpegPath(ffmpegPath)
ffmpeg.setFfprobePath(ffprobePath)
ffmpeg.ffmpegPath = ffmpegPath
ffmpeg.ffprobePath = ffprobePath
setFfmpegAndFfprobePath(dirname)
return true
}

Expand All @@ -90,16 +94,9 @@ export async function makeSureDependenciesExist(
.then(() => {
downloadDepProgressInfo.downloading = false
downloadDepProgressInfo.progress = 0
const ffmpegPath = isMac
? path.resolve(dirname, 'ffmpeg-mac/ffmpeg')
: path.resolve(dirname, 'ffmpeg-win/ffmpeg.exe')
const ffprobePath = isMac
? path.resolve(dirname, 'ffmpeg-mac/ffprobe')
: path.resolve(dirname, 'ffmpeg-win/ffprobe.exe')
ffmpeg.setFfmpegPath(ffmpegPath)
ffmpeg.setFfprobePath(ffprobePath)
ffmpeg.ffmpegPath = ffmpegPath
ffmpeg.ffprobePath = ffprobePath

setFfmpegAndFfprobePath(dirname)

_resolve(true)
})
.catch(() => {
Expand Down
2 changes: 1 addition & 1 deletion src/main/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -289,7 +289,7 @@ app.whenReady().then(async () => {
killRecordStreamFfmpegProcess(key)
})
clearTimerWhenAllFfmpegProcessEnd()

stopDownloadDepTimerWhenAllDownloadDepEnd()
win?.destroy()
})

Expand Down

0 comments on commit 15761c2

Please sign in to comment.