diff --git a/backend/app.js b/backend/app.js index 607e97c..5038dcc 100644 --- a/backend/app.js +++ b/backend/app.js @@ -185,6 +185,9 @@ async function downloadUpdateFiles() { fs.removeSync(path.join(__dirname, 'public')); fs.mkdirSync(path.join(__dirname, 'public')); + let replace_ignore_list = ['youtubedl-material/appdata/default.json', + 'youtubedl-material/appdata/db.json'] + // downloads new package.json and adds new public dir files from the downloaded zip fs.createReadStream(path.join(__dirname, 'youtubedl-material-latest-release.zip')).pipe(unzipper.Parse()) .on('entry', function (entry) { @@ -200,7 +203,7 @@ async function downloadUpdateFiles() { } else { entry.autodrain(); } - } else if (fileName === 'youtubedl-material/package.json') { + } else if (!replace_ignore_list.includes(fileName)) { // get package.json entry.pipe(fs.createWriteStream(path.join(__dirname, 'package.json'))); } else { @@ -821,7 +824,7 @@ async function autoUpdateYoutubeDL() { let current_app_details_path = 'node_modules/youtube-dl/bin/details'; let current_app_details_exists = fs.existsSync(current_app_details_path); if (!current_app_details_exists) { - console.log(`Failed to get youtube-dl binary details at location: ${current_app_details_path}. Cancelling update check.`); + console.log(`ERROR: Failed to get youtube-dl binary details at location '${current_app_details_path}'. Cancelling update check.`); resolve(false); return; } @@ -829,9 +832,17 @@ async function autoUpdateYoutubeDL() { let current_version = current_app_details['version']; let stored_binary_path = current_app_details['path']; if (!stored_binary_path || typeof stored_binary_path !== 'string') { - console.log(`Failed to get youtube-dl binary path at location: ${current_app_details_path}. Cancelling update check.`); - resolve(false); - return; + // console.log(`INFO: Failed to get youtube-dl binary path at location: ${current_app_details_path}, attempting to guess actual path...`); + const guessed_base_path = 'node_modules/youtube-dl/bin/'; + const guessed_file_path = guessed_base_path + 'youtube-dl' + (process.platform === 'win32' ? '.exe' : ''); + if (fs.existsSync(guessed_file_path)) { + stored_binary_path = guessed_file_path; + // console.log('INFO: Guess successful! Update process continuing...') + } else { + console.log(`ERROR: Guess '${guessed_file_path}' is not correct. Cancelling update check. Verify that your youtube-dl binaries exist by running npm install.`); + resolve(false); + return; + } } // got version, now let's check the latest version from the youtube-dl API