Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

Already on GitHub? Sign in to your account

Add source and destination directory protection #535

Merged
merged 2 commits into from Dec 26, 2012

Conversation

Projects
None yet
6 participants

After accidentally telling jekyll to use my source directory as it's destination directory, and losing work because it also deleted my .git directory and all other hidden files, I updated the library to take steps to prevent this from happening again.

First was to remove the dot-file deletion entirely from the cleanup of the site. This is a potentially very dangerous action that's impossible to test that it's correct. If the '..' check line ever disappears, even running the tests will attempt to delete everything accessible on the person's computer.

From what I can tell, all generated dot-files will already be known by Jekyll, and any static files will be configured for Jekyll to include, so it should properly remove all the files that it already knows about.

With this changed, I've also added a check on site generation that the destination directory doesn't include, or isn't exactly the same as, the source directory. While this isn't 100% fool proof, you'd need to use some symlinking to still cause an unfortunate destruction of your source files, this should cover almost all cases people would normally run into.

This is the results of discussion in #534 among others.

Jason Roelofs added some commits Apr 4, 2012

Remove deletion of dot files on cleanup.
This is a potentially very dangerous action that's impossible to test that it's correct.
If the '..' check line ever disappears, even running the tests will start deleting
everything accessible on the person's computer.

All dot-files that are generated are already known by Jekyll as either a static file or
a page (yaml front matter), only remove those files.
Contributor

mojombo commented Dec 26, 2012

This is a great protection to have in place. We all make mistakes sometimes, and software should prevent us from doing stupid things. Thanks!

@mojombo mojombo merged commit 604b60c into jekyll:master Dec 26, 2012

Member

ixti commented Dec 26, 2012

👍

zephiro commented Feb 10, 2013

It has always bothered me that Jekyll mangles timestamps. When you run jekyll to regenerate your site, all timestamps are updated to the current time. (This is because all pages are regenerated—a separate and also annoying issue.) So to anything that uses timestamps to determine when a page has changed, it appears that every page changes whenever a single page changes.

The solution would be Jekyll, generate only the files that have changed and not all

Owner

parkr commented Feb 10, 2013

@web2developer It's a nice idea, but not really something that is practical. We could keep a cache and check the contents with a hash or something for changes, but we have to regenerate the entire site again (except static files) if any change has been made to any pieces of the site. That's because Jekyll has no idea how your site is interconnected. Jekyll must regenerate all files when anything has changed - there's no real way around it.

@jasonroelofs jasonroelofs deleted the jasonroelofs:deletion_protection branch Aug 5, 2013

@jekyllbot jekyllbot locked and limited conversation to collaborators Feb 27, 2017

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.