mirror of
https://github.com/overte-org/overte.git
synced 2025-04-23 10:53:34 +02:00
Merge pull request #12481 from birarda/feat/content-settings
immediately show restore, set restore filename, cleanup old AS baked content on start
This commit is contained in:
commit
0e5e63bf03
4 changed files with 46 additions and 1 deletions
assignment-client/src/assets
domain-server
|
@ -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 (const 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 (const 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);
|
||||
|
|
|
@ -67,6 +67,10 @@ $(document).ready(function(){
|
|||
data: fileFormData
|
||||
}).done(function(data, textStatus, jqXHR) {
|
||||
isRestoring = true;
|
||||
|
||||
// immediately reload backup information since one should be restoring now
|
||||
reloadBackupInformation();
|
||||
|
||||
swal.close();
|
||||
}).fail(function(jqXHR, textStatus, errorThrown) {
|
||||
showErrorMessage(
|
||||
|
@ -297,6 +301,10 @@ $(document).ready(function(){
|
|||
// setup an AJAX POST to request content restore
|
||||
$.post('/api/backups/recover/' + backupID).done(function(data, textStatus, jqXHR) {
|
||||
isRestoring = true;
|
||||
|
||||
// immediately reload our backup information since one should be restoring now
|
||||
reloadBackupInformation();
|
||||
|
||||
swal.close();
|
||||
}).fail(function(jqXHR, textStatus, errorThrown) {
|
||||
showErrorMessage(
|
||||
|
|
|
@ -250,6 +250,7 @@ bool DomainContentBackupManager::recoverFromBackupZip(const QString& backupName,
|
|||
return false;
|
||||
} else {
|
||||
_isRecovering = true;
|
||||
_recoveryFilename = backupName;
|
||||
|
||||
for (auto& handler : _backupHandlers) {
|
||||
handler->recoverBackup(backupName, zip);
|
||||
|
|
Loading…
Reference in a new issue