mirror of
https://github.com/HifiExperiments/overte.git
synced 2025-07-23 04:28:12 +02:00
add delete debug, handle rename in memory state rollback
This commit is contained in:
parent
5e9751c6ed
commit
d3dc81c7a0
1 changed files with 17 additions and 4 deletions
|
@ -561,6 +561,8 @@ bool AssetServer::deleteMappings(const AssetPathList& paths) {
|
||||||
// persistence succeeded we are good to go
|
// persistence succeeded we are good to go
|
||||||
return true;
|
return true;
|
||||||
} else {
|
} else {
|
||||||
|
qWarning() << "Failed to persist deleted mappings, rolling back";
|
||||||
|
|
||||||
// we didn't delete the previous mapping, put it back in our in-memory representation
|
// we didn't delete the previous mapping, put it back in our in-memory representation
|
||||||
_fileMappings = oldMappings;
|
_fileMappings = oldMappings;
|
||||||
|
|
||||||
|
@ -619,10 +621,13 @@ bool AssetServer::renameMapping(const AssetPath& oldPath, const AssetPath& newPa
|
||||||
}
|
}
|
||||||
|
|
||||||
// take the old hash to remove the old mapping
|
// take the old hash to remove the old mapping
|
||||||
auto oldMapping = _fileMappings.take(oldPath).toString();
|
auto oldSourceMapping = _fileMappings.take(oldPath).toString();
|
||||||
|
|
||||||
if (!oldMapping.isEmpty()) {
|
// in case we're overwriting, keep the current destination mapping for potential rollback
|
||||||
_fileMappings[newPath] = oldMapping;
|
auto oldDestinationMapping = _fileMappings.value(newPath);
|
||||||
|
|
||||||
|
if (!oldSourceMapping.isEmpty()) {
|
||||||
|
_fileMappings[newPath] = oldSourceMapping;
|
||||||
|
|
||||||
if (writeMappingsToFile()) {
|
if (writeMappingsToFile()) {
|
||||||
// persisted the renamed mapping, return success
|
// persisted the renamed mapping, return success
|
||||||
|
@ -631,7 +636,15 @@ bool AssetServer::renameMapping(const AssetPath& oldPath, const AssetPath& newPa
|
||||||
return true;
|
return true;
|
||||||
} else {
|
} else {
|
||||||
// we couldn't persist the renamed mapping, rollback and return failure
|
// we couldn't persist the renamed mapping, rollback and return failure
|
||||||
_fileMappings[oldPath] = oldMapping;
|
_fileMappings[oldPath] = oldSourceMapping;
|
||||||
|
|
||||||
|
if (!oldDestinationMapping.isNull()) {
|
||||||
|
// put back the overwritten mapping for the destination path
|
||||||
|
_fileMappings[newPath] = oldDestinationMapping.toString();
|
||||||
|
} else {
|
||||||
|
// clear the new mapping
|
||||||
|
_fileMappings.remove(newPath);
|
||||||
|
}
|
||||||
|
|
||||||
qDebug() << "Failed to persist renamed mapping:" << oldPath << "=>" << newPath;
|
qDebug() << "Failed to persist renamed mapping:" << oldPath << "=>" << newPath;
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue