Skip to content

Commit

Permalink
fixed some permission bugs that prevented ffmpeg and yt-dlp updates
Browse files Browse the repository at this point in the history
  • Loading branch information
Davis-Software committed Sep 10, 2023
1 parent dc42953 commit 354d4f8
Show file tree
Hide file tree
Showing 2 changed files with 36 additions and 6 deletions.
40 changes: 35 additions & 5 deletions back/dependency-installer.js
Original file line number Diff line number Diff line change
Expand Up @@ -27,17 +27,43 @@ class Dependency{
}
}
makeExecutable(filepath, callback){
fs.chmod(filepath, "0500", callback)
fs.chmod(filepath, fs.constants.S_IRUSR | fs.constants.S_IWUSR | fs.constants.S_IXUSR, callback)
}
setConfigVal(key, val){
let conf = this.config
conf[key] = val
fs.writeFileSync(this.configFile, JSON.stringify(conf))
}
get config(){
return JSON.parse(fs.readFileSync(this.configFile, {
encoding: "utf-8"
}))
}
setConfigVal(key, val){
let conf = this.config
conf[key] = val
fs.writeFileSync(this.configFile, JSON.stringify(conf))
get canAccess(){
try {
fs.accessSync(this.executor, fs.constants.X_OK | fs.constants.R_OK | fs.constants.W_OK)
return true
}catch (e){
console.error("Dependency Error: " + e.message)
return false
}
}

/**
* Implementation required
* @param download
* @returns {Promise<boolean>}
*/
checkForUpdate(download){
throw new Error("Not Implemented")
}

/**
* Implementation required
* @returns {string}
*/
get executor(){
throw new Error("Not Implemented")
}
}

Expand All @@ -58,6 +84,8 @@ class YoutubeDlDependency extends Dependency{
})
}
checkForUpdate(download){
if(!this.canAccess) fs.rmSync(this.executor)

return new Promise(resolve => {
let curr_tag = fs.existsSync(this.executor) ? this.config.tag : null
this._getLatestTag(tag => {
Expand Down Expand Up @@ -118,6 +146,8 @@ class Ffmpeg extends Dependency{
})
}
checkForUpdate(download){
if(!this.canAccess) fs.rmSync(this.executor)

const unzipWin = (downloadLoc, outLoc, callback) => {
let zip = new StreamZip({
file: downloadLoc,
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
"url": "https://github.com/Davis-Software/YTDownloader"
},
"name": "swc_ytdownloader",
"version": "0.1.20",
"version": "0.1.21",
"description": "Download and convert Videos from YouTube",
"repository": "https://github.com/Davis-Software/YTDownloader",
"license": "MIT",
Expand Down

0 comments on commit 354d4f8

Please sign in to comment.