move some bits to cache folder

This commit is contained in:
Karl0ss 2022-10-26 10:36:17 +01:00
parent e5987247fe
commit 0cc32b18c9
3 changed files with 9 additions and 9 deletions

View File

@ -7,7 +7,7 @@ const { checkDownloadHistory } = require('./checkDownloadHistory')
async function filterFeed() { async function filterFeed() {
let hevcSwitch = JSON.parse(fs.readFileSync('config.json')).OnlyHEVC let hevcSwitch = JSON.parse(fs.readFileSync('config.json')).OnlyHEVC
let myshowlist = JSON.parse(fs.readFileSync('shows.json')) let myshowlist = JSON.parse(fs.readFileSync('shows.json'))
let feed = JSON.parse(fs.readFileSync('./feedCache.json')); let feed = JSON.parse(fs.readFileSync('./cache/feedCache.json'));
let retryShowCache = [] let retryShowCache = []
let urlsToCheck = [] let urlsToCheck = []
@ -75,7 +75,7 @@ async function filterFeed() {
} }
} }
log.info('Wiping feed cache') log.info('Wiping feed cache')
fs.writeFileSync('./feedCache.json', JSON.stringify(retryShowCache)); fs.writeFileSync('./cache/feedCache.json', JSON.stringify(retryShowCache));
global.linkCheckTime = new Date(); global.linkCheckTime = new Date();
} }

View File

@ -11,15 +11,15 @@ async function feedUpdater() {
let items = []; let items = [];
if (fs.existsSync('./feedCache.json')) { if (fs.existsSync('./cache/feedCache.json')) {
items = JSON.parse(fs.readFileSync('./feedCache.json')) items = JSON.parse(fs.readFileSync('./cache/feedCache.json'))
} }
// Compare existing cache and new items and merge differences // Compare existing cache and new items and merge differences
let updatedArray = lodash.unionBy(feed.items, items, 'title'); let updatedArray = lodash.unionBy(feed.items, items, 'title');
// Save the file // Save the file
log.info(updatedArray.length + ' items in file cache') log.info(updatedArray.length + ' items in file cache')
fs.writeFileSync('./feedCache.json', JSON.stringify(updatedArray)); fs.writeFileSync('./cache/feedCache.json', JSON.stringify(updatedArray));
global.rssRefreshTime = new Date(); global.rssRefreshTime = new Date();
} }

View File

@ -2,16 +2,16 @@ const fs = require('fs')
function checkDownloadHistory(urlObj) { function checkDownloadHistory(urlObj) {
try { try {
history = JSON.parse(fs.readFileSync('./downloadHistory.json')); history = JSON.parse(fs.readFileSync('./cache/downloadHistory.json'));
} catch (error) { } catch (error) {
fs.writeFileSync('./downloadHistory.json', JSON.stringify([])); fs.writeFileSync('./cache/downloadHistory.json', JSON.stringify([]));
} }
history = JSON.parse(fs.readFileSync('./downloadHistory.json')); history = JSON.parse(fs.readFileSync('./cache/downloadHistory.json'));
if (history.includes(urlObj.fileName)) { if (history.includes(urlObj.fileName)) {
return true return true
} else { } else {
history.push(urlObj.fileName) history.push(urlObj.fileName)
fs.writeFileSync('./downloadHistory.json', JSON.stringify(history)); fs.writeFileSync('./cache/downloadHistory.json', JSON.stringify(history));
return false return false
} }
} }