summaryrefslogtreecommitdiff
path: root/hadori.C
diff options
context:
space:
mode:
authorTimo Weingärtner <timo@tiwe.de>2018-10-27 21:37:40 +0200
committerTimo Weingärtner <timo@tiwe.de>2018-10-27 21:39:28 +0200
commit2cad5033359975238cbb95824595b638892bc039 (patch)
tree0fbc4dab84ddb937461d16848c3c35a56fc6b313 /hadori.C
parent07d402e83fd6b58d53825441169503cc92fd71d6 (diff)
downloadhadori-2cad5033359975238cbb95824595b638892bc039.tar.gz
move dry-run checking into do_link
Diffstat (limited to 'hadori.C')
-rw-r--r--hadori.C5
1 files changed, 3 insertions, 2 deletions
diff --git a/hadori.C b/hadori.C
index f5aebda..4465ef3 100644
--- a/hadori.C
+++ b/hadori.C
@@ -71,6 +71,8 @@ inline std::ostream& operator<< (std::ostream& os, inode const & i) {
}
static void do_link (inode const & i, std::string const & other) {
+ if (config.count("dry-run"))
+ return;
if (!link(i.filename.c_str(), other.c_str())) {
error << "linking " << i << " to " << other << " succeeded before unlinking (race condition)" << std::endl;
exit(EX_UNAVAILABLE);
@@ -129,8 +131,7 @@ static void handle_file (std::string const & path, struct stat const & s) {
verbose << "linking " << candidate << " to " << path << std::endl;
if (s.st_nlink > 1)
to_link.insert({s.st_ino, it.second});
- if (not config.count("dry-run"))
- do_link(candidate, path);
+ do_link(candidate, path);
return;
}
debug << "we keep " << f << std::endl;