mirror of
https://gitlab.com/MrFry/mrfrys-node-server
synced 2025-04-01 20:24:18 +02:00
Duplicate remover: removing empty directories
This commit is contained in:
parent
43b8d939c1
commit
a2bde65425
1 changed files with 23 additions and 2 deletions
|
@ -125,7 +125,7 @@ function removePossibleAnswersDuplicates(path) {
|
||||||
}
|
}
|
||||||
const dataB = utils.ReadJSON(currPath2)
|
const dataB = utils.ReadJSON(currPath2)
|
||||||
|
|
||||||
dataB.questions.forEach((q2) => {
|
dataB.questions.some((q2) => {
|
||||||
const percent = compareQuestionObj(
|
const percent = compareQuestionObj(
|
||||||
createQuestion(q1),
|
createQuestion(q1),
|
||||||
'',
|
'',
|
||||||
|
@ -136,6 +136,7 @@ function removePossibleAnswersDuplicates(path) {
|
||||||
utils.deleteFile(currPath2)
|
utils.deleteFile(currPath2)
|
||||||
count--
|
count--
|
||||||
delets++
|
delets++
|
||||||
|
return true
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
})
|
})
|
||||||
|
@ -143,7 +144,27 @@ function removePossibleAnswersDuplicates(path) {
|
||||||
|
|
||||||
printProgressBar(currIndex, count)
|
printProgressBar(currIndex, count)
|
||||||
})
|
})
|
||||||
log(`Deleted ${C('green')}${delets}${C()} files`)
|
|
||||||
|
log(`${C('green')}Deleting empty directories ...${C()}`)
|
||||||
|
const dirs = fs.readdirSync(path)
|
||||||
|
count = dirs.length
|
||||||
|
currIndex = 0
|
||||||
|
let deletedDirCount = 0
|
||||||
|
dirs.forEach((dir) => {
|
||||||
|
currIndex++
|
||||||
|
const currDirContent = fs.readdirSync(path + '/' + dir)
|
||||||
|
if (currDirContent.length === 0) {
|
||||||
|
fs.rmdirSync(path + '/' + dir)
|
||||||
|
deletedDirCount++
|
||||||
|
}
|
||||||
|
printProgressBar(currIndex, count)
|
||||||
|
})
|
||||||
|
|
||||||
|
log(
|
||||||
|
`Deleted ${C('green')}${delets}${C()} files, and ${C(
|
||||||
|
'green'
|
||||||
|
)}${deletedDirCount}${C()} directories`
|
||||||
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
function clearPossibleAnswers(path, db) {
|
function clearPossibleAnswers(path, db) {
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue