mirror of
https://github.com/Tzahi12345/YoutubeDL-Material.git
synced 2026-04-17 16:21:27 +03:00
Added debug statements
This commit is contained in:
@@ -137,10 +137,11 @@ async function startServer() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// getLatestVersion();
|
// getLatestVersion();
|
||||||
// updateServer();
|
updateServer();
|
||||||
}
|
}
|
||||||
|
|
||||||
async function restartServer() {
|
async function restartServer() {
|
||||||
|
console.log('Restarting server...');
|
||||||
const restartProcess = () => {
|
const restartProcess = () => {
|
||||||
spawn(process.argv[1], process.argv.slice(2), {
|
spawn(process.argv[1], process.argv.slice(2), {
|
||||||
detached: true,
|
detached: true,
|
||||||
@@ -166,12 +167,15 @@ async function updateServer() {
|
|||||||
|
|
||||||
// grab new package.json and public folder
|
// grab new package.json and public folder
|
||||||
await downloadUpdateFiles();
|
await downloadUpdateFiles();
|
||||||
|
|
||||||
|
restartServer();
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
async function downloadUpdateFiles() {
|
async function downloadUpdateFiles() {
|
||||||
let tag = await getLatestVersion();
|
let tag = await getLatestVersion();
|
||||||
return new Promise(async resolve => {
|
return new Promise(async resolve => {
|
||||||
|
console.log('Downloading new files...')
|
||||||
var options = {
|
var options = {
|
||||||
owner: 'tzahi12345',
|
owner: 'tzahi12345',
|
||||||
repo: 'YoutubeDL-Material',
|
repo: 'YoutubeDL-Material',
|
||||||
@@ -185,6 +189,8 @@ async function downloadUpdateFiles() {
|
|||||||
fs.removeSync(path.join(__dirname, 'public'));
|
fs.removeSync(path.join(__dirname, 'public'));
|
||||||
fs.mkdirSync(path.join(__dirname, 'public'));
|
fs.mkdirSync(path.join(__dirname, 'public'));
|
||||||
|
|
||||||
|
console.log(`Installing update ${tag}...`)
|
||||||
|
|
||||||
// downloads new package.json and adds new public dir files from the downloaded zip
|
// 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())
|
fs.createReadStream(path.join(__dirname, 'youtubedl-material-latest-release.zip')).pipe(unzipper.Parse())
|
||||||
.on('entry', function (entry) {
|
.on('entry', function (entry) {
|
||||||
@@ -206,6 +212,9 @@ async function downloadUpdateFiles() {
|
|||||||
} else {
|
} else {
|
||||||
entry.autodrain();
|
entry.autodrain();
|
||||||
}
|
}
|
||||||
|
})
|
||||||
|
.on('close', function () {
|
||||||
|
resolve(true);
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user