-
-
Notifications
You must be signed in to change notification settings - Fork 5
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
Error: File already exists #28
Comments
Looks like it's happening somewhere in here: async function createWeeklyNote2(date) {
const { vault } = window.app;
const { template, format: format2, folder } = getWeeklyNoteSettings();
const [templateContents, IFoldInfo] = await getTemplateInfo(template);
const filename = date.format(format2);
const normalizedPath = await getNotePath(folder, filename);
try {
const createdFile = await vault.create(normalizedPath, templateContents.replace(/{{\s*(date|time)\s*(([+-]\d+)([yqmwdhs]))?\s*(:.+?)?}}/gi, (_, _timeOrDate, calc, timeDelta, unit, momentFormat) => {
const now2 = window.moment();
const currentDate = date.clone().set({
hour: now2.get("hour"),
minute: now2.get("minute"),
second: now2.get("second")
});
if (calc) {
currentDate.add(parseInt(timeDelta, 10), unit);
}
if (momentFormat) {
return currentDate.format(momentFormat.substring(1).trim());
}
return currentDate.format(format2);
}).replace(/{{\s*title\s*}}/gi, filename).replace(/{{\s*time\s*}}/gi, window.moment().format("HH:mm")).replace(/{{\s*(sunday|monday|tuesday|wednesday|thursday|friday|saturday)\s*:(.*?)}}/gi, (_, dayOfWeek, momentFormat) => {
const day = getDayOfWeekNumericalValue(dayOfWeek);
return date.weekday(day).format(momentFormat.trim());
}));
window.app.foldManager.save(createdFile, IFoldInfo);
return createdFile;
} catch (err) {
console.error(`Failed to create file: '${normalizedPath}'`, err);
new obsidian.Notice("Unable to create new file.");
}
} We could avoid calling |
It seems like this issue only affects weekly notes. The plugin adds a clipped entry into daily notes without a problem even if the note exists already. |
I haven't been able to reproduce this yet, though I did find other issues unrelated to this. Can you share what Operating System you are on. Can you also share what version of Obsidian you are using? Thanks! |
Hey, thanks for a reply. Here's the information:
|
I was able to reproduce this now. Clipper uses the Oddly, I can only recreate this if I use a Note Title Format like yours :).
|
This is an issue in the Not sure why the code doesn't just take the date, the format, generate the path and see if that exists. I don't think I will be able to fix this one on my end currently. |
The periodic-notes-interface library is causing the problem. It was designed/extracted from the calendar plugin so has an odd interface. I am going to play around to see if I can support this a different way. |
Hi! Thanks a lot for creating this plugin first of all. 🙇
When I clip something when there's no target note created, it creates a new daily/weekly note and adds the clip there. However, if I clip some other thing again, it fails with the following error:
I think it may be related with some plugins I'm using, such as Templater, Periodic notes and Calendar, but it'd be nice if the clipper plugin doesn't attempt to create a new note when it exists already.
The text was updated successfully, but these errors were encountered: