aboutsummaryrefslogtreecommitdiff
path: root/IkiWiki/Render.pm
diff options
context:
space:
mode:
authorJoey Hess <joey@kodama.kitenet.net>2008-07-12 23:31:27 -0400
committerJoey Hess <joey@kodama.kitenet.net>2008-07-12 23:31:27 -0400
commit0b140ed1c8428d6984e1e0294b5008670d4f87fe (patch)
tree2cdb5a7a32dea5c1391f4fda62161997b103f6ac /IkiWiki/Render.pm
parente3c0e4977449de2eec36e254a7e131693ba2f822 (diff)
downloadikiwiki-0b140ed1c8428d6984e1e0294b5008670d4f87fe.tar
ikiwiki-0b140ed1c8428d6984e1e0294b5008670d4f87fe.tar.gz
avoid hardlinking files owned by others
If hardlinks are enabled, it would hardlink files from the underlay. That was sorta annoying if you tried to edit by hand for some reason, so let's not. Files that are hardlinked should be rare enough that a few extra stats won't hurt.
Diffstat (limited to 'IkiWiki/Render.pm')
-rw-r--r--IkiWiki/Render.pm12
1 files changed, 8 insertions, 4 deletions
diff --git a/IkiWiki/Render.pm b/IkiWiki/Render.pm
index c241fd40b..990fcaaa1 100644
--- a/IkiWiki/Render.pm
+++ b/IkiWiki/Render.pm
@@ -229,10 +229,14 @@ sub render ($) { #{{{
will_render($file, $file, 1);
if ($config{hardlink}) {
- prep_writefile($file, $config{destdir});
- unlink($config{destdir}."/".$file);
- if (link($srcfile, $config{destdir}."/".$file)) {
- return;
+ # only hardlink if owned by same user
+ my @stat=stat($srcfile);
+ if ($stat[4] == $>) {
+ prep_writefile($file, $config{destdir});
+ unlink($config{destdir}."/".$file);
+ if (link($srcfile, $config{destdir}."/".$file)) {
+ return;
+ }
}
# if hardlink fails, fall back to copying
}