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

[Bug] zk cannot query links of files in subdirectories #170

Closed
B4rc1 opened this issue Feb 21, 2022 · 10 comments · Fixed by #193
Closed

[Bug] zk cannot query links of files in subdirectories #170

B4rc1 opened this issue Feb 21, 2022 · 10 comments · Fixed by #193
Labels
bug Something isn't working

Comments

@B4rc1
Copy link

B4rc1 commented Feb 21, 2022

$ zk init
$ zk new --title one
$ zk new --title two
$ mkdir my_dir
$ zk new --title three my_dir

After this you end up with a folder looking something like this:

❯ tree
 .
├──  my_dir
│  └──  5r1k.md
├──  1zyl.md
└──  koxo.md

Now insert links to file on in file two and three.

You should end up with:

❯ zk list
one 1zyl.md (3 minutes ago)


three my_dir/5r1k.md (3 minutes ago)

  ‣ [[1zyl]]

two koxo.md (3 minutes ago)

  ‣ [[1zyl]]


Found 3 notes

as you can see two and three link to one. When asking zk which file links to one:

❯ zk list --link-to 1zyl.md
two koxo.md (5 minutes ago)

  ‣ [[1zyl]]


Found 1 note

When asking which file three links:

❯ zk list --linked-by "my_dir/5r1k.md"

Found 0 note

System Information
zk version: 0.9.0

❯ zk --version
zk dev
@mickael-menu
Copy link
Member

Thank you for the detailed bug report, I can reproduce it.

@mickael-menu mickael-menu added the bug Something isn't working label Feb 23, 2022
@j-hui
Copy link

j-hui commented Mar 7, 2022

Probably related: zk also doesn't seem to count links from subdirectories when figuring out which notes are orphans.

$ zk init --no-input
$ zk new --title one # xu2y.md
$ mkdir my_dir && zk new --title two my_dir # he0x.md

Say I link these notes to each other:

$ zk list
one xu2y.md (3 minutes ago)

  ‣ [[my_dir/he0x]]

two my_dir/he0x.md (3 minutes ago)

  ‣ [[xu2y]]


Found 2 notes

Because these are linked circularly, neither should be considered an orphan. However:

$ zk list --orphan
one xu2y.md (4 minutes ago)

  ‣ [[my_dir/he0x]]


Found 1 note

one is still considered an orphan despite the link from two.

I post here because this seems like a different expression of the same issue, but I'm happy to open a new issue if that makes things easier to track.

@mickael-menu
Copy link
Member

@j-hui It's fine here, I'll check if the issues are related after fixing the first one.

@waynezhang
Copy link

Coming from Logseq. I'm keeping journals in journals directory and other things in pages directory. But they can not refer to each others.

@dj8yfo
Copy link

dj8yfo commented Apr 7, 2022

Bump. Seeing this too.

@mickael-menu
Copy link
Member

It should be fixed in main now, could someone confirm?

@j-hui Yes it was indeed the same issue.

@B4rc1
Copy link
Author

B4rc1 commented Apr 24, 2022

still present for me on commit 7622d9e:

❯ ./zk list technical-tests/linking2.md
linking2 technical-tests/linking2.md (3 months ago)

  ‣ [[references/lua]]


Found 1 note
❯ ./zk list --linked-by technical-tests/linking2.md

Found 0 note
❯ ./zk list --link-to references/lua.md

Found 0 note

@mickael-menu
Copy link
Member

@B4rc1 Your example works for me, make sure you are really using the latest version (check zk --version maybe).

Also forcing to reindex your notebook might help: zk index --force.

@B4rc1
Copy link
Author

B4rc1 commented Apr 24, 2022

reindexing (zk index --force) fixed it. There should be a disclaimer somewhere to reindex your notebook on updates (or do that automatically)

@mickael-menu
Copy link
Member

Yeah I think I'll add a reindexing step for the next release. Thanks for confirming the fix.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

Successfully merging a pull request may close this issue.

5 participants