mirror of
https://github.com/JulianGro/overte.git
synced 2025-08-05 06:42:51 +02:00
Merge pull request #86 from birarda/atp-mappings
disable client caching of ATP mappings, fix bug retreiving assets
This commit is contained in:
commit
aeee89eb15
4 changed files with 1 additions and 37 deletions
|
@ -220,12 +220,10 @@ void AssetServer::handleGetMappingOperation(ReceivedMessage& message, SharedNode
|
|||
auto it = _fileMappings.find(assetPath);
|
||||
if (it != _fileMappings.end()) {
|
||||
auto assetHash = it->toString();
|
||||
qDebug() << "Found mapping for: " << assetPath << "=>" << assetHash;
|
||||
replyPacket.writePrimitive(AssetServerError::NoError);
|
||||
replyPacket.write(QByteArray::fromHex(assetHash.toUtf8()));
|
||||
}
|
||||
else {
|
||||
qDebug() << "Mapping not found for: " << assetPath;
|
||||
replyPacket.writePrimitive(AssetServerError::AssetNotFound);
|
||||
}
|
||||
}
|
||||
|
@ -314,7 +312,7 @@ void AssetServer::handleAssetGetInfo(QSharedPointer<ReceivedMessage> message, Sh
|
|||
replyPacket->write(assetHash);
|
||||
|
||||
QString fileName = QString(hexHash);
|
||||
QFileInfo fileInfo { _resourcesDirectory.filePath(fileName) };
|
||||
QFileInfo fileInfo { _filesDirectory.filePath(fileName) };
|
||||
|
||||
if (fileInfo.exists() && fileInfo.isReadable()) {
|
||||
qDebug() << "Opening file: " << fileInfo.filePath();
|
||||
|
|
|
@ -91,8 +91,6 @@ void AssetClient::clearCache() {
|
|||
return;
|
||||
}
|
||||
|
||||
_mappingCache.clear();
|
||||
|
||||
if (auto cache = NetworkAccessManager::getInstance().cache()) {
|
||||
qDebug() << "AssetClient::clearCache(): Clearing disk cache.";
|
||||
cache->clear();
|
||||
|
@ -578,6 +576,4 @@ void AssetClient::handleNodeKilled(SharedNodePointer node) {
|
|||
messageMapIt->second.clear();
|
||||
}
|
||||
}
|
||||
|
||||
_mappingCache.clear();
|
||||
}
|
||||
|
|
|
@ -95,8 +95,6 @@ private:
|
|||
std::unordered_map<SharedNodePointer, std::unordered_map<MessageID, GetInfoCallback>> _pendingInfoRequests;
|
||||
std::unordered_map<SharedNodePointer, std::unordered_map<MessageID, UploadResultCallback>> _pendingUploads;
|
||||
|
||||
QHash<QString, QString> _mappingCache;
|
||||
|
||||
friend class AssetRequest;
|
||||
friend class AssetUpload;
|
||||
friend class GetMappingRequest;
|
||||
|
|
|
@ -32,14 +32,6 @@ void GetMappingRequest::doStart() {
|
|||
|
||||
auto assetClient = DependencyManager::get<AssetClient>();
|
||||
|
||||
// Check cache
|
||||
auto it = assetClient->_mappingCache.constFind(_path);
|
||||
if (it != assetClient->_mappingCache.constEnd()) {
|
||||
_hash = it.value();
|
||||
emit finished(this);
|
||||
return;
|
||||
}
|
||||
|
||||
assetClient->getAssetMapping(_path, [this, assetClient](bool responseReceived, AssetServerError error, QSharedPointer<ReceivedMessage> message) {
|
||||
if (!responseReceived) {
|
||||
_error = NetworkError;
|
||||
|
@ -59,7 +51,6 @@ void GetMappingRequest::doStart() {
|
|||
|
||||
if (!_error) {
|
||||
_hash = message->read(SHA256_HASH_LENGTH).toHex();
|
||||
assetClient->_mappingCache[_path] = _hash;
|
||||
}
|
||||
emit finished(this);
|
||||
});
|
||||
|
@ -88,12 +79,10 @@ void GetAllMappingsRequest::doStart() {
|
|||
if (!error) {
|
||||
int numberOfMappings;
|
||||
message->readPrimitive(&numberOfMappings);
|
||||
assetClient->_mappingCache.clear();
|
||||
for (auto i = 0; i < numberOfMappings; ++i) {
|
||||
auto path = message->readString();
|
||||
auto hash = message->readString();
|
||||
_mappings[path] = hash;
|
||||
assetClient->_mappingCache[path] = hash;
|
||||
}
|
||||
}
|
||||
emit finished(this);
|
||||
|
@ -122,9 +111,6 @@ void SetMappingRequest::doStart() {
|
|||
}
|
||||
}
|
||||
|
||||
if (!error) {
|
||||
assetClient->_mappingCache[_path] = _hash;
|
||||
}
|
||||
emit finished(this);
|
||||
});
|
||||
};
|
||||
|
@ -151,12 +137,6 @@ void DeleteMappingsRequest::doStart() {
|
|||
}
|
||||
}
|
||||
|
||||
if (!error) {
|
||||
// enumerate the paths and remove them from the cache
|
||||
for (auto& path : _paths) {
|
||||
assetClient->_mappingCache.remove(path);
|
||||
}
|
||||
}
|
||||
emit finished(this);
|
||||
});
|
||||
};
|
||||
|
@ -189,14 +169,6 @@ void RenameMappingRequest::doStart() {
|
|||
}
|
||||
}
|
||||
|
||||
if (!error) {
|
||||
// take the hash mapped for the old path from the cache
|
||||
auto hash = assetClient->_mappingCache.take(_oldPath);
|
||||
if (!hash.isEmpty()) {
|
||||
// use the hash mapped for the old path for the new path
|
||||
assetClient->_mappingCache[_newPath] = hash;
|
||||
}
|
||||
}
|
||||
emit finished(this);
|
||||
});
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue