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.master
parent
e3c0e49774
commit
0b140ed1c8
|
@ -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
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue