A clean and minimal youtube frontend, without all the ads and whistles
JavaScript
fix: reclaim disk space
Christian Feiacaf6f9e68d0
diff --git a/lib/server.js b/lib/server.jsindex f9100a2..091f074 100644--- a/lib/server.js+++ b/lib/server.js@@ -345,8 +345,8 @@ function diskUsageHandler(req, res, repo) {const diskSpaceUsed = videos.filter(filterFn).reduce((total, video) => {try {- const files = fs.globSync(`./data/videos/${video.id}*`)- return total + files.reduce((acc, file) => acc + fs.statSync(file).size / Math.pow(10, 9), 0)+ const filenames = fs.readdirSync('./data/videos').filter(f => f.startsWith(video.id))+ return total + filenames.reduce((acc, filename) => acc + fs.statSync(`./data/videos/${filename}`).size / Math.pow(10, 9), 0)} catch (err) {console.error(err)return total@@ -359,17 +359,17 @@ function diskUsageHandler(req, res, repo) {async function reclaimDiskSpaceHandler(req, res, repo) {const body = await getBody(req)const {onlyIgnored} = JSON.parse(body)- const videos = repo.getVideos()+ const videos = repo.getAllVideos()- const filterFn = onlyIgnored- ? video => video.downloaded && video.ignored- : video => video.downloaded+ const filterFn = onlyIgnored ? video => video.downloaded && video.ignored : video => video.downloadedvideos.filter(filterFn).forEach((video) => {try {- const files = fs.globSync(`./data/videos/${video.id}*`)- files.forEach(file => fs.unlinkSync(file))+ const filenames = fs.readdirSync('./data/videos').filter(f => f.startsWith(video.id))+ filenames.forEach(filename => {+ fs.unlinkSync(`./data/videos/${filename}`)+ })repo.updateVideo(video.id, {downloaded: false})} catch (err) {console.error(err.message)