Fix terrasync hash persistence
This commit is contained in:
parent
a0c4913f84
commit
f77724a646
@ -1006,11 +1006,11 @@ HTTPRepository::failure() const
|
|||||||
|
|
||||||
SGPath cachePath = basePath;
|
SGPath cachePath = basePath;
|
||||||
cachePath.append(".hashes");
|
cachePath.append(".hashes");
|
||||||
sg_ofstream stream(cachePath, std::ios::out | std::ios::trunc);
|
sg_ofstream stream(cachePath, std::ios::out | std::ios::trunc | std::ios::binary);
|
||||||
HashCache::const_iterator it;
|
HashCache::const_iterator it;
|
||||||
for (it = hashes.begin(); it != hashes.end(); ++it) {
|
for (it = hashes.begin(); it != hashes.end(); ++it) {
|
||||||
stream << it->filePath << ":" << it->modTime << ":"
|
stream << it->filePath << "*" << it->modTime << "*"
|
||||||
<< it->lengthBytes << ":" << it->hashHex << "\n";
|
<< it->lengthBytes << "*" << it->hashHex << "\n";
|
||||||
}
|
}
|
||||||
stream.close();
|
stream.close();
|
||||||
hashCacheDirty = false;
|
hashCacheDirty = false;
|
||||||
@ -1034,7 +1034,7 @@ HTTPRepository::failure() const
|
|||||||
if( line.empty() || line[0] == '#' )
|
if( line.empty() || line[0] == '#' )
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
string_list tokens = simgear::strutils::split( line, ":" );
|
string_list tokens = simgear::strutils::split(line, "*");
|
||||||
if( tokens.size() < 4 ) {
|
if( tokens.size() < 4 ) {
|
||||||
SG_LOG(SG_TERRASYNC, SG_WARN, "invalid entry in '" << cachePath << "': '" << line << "' (ignoring line)");
|
SG_LOG(SG_TERRASYNC, SG_WARN, "invalid entry in '" << cachePath << "': '" << line << "' (ignoring line)");
|
||||||
continue;
|
continue;
|
||||||
@ -1056,6 +1056,9 @@ HTTPRepository::failure() const
|
|||||||
entry.lengthBytes = strtol(sizeData.c_str(), NULL, 10);
|
entry.lengthBytes = strtol(sizeData.c_str(), NULL, 10);
|
||||||
hashes.push_back(entry);
|
hashes.push_back(entry);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
SG_LOG(SG_TERRASYNC, SG_INFO, "restored hashes:" << hashes.size());
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
class DirectoryWithPath
|
class DirectoryWithPath
|
||||||
|
Loading…
Reference in New Issue
Block a user