Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Handle empty note subdirectories better #32

Merged
merged 1 commit into from
Jan 7, 2023

Conversation

EddieAbbondanzio
Copy link
Owner

Directories that match the note id regex will now have their contents checked to see if metadata / markdown files exist before attempting to load them.

The app was previously attempting to load empty directories if the directory name matched and it'd crash the app due to expected files not being found.

Comment on lines +362 to +376
const metadataPath = p.join(
noteDirectoryPath,
entry.name,
METADATA_FILE_NAME,
);
const markdownPath = p.join(
noteDirectoryPath,
entry.name,
MARKDOWN_FILE_NAME,
);

// Attachment directory doesn't need to be checked because it'll be re-created
// the first time the user attempts to add an attachment.

return fs.existsSync(metadataPath) && fs.existsSync(markdownPath);
Copy link
Owner Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Doesn't need to be in this PR, but we should add some logging here so we can make it easy to tell why a file wasn't loaded, or if there are folders that don't belong in the note directory.

@EddieAbbondanzio EddieAbbondanzio merged commit 98b8477 into master Jan 7, 2023
@EddieAbbondanzio EddieAbbondanzio deleted the handle-empty-note-subdirs-better branch January 7, 2023 00:48
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant