Merge pull request from birarda/feat/content-settings

immediately show restore, set restore filename, cleanup old AS baked content on start
This commit is contained in:
Clément Brisset 2018-02-22 18:41:13 -08:00 committed by GitHub
commit 0e5e63bf03
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
4 changed files with 46 additions and 1 deletions
assignment-client/src/assets
domain-server
resources/web/content/js
src

View file

@ -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;

View file

@ -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);

View file

@ -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(

View file

@ -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);