mirror of
https://github.com/karl0ss/JDRssDownloader.git
synced 2025-04-27 20:03:40 +01:00
19 lines
600 B
JavaScript
19 lines
600 B
JavaScript
const fs = require('fs')
|
|
|
|
function checkDownloadHistory(urlObj) {
|
|
try {
|
|
history = JSON.parse(fs.readFileSync('./downloadHistory.json'));
|
|
} catch (error) {
|
|
fs.writeFileSync('./downloadHistory.json', JSON.stringify([]));
|
|
}
|
|
history = JSON.parse(fs.readFileSync('./downloadHistory.json'));
|
|
if (history.includes(urlObj.fileName)) {
|
|
return true
|
|
} else {
|
|
history.push(urlObj.fileName)
|
|
fs.writeFileSync('./downloadHistory.json', JSON.stringify(history));
|
|
return false
|
|
}
|
|
}
|
|
|
|
module.exports = { checkDownloadHistory } |