Skip to content

Commit 78fd750

Browse files
committed
Added accounting for folders when calculating status
1 parent 824bf9f commit 78fd750

File tree

2 files changed

+8
-4
lines changed

2 files changed

+8
-4
lines changed

TODO.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
# TODO
2+
3+
- Добавить команду для вывода импортированных заметок с ошибками

src/notes_importer.js

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ export async function importNotes(notesDir) {
1212
console.info(`\nLoaded already imported ${importedNoteList.length} notes`)
1313

1414
// noinspection JSValidateTypes
15-
const files = getNotesFiles(notesDir)
15+
const { files } = getNotesFiles(notesDir)
1616

1717
let fileIndex = 0
1818
for (const relFilePath of files) {
@@ -63,9 +63,10 @@ async function createParentNotes(relFilePath) {
6363
}
6464

6565
function getNotesFiles(notesDir) {
66+
const filesAndDirs = readdirSync(notesDir, { recursive: true })
6667
// noinspection JSValidateTypes
67-
return readdirSync(notesDir, { recursive: true })
68-
.filter(it => lstatSync(`${notesDir}/${it}`).isFile())
68+
const files = filesAndDirs.filter(it => lstatSync(`${notesDir}/${it}`).isFile())
69+
return { filesAndDirs, files }
6970
}
7071

7172
async function saveNoteToNotion(noteInfo) {
@@ -95,7 +96,7 @@ async function saveNoteToNotion(noteInfo) {
9596
}
9697

9798
export async function getImportNotesStatus(notesDir) {
98-
const notesCount = getNotesFiles(notesDir).length
99+
const notesCount = getNotesFiles(notesDir).filesAndDirs.length
99100
const importedNotes = await loadImportStatuses()
100101
const importedCount = importedNotes.length
101102
const importedWithErrorsCount = importedNotes.filter(it => !it.imported).length

0 commit comments

Comments
 (0)