mirror of
https://github.com/RetroShare/RetroShare.git
synced 2025-02-06 10:05:38 -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,13 +1008,33 @@ void FileIndexMonitor::hashFiles(const std::vector<DirContentToHash>& to_hash)
|
|||||||
/* update fileIndex with new time */
|
/* update fileIndex with new time */
|
||||||
/* update with new time */
|
/* update with new time */
|
||||||
|
|
||||||
fi.updateFileEntry(to_hash[i].dirpath,fe,stamp);
|
// Check again that the hashed file hasn't been modified since the beginning of the hashing process.
|
||||||
|
// If so, drop it.
|
||||||
|
//
|
||||||
|
struct stat64 buf;
|
||||||
|
|
||||||
hashed_size += to_hash[i].fentries[j].size ;
|
#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);
|
||||||
|
|
||||||
// Update the hash cache
|
hashed_size += to_hash[i].fentries[j].size ;
|
||||||
if(useHashCache)
|
|
||||||
hashCache.insert(real_path,fe.size,fe.modtime,fe.hash) ;
|
// Update the hash cache
|
||||||
|
//
|
||||||
|
if(useHashCache)
|
||||||
|
hashCache.insert(real_path,fe.size,fe.modtime,fe.hash) ;
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
std::cerr << "Failed to Hash File " << fe.name << std::endl;
|
std::cerr << "Failed to Hash File " << fe.name << std::endl;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user