-
-
Notifications
You must be signed in to change notification settings - Fork 95
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
Prevent overwriting the output files #170
Conversation
This often happens when you try to write out `tags/Blog` and `tags/blog` on case-insensitive systems.
Note that I used the experimental api |
OMG I didn't realise that Lume does overwrite the current file in |
Ovewriting output files is the intended behavior because on const urls = new Set();
for (const page of pages) {
const path = page.dest.path + page.dest.ext;
const id = path.toLowerCase();
if (urls.has(id)) {
console.log(`Duplicated page ${path}`);
}
urls.add(path);
} |
Note that |
Pathname of URL is case sensitive. If your file system allows How about defining a property in Page object which represents the page is already built or not yet? |
Hmm? I wrote something strange. It does not work. Please forget about the suggestion at the end of my last message🤔 |
We can pool the file inode number we actually wrote to. This easily enables us to detect the duplication. But this is only possible on Unix-like system. |
In order to make the site working consistently on any platform, I'd consider duplication detection case insensitive, meaning that I also think that this detection should only show a warning, but the output file should be overwritten, so it's up to the user to fix it or not. |
FYI, eleventy has the same feature: 11ty/eleventy#562 |
I meant it's difficult to support case sensitive output while prohibiting it in case sensitive file systems. It's not a problem if you warn duplication detected in case insensitively for all file systems. I'll modify the commit. Part of this PR is better to be applied to fix the problem of the output file being mixture of duplicated two input content. This happens because writing to |
to prevent mixing up the duplicated file contents
Here it is! |
Nice, thank you! |
Imagine you accidentally create two tags
blog
andBlog
, and let Lume generate_site/tags/blog/index.html
and_site/tags/Blog/index.html
respectively (this is exactly what I did).Case-insensitive filesystems regard those two files as the same, allowing Lume to overwrite one with the other.
This PR warns user that there already exist a generated file.