mirror of
https://github.com/HifiExperiments/overte.git
synced 2025-08-04 21:33:09 +02:00
delete baked content for unmapped files on AS startup
This commit is contained in:
parent
3e4375b1e6
commit
d9d2b26519
2 changed files with 37 additions and 1 deletions
|
@ -394,6 +394,7 @@ void AssetServer::completeSetup() {
|
|||
|
||||
if (_fileMappings.size() > 0) {
|
||||
cleanupUnmappedFiles();
|
||||
cleanupBakedFilesForDeletedAssets();
|
||||
}
|
||||
|
||||
nodeList->addSetOfNodeTypesToNodeInterestSet({ NodeType::Agent, NodeType::EntityScriptServer });
|
||||
|
@ -473,7 +474,7 @@ void AssetServer::replayRequests() {
|
|||
}
|
||||
|
||||
void AssetServer::cleanupUnmappedFiles() {
|
||||
QRegExp hashFileRegex { "^[a-f0-9]{" + QString::number(AssetUtils::SHA256_HASH_HEX_LENGTH) + "}" };
|
||||
QRegExp hashFileRegex { AssetUtils::ASSET_HASH_REGEX_STRING };
|
||||
|
||||
auto files = _filesDirectory.entryInfoList(QDir::Files);
|
||||
|
||||
|
@ -505,6 +506,38 @@ void AssetServer::cleanupUnmappedFiles() {
|
|||
}
|
||||
}
|
||||
|
||||
void AssetServer::cleanupBakedFilesForDeletedAssets() {
|
||||
qCInfo(asset_server) << "Performing baked asset cleanup for deleted assets";
|
||||
|
||||
std::set<AssetUtils::AssetHash> bakedHashes;
|
||||
|
||||
for (auto it : _fileMappings) {
|
||||
// check if this is a mapping to baked content
|
||||
if (it.first.startsWith(AssetUtils::HIDDEN_BAKED_CONTENT_FOLDER)) {
|
||||
// extract the hash from the baked mapping
|
||||
AssetUtils::AssetHash hash = it.first.mid(AssetUtils::HIDDEN_BAKED_CONTENT_FOLDER.length(),
|
||||
AssetUtils::SHA256_HASH_HEX_LENGTH);
|
||||
|
||||
// add the hash to our set of hashes for which we have baked content
|
||||
bakedHashes.insert(hash);
|
||||
}
|
||||
}
|
||||
|
||||
// enumerate the hashes for which we have baked content
|
||||
for (auto hash : bakedHashes) {
|
||||
// check if we have a mapping that points to this hash
|
||||
auto matchingMapping = std::find_if(std::begin(_fileMappings), std::end(_fileMappings),
|
||||
[&hash](const std::pair<AssetUtils::AssetPath, AssetUtils::AssetHash> mappingPair) {
|
||||
return mappingPair.second == hash;
|
||||
});
|
||||
|
||||
if (matchingMapping == std::end(_fileMappings)) {
|
||||
// we didn't find a mapping for this hash, remove any baked content we still have for it
|
||||
removeBakedPathsForDeletedAsset(hash);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void AssetServer::handleAssetMappingOperation(QSharedPointer<ReceivedMessage> message, SharedNodePointer senderNode) {
|
||||
using AssetMappingOperationType = AssetUtils::AssetMappingOperationType;
|
||||
|
||||
|
|
|
@ -88,6 +88,9 @@ private:
|
|||
/// Delete any unmapped files from the local asset directory
|
||||
void cleanupUnmappedFiles();
|
||||
|
||||
/// Delete any baked files for assets removed from the local asset directory
|
||||
void cleanupBakedFilesForDeletedAssets();
|
||||
|
||||
QString getPathToAssetHash(const AssetUtils::AssetHash& assetHash);
|
||||
|
||||
std::pair<AssetUtils::BakingStatus, QString> getAssetStatus(const AssetUtils::AssetPath& path, const AssetUtils::AssetHash& hash);
|
||||
|
|
Loading…
Reference in a new issue