diff options
author | Timo Weingärtner <timo@tiwe.de> | 2011-11-28 01:11:16 +0100 |
---|---|---|
committer | Timo Weingärtner <timo@tiwe.de> | 2011-11-30 14:30:29 +0100 |
commit | 7349d7a5f4c305f5ba350858cc810ab79ca81bb4 (patch) | |
tree | 90a1c8258a331f15d02527892a4922cd62b2a333 /hadori.C | |
parent | f52b13a15df60b02e10f88b656192a2db5077706 (diff) | |
download | hadori-7349d7a5f4c305f5ba350858cc810ab79ca81bb4.tar.gz |
forget/dont't memorize inode in to_link if st_nlink == 1
Might have caused data loss if inode number is reallocted to a file inside
the tree(s) being scanned.
Also saves a little bit of memory.
Diffstat (limited to 'hadori.C')
-rw-r--r-- | hadori.C | 5 |
1 files changed, 4 insertions, 1 deletions
@@ -56,6 +56,8 @@ void handle_file(std::string const & path, struct stat const & s) { inode const & target = kept.find(to_link[s.st_ino])->second; debug << "another link to inode " << s.st_ino << " that we merge with " << target << std::endl; do_link(target, path); + if (s.st_nlink == 1) + to_link.erase(s.st_ino); return; } inode f(path, s); @@ -78,7 +80,8 @@ void handle_file(std::string const & path, struct stat const & s) { if (!compare(candidate, f)) continue; verbose << "linking " << candidate << " to " << path << std::endl; - to_link.insert(std::make_pair(s.st_ino, it->second)); + if (s.st_nlink > 1) + to_link.insert(std::make_pair(s.st_ino, it->second)); if (not config.count("dry-run")) do_link(candidate, path); return; |