From 1251328d2b2e0aa3bde3a15e545b0b569c1b9444 Mon Sep 17 00:00:00 2001 From: Stephen Birarda Date: Thu, 22 Feb 2018 16:53:49 -0800 Subject: [PATCH 1/4] reload backup information immediately when restore starts --- domain-server/resources/web/content/js/content.js | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/domain-server/resources/web/content/js/content.js b/domain-server/resources/web/content/js/content.js index f5525e9892..6e80fde7f6 100644 --- a/domain-server/resources/web/content/js/content.js +++ b/domain-server/resources/web/content/js/content.js @@ -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( From 3e4375b1e6a6ba58e1b2fe40126e867cd0c0e0de Mon Sep 17 00:00:00 2001 From: Stephen Birarda Date: Thu, 22 Feb 2018 16:54:56 -0800 Subject: [PATCH 2/4] set recovery filename during domain content archive recovery --- domain-server/src/DomainContentBackupManager.cpp | 1 + 1 file changed, 1 insertion(+) diff --git a/domain-server/src/DomainContentBackupManager.cpp b/domain-server/src/DomainContentBackupManager.cpp index f94f62811e..eff69ee167 100644 --- a/domain-server/src/DomainContentBackupManager.cpp +++ b/domain-server/src/DomainContentBackupManager.cpp @@ -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); From d9d2b26519d611a3405bf3ae10043fa53ec30a60 Mon Sep 17 00:00:00 2001 From: Stephen Birarda Date: Thu, 22 Feb 2018 16:55:35 -0800 Subject: [PATCH 3/4] delete baked content for unmapped files on AS startup --- assignment-client/src/assets/AssetServer.cpp | 35 +++++++++++++++++++- assignment-client/src/assets/AssetServer.h | 3 ++ 2 files changed, 37 insertions(+), 1 deletion(-) diff --git a/assignment-client/src/assets/AssetServer.cpp b/assignment-client/src/assets/AssetServer.cpp index 4c6cba2e74..509f8095c9 100644 --- a/assignment-client/src/assets/AssetServer.cpp +++ b/assignment-client/src/assets/AssetServer.cpp @@ -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 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 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 message, SharedNodePointer senderNode) { using AssetMappingOperationType = AssetUtils::AssetMappingOperationType; diff --git a/assignment-client/src/assets/AssetServer.h b/assignment-client/src/assets/AssetServer.h index c85fb89175..f5a7d5f2da 100644 --- a/assignment-client/src/assets/AssetServer.h +++ b/assignment-client/src/assets/AssetServer.h @@ -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 getAssetStatus(const AssetUtils::AssetPath& path, const AssetUtils::AssetHash& hash); From a0f7d4dd345dc122d2bd25fe27c635313424baf8 Mon Sep 17 00:00:00 2001 From: Stephen Birarda Date: Thu, 22 Feb 2018 18:08:08 -0800 Subject: [PATCH 4/4] use const auto & where possible as per CR comments --- assignment-client/src/assets/AssetServer.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/assignment-client/src/assets/AssetServer.cpp b/assignment-client/src/assets/AssetServer.cpp index 509f8095c9..f600f5edc2 100644 --- a/assignment-client/src/assets/AssetServer.cpp +++ b/assignment-client/src/assets/AssetServer.cpp @@ -511,7 +511,7 @@ void AssetServer::cleanupBakedFilesForDeletedAssets() { std::set bakedHashes; - for (auto it : _fileMappings) { + 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 @@ -524,7 +524,7 @@ void AssetServer::cleanupBakedFilesForDeletedAssets() { } // enumerate the hashes for which we have baked content - for (auto hash : bakedHashes) { + 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 mappingPair) {