mirror of
https://github.com/RetroShare/RetroShare.git
synced 2025-01-30 09:13:40 -05:00
added post-hash check for file modification. If the file has been modified while being hashed, it will not be shared until re-hashed. Should prevent chunks error in files that get hashed while being copied.
git-svn-id: http://svn.code.sf.net/p/retroshare/code/trunk@6924 b45a01b8-16f6-495d-af2f-9b41ad6348cc
This commit is contained in:
parent
e269128bdc
commit
79e25b5dce
@ -1008,14 +1008,34 @@ void FileIndexMonitor::hashFiles(const std::vector<DirContentToHash>& to_hash)
|
||||
/* update fileIndex with new time */
|
||||
/* update with new time */
|
||||
|
||||
// Check again that the hashed file hasn't been modified since the beginning of the hashing process.
|
||||
// If so, drop it.
|
||||
//
|
||||
struct stat64 buf;
|
||||
|
||||
#ifdef WINDOWS_SYS
|
||||
std::wstring wfullname;
|
||||
librs::util::ConvertUtf8ToUtf16(real_path, wfullname);
|
||||
if ( 0 == _wstati64(wfullname.c_str(), &buf))
|
||||
#else
|
||||
if ( 0 == stat64(real_path.c_str(), &buf))
|
||||
#endif
|
||||
{
|
||||
if(buf.st_mtime != fe.modtime)
|
||||
std::cerr << "File " << real_path << " has been modified while being hashed. It will be dropped to avoid data inconsistency" << std::endl;
|
||||
else
|
||||
{
|
||||
fi.updateFileEntry(to_hash[i].dirpath,fe,stamp);
|
||||
|
||||
hashed_size += to_hash[i].fentries[j].size ;
|
||||
|
||||
// Update the hash cache
|
||||
//
|
||||
if(useHashCache)
|
||||
hashCache.insert(real_path,fe.size,fe.modtime,fe.hash) ;
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
std::cerr << "Failed to Hash File " << fe.name << std::endl;
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user