Duplicate remover: updating savedQuestions.json

This commit is contained in:
mrfry 2021-03-29 20:06:22 +02:00
parent a2bde65425
commit 18b832ca59

View file

@ -160,6 +160,15 @@ function removePossibleAnswersDuplicates(path) {
printProgressBar(currIndex, count) printProgressBar(currIndex, count)
}) })
log(`${C('green')}Updating savedQuestions.json ...${C()}`)
count = dirs.length
currIndex = 0
dirs.forEach((dir) => {
currIndex++
updateSavedQuestionsFile(path + '/' + dir)
printProgressBar(currIndex, count)
})
log( log(
`Deleted ${C('green')}${delets}${C()} files, and ${C( `Deleted ${C('green')}${delets}${C()} files, and ${C(
'green' 'green'
@ -199,6 +208,19 @@ function clearPossibleAnswers(path, db) {
log(`Deleted ${C('green')}${delets}${C()} files`) log(`Deleted ${C('green')}${delets}${C()} files`)
} }
function updateSavedQuestionsFile(path) {
const filePath = path + '/' + 'savedQuestions.json'
if (!utils.FileExists(filePath)) {
log(`${filePath} does not exists!`)
return
}
const savedQuestions = utils.ReadJSON(filePath)
return savedQuestions.filter((sq) => {
return utils.FileExists(path + '/' + sq.fname)
})
}
// --------------------------------------------------------------------------------- // ---------------------------------------------------------------------------------
// difference // difference
// --------------------------------------------------------------------------------- // ---------------------------------------------------------------------------------