Failed to create file when trying to open weekly note
See original GitHub issueSo… This is weird, especially after taking a look at the code both in this repo and obsidian-daily-notes-interface
.
Whenever I create a weekly note for the first time, everything works as expected. It creates the note in my designated location, and opens it in the editor. However, when I move to another note and invoke the Periodic Notes: Open weekly note
command via the command palette, I get the following error in the console:
Failed to create file: 'Journal/Weekly Reviews/2021-W30.md' Error: File already exists.
Which… makes sense. Because the file already exists. But I expected it to just open the weekly note, just like how it works for the daily notes. These are the settings that I’m using at the moment.
The only thing I could think of is it being an issue with the “escape characters” used in the Format
. I could imagine that the code checks if the file exists (to already open it) is somehow “fooled” when using a character like this, and that would always return false
. At the same time though, I tried running window.app.vault.create("Journal/Weekly Reviews/2021-W30.md");
manually from the console, but got the same error. So I’m kind of lost here. Hope you can help me out! 😄
Issue Analytics
- State:
- Created 2 years ago
- Comments:9
Top GitHub Comments
@urdvr you’re absolutely right! Installing the Calendar plugin and setting the “Start week on”-setting to “Monday” does indeed fix the issue. Thanks for your detective work, I couldn’t spot that issue you described but it totally makes sense as to why it’s messing up now.
I’ll leave this issue open if we want to track the bug here, but in the meantime I’ll work around it by just keeping the Calendar plugin installed.
This issue happens because the start of the ISO week should be on Monday, but the default is Sunday. Periodic Notes checks if you have a note for the current week, sees that you do not, takes the start of the current week (incorrectly, previous Sunday) and tries to create the file that corresponds to that ISO week. This fails because the file already exists.
The correct solution would be to use
isoWeek
as the unit of time inconst startOfPeriod = date.clone().startOf(config.unitOfTime)
in the openPeriodicNote function if the week format is WW. Or just to skip the “take the start of the current week” step.A workaround that seems to work for me is to install the “Calendar” plugin by the same author (https://github.com/liamcain/obsidian-calendar-plugin) and set the “Start week on” option to Monday. This seems to override the default and I don’t get errors.