mirror of
https://github.com/AleziaKurdis/overte.git
synced 2025-04-08 06:32:35 +02:00
Merge pull request #12466 from Atlante45/feat/backups-integration
Fix crash on manual upload recovery
This commit is contained in:
commit
af3970e211
2 changed files with 16 additions and 7 deletions
|
@ -101,7 +101,10 @@ void AssetsBackupHandler::checkForAssetsToDelete() {
|
|||
|
||||
if (deprecatedAssets.size() > 0) {
|
||||
qCDebug(asset_backup) << "Found" << deprecatedAssets.size() << "backup assets to delete from disk.";
|
||||
if (_allBackupsLoadedSuccessfully) {
|
||||
const auto noCorruptedBackups = none_of(begin(_backups), end(_backups), [&](const AssetServerBackup& backup) {
|
||||
return backup.corruptedBackup;
|
||||
});
|
||||
if (noCorruptedBackups) {
|
||||
for (const auto& hash : deprecatedAssets) {
|
||||
QFile::remove(_assetsDirectory + hash);
|
||||
}
|
||||
|
@ -175,7 +178,6 @@ void AssetsBackupHandler::loadBackup(const QString& backupName, QuaZip& zip) {
|
|||
qCCritical(asset_backup) << "Failed to find" << MAPPINGS_FILE << "while loading backup";
|
||||
qCCritical(asset_backup) << " Error:" << zip.getZipError();
|
||||
backup.corruptedBackup = true;
|
||||
_allBackupsLoadedSuccessfully = false;
|
||||
return;
|
||||
}
|
||||
|
||||
|
@ -184,7 +186,6 @@ void AssetsBackupHandler::loadBackup(const QString& backupName, QuaZip& zip) {
|
|||
qCCritical(asset_backup) << "Could not unzip backup file for load:" << backupName;
|
||||
qCCritical(asset_backup) << " Error:" << zip.getZipError();
|
||||
backup.corruptedBackup = true;
|
||||
_allBackupsLoadedSuccessfully = false;
|
||||
return;
|
||||
}
|
||||
|
||||
|
@ -194,7 +195,6 @@ void AssetsBackupHandler::loadBackup(const QString& backupName, QuaZip& zip) {
|
|||
qCCritical(asset_backup) << "Could not parse backup file to JSON object for load:" << backupName;
|
||||
qCCritical(asset_backup) << " Error:" << error.errorString();
|
||||
backup.corruptedBackup = true;
|
||||
_allBackupsLoadedSuccessfully = false;
|
||||
return;
|
||||
}
|
||||
|
||||
|
@ -206,7 +206,6 @@ void AssetsBackupHandler::loadBackup(const QString& backupName, QuaZip& zip) {
|
|||
if (!AssetUtils::isValidHash(assetHash)) {
|
||||
qCCritical(asset_backup) << "Corrupted mapping in loading backup file" << backupName << ":" << it.key();
|
||||
backup.corruptedBackup = true;
|
||||
_allBackupsLoadedSuccessfully = false;
|
||||
continue;
|
||||
}
|
||||
|
||||
|
@ -280,7 +279,7 @@ void AssetsBackupHandler::recoverBackup(const QString& backupName, QuaZip& zip)
|
|||
qCWarning(asset_backup) << "Current asset mappings that might be stale.";
|
||||
}
|
||||
|
||||
const auto it = find_if(begin(_backups), end(_backups), [&](const AssetServerBackup& backup) {
|
||||
auto it = find_if(begin(_backups), end(_backups), [&](const AssetServerBackup& backup) {
|
||||
return backup.name == backupName;
|
||||
});
|
||||
if (it == end(_backups)) {
|
||||
|
@ -307,6 +306,17 @@ void AssetsBackupHandler::recoverBackup(const QString& backupName, QuaZip& zip)
|
|||
writeAssetFile(asset, zipFile.readAll());
|
||||
}
|
||||
}
|
||||
|
||||
// iterator is end() and has been invalidated in the `loadBackup` call
|
||||
// grab the new iterator
|
||||
it = find_if(begin(_backups), end(_backups), [&](const AssetServerBackup& backup) {
|
||||
return backup.name == backupName;
|
||||
});
|
||||
|
||||
if (it == end(_backups)) {
|
||||
qCCritical(asset_backup) << "Failed to recover backup:" << backupName;
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
const auto& newMappings = it->mappings;
|
||||
|
|
|
@ -78,7 +78,6 @@ private:
|
|||
};
|
||||
|
||||
// Internal storage for backups on disk
|
||||
bool _allBackupsLoadedSuccessfully { false };
|
||||
std::vector<AssetServerBackup> _backups;
|
||||
std::set<AssetUtils::AssetHash> _assetsInBackups;
|
||||
std::set<AssetUtils::AssetHash> _assetsOnDisk;
|
||||
|
|
Loading…
Reference in a new issue