shortened urls cleanup

This commit is contained in:
Evert Prants 2020-01-06 23:10:21 +02:00
parent 83289e13d9
commit ef48da6478
Signed by: evert
GPG Key ID: 1688DA83D222D0B5

View File

@ -52,7 +52,16 @@ async function clearDatabase (config, dbPromise) {
}
}
console.log('Database was cleared of %d files and %d IPFS hashes.', files.length, hashes.length)
// Shortened URLs
let shorts = await db.all('SELECT hash FROM Short WHERE timeat < ?', new Date() - (config.expiry * 1000))
if (shorts.length > 0) {
for (let i in shorts) {
await db.run('DELETE FROM Short WHERE hash = ?', shorts[i].hash)
}
}
console.log('Database was cleared of %d files, %d IPFS hashes and %d shortened URLs.',
files.length, hashes.length, shorts.length)
}
async function init () {