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

allow notebook as hidden dir #402

Merged
merged 4 commits into from
Apr 14, 2024
Merged

allow notebook as hidden dir #402

merged 4 commits into from
Apr 14, 2024

Conversation

tjex
Copy link
Member

@tjex tjex commented Apr 7, 2024

resolves: #271

The index function of zk calls a directory walk. That walk function was set to ignore all directories and files that had a period as a prefix. This applied then to the notebook root directory itself. This also effected commands such as zk list.

This fix is an initial approach to solving that by checking if the directory begins with a prefix and the directory in question does not equal the notebook root directory.

This equality check is done by getting the notebook directory from the NotebookPath.Filename() method, and checking it against the value of filename in internal/util/paths/walk.go.

Note: It was not possible to import the core package to walk.go as it created an import cycle. This is why it is instead accessed in internal/core/note_index.go line 153 and passed to the paths.Walk() call.

On that line (153), I'm unsure whether I've used the NotebookPath struct correctly as in other areas of the code base, all fields of the struct are declared.

I have however tested this fix with success. That being a notebook with root dir .test-vault; zk indexes and lists correctly, meaning it ignores the .zk and .git directories as well as a .test-file.md note created via zk.

Please let me know if there is a better way to do this! 🙏

tjex added 3 commits April 7, 2024 09:18
- hidden directories and files should be ignored
- if the notebook root folder is hidden, this is accepted
@jurica jurica self-requested a review April 7, 2024 20:50
Copy link
Member

@jurica jurica left a comment

Choose a reason for hiding this comment

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

@tjex I have one little nitpick.
Regarding your issue with the cyclic reference: IMHO it's perfectly fine to add that new argument to Walk.

internal/core/note_index.go Outdated Show resolved Hide resolved
@tjex tjex requested a review from jurica April 7, 2024 23:21
@jurica jurica merged commit 0973f99 into zk-org:main Apr 14, 2024
3 checks passed
@tjex tjex deleted the allow-notebook-as-hidden-dir branch April 15, 2024 00:51
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.

Notebook inside a hidden directory not working
2 participants