diff --git a/applications/tempfiles/index.js b/applications/tempfiles/index.js index a6716ea..31e43fa 100644 --- a/applications/tempfiles/index.js +++ b/applications/tempfiles/index.js @@ -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 () {