obsidian-dataview
obsidian-dataview copied to clipboard
Links to renamed/moved files don't update until file contents are edited
What happened?
If a file is renamed or moved, any links to that file in a Dataview query will continue to point to the file's old path. If the link is followed, a new empty file with the same path will be created. The link is only updated when the content of the linked file is edited.
My expectation would be that the links in the Dataview query would be updated automatically to reflect changes to paths/filenames.
DQL
TASK
WHERE due = date(today)
GROUP BY project
JS
No response
Dataview Version
0.4.22
Obsidian Version
0.13.19
OS
Windows
Thanks for the report! We do update links to files that are renamed, it looks like though we've missed it for tasks or there's some bug somewhere in there. We'll take a look.
@M-bot Here's a case to reproduce it:
View.md
// Type your search tags in the "search" array. Order doesn't matter.
let search = ['#context/online', '#prio/high'];
// Which folder to search in.
let folder = 'Tasks/Projects';
// ---
// Search algorithm.
let search_re = search.map(s => new RegExp('^' + s.replace(/[\\^$*+?.()|[\]{}]/g, '\\$&') + '(?:\\/|$)'));
let next_tasks = [];
dv.pages('"' + folder + '" and ' + search.join(' and ')).forEach(p => {
// Process all tasks in the current file to check if they match.
let seen_sections = new Set();
p.file.tasks.forEach(t => {
// Only process the first incomplete task of each section.
if (seen_sections.has(t.section.subpath) || t.completed) return;
seen_sections.add(t.section.subpath);
// Only add this task if it contains all search-tags.
// NOTE: Supports nested tags, so "#foo" matches "#foo/bar",
// and properly parses tags, so "#foo" won't match "#foos".
if (search_re.every(re => t.tags.some(v => re.test(v)))) {
next_tasks.push(t);
}
});
});
dv.taskList(next_tasks, true);
Tasks/Projects/Test Project 1.md
# Subproject 1
- [ ] Task 1 #context/online #prio/high
- [ ] Task 2 #context/online #prio/high
- [ ] Task 3 #context/online #prio/high
# Subproject 2
- [x] Task 2.1 #context/online #prio/high
- [ ] Task 2.2 #context/online #prio/high
- [ ] Task 2.3 #context/online #prio/high
Now view View.md
and then right-click on Test Project 1.md
and rename it. The dataview query clearly re-runs (you can see it flicker), but the page title/links in the dataview aren't updated. It will still say the name Test Project 1
.
The only way to achieve an update is to restart Obsidian, OR go into the renamed document and edit the actual text contents of it.
My guess why this is a bug:
- Renaming a file doesn't change its size or modification time. Perhaps Dataview treats the file as "already cached" and skips the changes if we only rename it?
There's a command to refresh views, can you check if that helps?
Hmm, file renames seem to update instantly in views for me; Dataview watches for file renames according to the Obsidian metadata-cache:rename
event, and updates data there.
Hello, sorry to come back to you so late. I currently go through older issues to see which are stale or already solved.
Due to missing feedback, I'll close the issue for now. If the problem still occurs for you, please comment on the issue with details on what is not working as expected and the requested information and I'll reopen your report.
Hi, I stumbled upon this issue because I still have the same exact problem.
It seems that the file link is NOT updated when doing a TASK
query, but IS updated when doing other kind of query, for example:
TABLE
file.tasks
WHERE file.tasks