mirror of
https://codeberg.org/tacerus/teddit.git
synced 2024-11-22 06:49:26 +01:00
make the getUsage() function a bit more reliable, and fine-tune the amount of files to delete from static/
This commit is contained in:
parent
e0b5cc6e40
commit
b76c72ef6c
@ -16,7 +16,15 @@ module.exports.removeCacheFiles = function() {
|
|||||||
return new Promise((resolve, reject) => {
|
return new Promise((resolve, reject) => {
|
||||||
let size = spawn('du', ['-sBM', './static/'])
|
let size = spawn('du', ['-sBM', './static/'])
|
||||||
size.stdout.on('data', function (data) {
|
size.stdout.on('data', function (data) {
|
||||||
usage = parseInt(data)
|
data = data.toString()
|
||||||
|
let lines = data.split('\n')
|
||||||
|
if(lines) {
|
||||||
|
for(let i = lines.length; i >= 0; i--) {
|
||||||
|
if(lines[i] && lines[i].includes('./static/')) {
|
||||||
|
usage = parseInt(lines[i])
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
resolve(usage)
|
resolve(usage)
|
||||||
})
|
})
|
||||||
})
|
})
|
||||||
@ -28,10 +36,10 @@ module.exports.removeCacheFiles = function() {
|
|||||||
if(usage > limit) {
|
if(usage > limit) {
|
||||||
const { exec } = require('child_process')
|
const { exec } = require('child_process')
|
||||||
exec(`cd ${pics} && ls -1btr -Iflairs -Iicons -Ithumbs -I.gitignore | head -50 | xargs rm -f --`)
|
exec(`cd ${pics} && ls -1btr -Iflairs -Iicons -Ithumbs -I.gitignore | head -50 | xargs rm -f --`)
|
||||||
exec(`cd ${flairs} && ls -1btr -I.gitignore | head -50 | xargs rm -f --`)
|
exec(`cd ${flairs} && ls -1btr -I.gitignore | head -6 | xargs rm -f --`)
|
||||||
exec(`cd ${icons} && ls -1btr -I.gitignore | head -50 | xargs rm -f --`)
|
exec(`cd ${icons} && ls -1btr -I.gitignore | head -6 | xargs rm -f --`)
|
||||||
exec(`cd ${thumbs} && ls -1btr -I.gitignore | head -50 | xargs rm -f --`)
|
exec(`cd ${thumbs} && ls -1btr -I.gitignore | head -80 | xargs rm -f --`)
|
||||||
exec(`cd ${vids} && ls -1btr -I.gitignore | head -30 | xargs rm -f --`)
|
exec(`cd ${vids} && ls -1btr -I.gitignore | head -2 | xargs rm -f --`)
|
||||||
}
|
}
|
||||||
resolve(1)
|
resolve(1)
|
||||||
})
|
})
|
||||||
|
Loading…
Reference in New Issue
Block a user