From 65c88b2ff4e2616fa5c1d4c5e75298ed1eb1c0d8 Mon Sep 17 00:00:00 2001 From: Oren Hurvitz Date: Sun, 29 Apr 2012 08:53:33 +0300 Subject: Better error handling if Load OAR or Save OAR fail --- .../CoreModules/World/Archiver/ArchiveReadRequest.cs | 20 ++++++++++++++++---- .../World/Archiver/ArchiveWriteRequestExecution.cs | 7 ++++++- .../World/Archiver/ArchiveWriteRequestPreparation.cs | 11 ++++++++++- 3 files changed, 32 insertions(+), 6 deletions(-) diff --git a/OpenSim/Region/CoreModules/World/Archiver/ArchiveReadRequest.cs b/OpenSim/Region/CoreModules/World/Archiver/ArchiveReadRequest.cs index a6dbaba..e360f93 100644 --- a/OpenSim/Region/CoreModules/World/Archiver/ArchiveReadRequest.cs +++ b/OpenSim/Region/CoreModules/World/Archiver/ArchiveReadRequest.cs @@ -200,8 +200,8 @@ namespace OpenSim.Region.CoreModules.World.Archiver } catch (Exception e) { - m_log.ErrorFormat( - "[ARCHIVER]: Aborting load with error in archive file {0}. {1}", filePath, e); + m_log.Error( + String.Format("[ARCHIVER]: Aborting load with error in archive file {0} ", filePath), e); m_errorMessage += e.ToString(); m_scene.EventManager.TriggerOarFileLoaded(m_requestId, m_errorMessage); return; @@ -219,6 +219,7 @@ namespace OpenSim.Region.CoreModules.World.Archiver { m_log.ErrorFormat("[ARCHIVER]: Failed to load {0} assets", failedAssetRestores); m_errorMessage += String.Format("Failed to load {0} assets", failedAssetRestores); + // Continue, because we allow the OAR to be loaded even if some assets fail } } @@ -228,8 +229,19 @@ namespace OpenSim.Region.CoreModules.World.Archiver m_scene.DeleteAllSceneObjects(); } - LoadParcels(serialisedParcels); - LoadObjects(serialisedSceneObjects); + try + { + LoadParcels(serialisedParcels); + LoadObjects(serialisedSceneObjects); + } + catch (Exception e) + { + m_log.Error("[ARCHIVER]: Error loading parcels or objects ", e); + m_errorMessage += e.ToString(); + m_scene.EventManager.TriggerOarFileLoaded(m_requestId, m_errorMessage); + return; + } + m_log.InfoFormat("[ARCHIVER]: Successfully loaded archive"); diff --git a/OpenSim/Region/CoreModules/World/Archiver/ArchiveWriteRequestExecution.cs b/OpenSim/Region/CoreModules/World/Archiver/ArchiveWriteRequestExecution.cs index c179a34..2b40a9e 100644 --- a/OpenSim/Region/CoreModules/World/Archiver/ArchiveWriteRequestExecution.cs +++ b/OpenSim/Region/CoreModules/World/Archiver/ArchiveWriteRequestExecution.cs @@ -87,6 +87,11 @@ namespace OpenSim.Region.CoreModules.World.Archiver { Save(assetsFoundUuids, assetsNotFoundUuids); } + catch (Exception e) + { + m_scene.EventManager.TriggerOarFileSaved(m_requestId, e.ToString()); + throw; + } finally { m_archiveWriter.Close(); @@ -150,4 +155,4 @@ namespace OpenSim.Region.CoreModules.World.Archiver } } } -} \ No newline at end of file +} diff --git a/OpenSim/Region/CoreModules/World/Archiver/ArchiveWriteRequestPreparation.cs b/OpenSim/Region/CoreModules/World/Archiver/ArchiveWriteRequestPreparation.cs index eabe46e..384d81b 100644 --- a/OpenSim/Region/CoreModules/World/Archiver/ArchiveWriteRequestPreparation.cs +++ b/OpenSim/Region/CoreModules/World/Archiver/ArchiveWriteRequestPreparation.cs @@ -124,6 +124,9 @@ namespace OpenSim.Region.CoreModules.World.Archiver if (options.ContainsKey("noassets") && (bool)options["noassets"]) SaveAssets = false; + // Whether someone else (i.e., ReceivedAllAssets()) is responsible for calling TriggerOarFileSaved() when we're done + bool eventHandled = false; + try { Dictionary assetUuids = new Dictionary(); @@ -230,15 +233,21 @@ namespace OpenSim.Region.CoreModules.World.Archiver m_scene.RegionInfo.ScopeID, options, awre.ReceivedAllAssets); Util.FireAndForget(o => ar.Execute()); + eventHandled = true; } else { awre.ReceivedAllAssets(new List(), new List()); + eventHandled = true; } } - catch (Exception) + catch (Exception e) { m_saveStream.Close(); + + if (!eventHandled) + m_scene.EventManager.TriggerOarFileSaved(m_requestId, e.ToString()); + throw; } } -- cgit v1.1