improvement: add ffmpeg check and copy it again if the file is missing (#153)

This commit is contained in:
Jelle Glebbeek
2021-08-28 02:21:15 +02:00
parent c50dd1a067
commit 3afb5f1062

View File

@@ -48,6 +48,7 @@ class Filepaths {
this.settings = path.join(this.persistentPath, "userSettings");
this.taskList = path.join(this.persistentPath, "taskList");
this.ytdlVersion = path.join(this.persistentPath, "ytdlVersion");
this.checkFfmpeg();
break;
case "darwin":
this.packedPrefix = this.appPath;
@@ -71,6 +72,7 @@ class Filepaths {
this.settings = this.app.isPackaged ? path.join(this.persistentPath, "userSettings") : "userSettings";
this.taskList = this.app.isPackaged ? path.join(this.persistentPath, "taskList") : "taskList";
this.ytdlVersion = this.app.isPackaged ? path.join(this.persistentPath, "ytdlVersion") :"binaries/ytdlVersion";
this.checkFfmpeg();
this.setPermissions()
break;
}
@@ -102,6 +104,17 @@ class Filepaths {
else return process.platform;
}
checkFfmpeg() {
try {
fs.promises.access(this.ffmpeg, fs.constants.F_OK).catch(() => {
const from = path.join(this.unpackedPrefix, "binaries");
fs.copyFileSync(path.join(from, path.basename(this.ffmpeg)), this.ffmpeg);
})
} catch (e) {
console.error(e);
}
}
setPermissions() {
fs.chmod(this.ytdl, 0o755, (err) => {
if(err) console.error(err);