2022-06-18 13:44:16 +01:00
|
|
|
const fs = require('fs')
|
|
|
|
|
|
|
|
function checkDownloadHistory(urlObj) {
|
|
|
|
try {
|
2022-10-26 10:36:17 +01:00
|
|
|
history = JSON.parse(fs.readFileSync('./cache/downloadHistory.json'));
|
2022-06-18 13:44:16 +01:00
|
|
|
} catch (error) {
|
2022-10-26 10:36:17 +01:00
|
|
|
fs.writeFileSync('./cache/downloadHistory.json', JSON.stringify([]));
|
2022-06-18 13:44:16 +01:00
|
|
|
}
|
2022-10-26 10:36:17 +01:00
|
|
|
history = JSON.parse(fs.readFileSync('./cache/downloadHistory.json'));
|
2022-06-18 13:44:16 +01:00
|
|
|
if (history.includes(urlObj.fileName)) {
|
|
|
|
return true
|
|
|
|
} else {
|
|
|
|
history.push(urlObj.fileName)
|
2022-10-26 10:36:17 +01:00
|
|
|
fs.writeFileSync('./cache/downloadHistory.json', JSON.stringify(history));
|
2022-06-18 13:44:16 +01:00
|
|
|
return false
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
module.exports = { checkDownloadHistory }
|