aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/OpenSim/Region/CoreModules/Avatar/Inventory/Archiver/InventoryArchiveWriteRequest.cs
diff options
context:
space:
mode:
authorJustin Clark-Casey (justincc)2009-11-24 18:27:31 +0000
committerJustin Clark-Casey (justincc)2009-11-24 18:27:31 +0000
commitf605d59136ef5a6ada9f332fb775f58adc1ec36a (patch)
tree108e59945dc00128fa468bba1a5fe752b9f77dbc /OpenSim/Region/CoreModules/Avatar/Inventory/Archiver/InventoryArchiveWriteRequest.cs
parentmake save and load oar slightly more robust by always closing the archive str... (diff)
downloadopensim-SC_OLD-f605d59136ef5a6ada9f332fb775f58adc1ec36a.zip
opensim-SC_OLD-f605d59136ef5a6ada9f332fb775f58adc1ec36a.tar.gz
opensim-SC_OLD-f605d59136ef5a6ada9f332fb775f58adc1ec36a.tar.bz2
opensim-SC_OLD-f605d59136ef5a6ada9f332fb775f58adc1ec36a.tar.xz
Make load/save iar slightly better in the face of io failures by always attempting to close the streams
Diffstat (limited to '')
-rw-r--r--OpenSim/Region/CoreModules/Avatar/Inventory/Archiver/InventoryArchiveWriteRequest.cs72
1 files changed, 40 insertions, 32 deletions
diff --git a/OpenSim/Region/CoreModules/Avatar/Inventory/Archiver/InventoryArchiveWriteRequest.cs b/OpenSim/Region/CoreModules/Avatar/Inventory/Archiver/InventoryArchiveWriteRequest.cs
index 6e11f36..c85d974 100644
--- a/OpenSim/Region/CoreModules/Avatar/Inventory/Archiver/InventoryArchiveWriteRequest.cs
+++ b/OpenSim/Region/CoreModules/Avatar/Inventory/Archiver/InventoryArchiveWriteRequest.cs
@@ -117,19 +117,19 @@ namespace OpenSim.Region.CoreModules.Avatar.Inventory.Archiver
117 } 117 }
118 118
119 protected void ReceivedAllAssets(ICollection<UUID> assetsFoundUuids, ICollection<UUID> assetsNotFoundUuids) 119 protected void ReceivedAllAssets(ICollection<UUID> assetsFoundUuids, ICollection<UUID> assetsNotFoundUuids)
120 { 120 {
121 // We're almost done. Just need to write out the control file now
122 m_archiveWriter.WriteFile(ArchiveConstants.CONTROL_FILE_PATH, Create0p1ControlFile());
123 m_log.InfoFormat("[ARCHIVER]: Added control file to archive.");
124
125 Exception reportedException = null; 121 Exception reportedException = null;
126 bool succeeded = true; 122 bool succeeded = true;
127 123
128 try 124 try
129 { 125 {
126 // We're almost done. Just need to write out the control file now
127 m_archiveWriter.WriteFile(ArchiveConstants.CONTROL_FILE_PATH, Create0p1ControlFile());
128 m_log.InfoFormat("[ARCHIVER]: Added control file to archive.");
129
130 m_archiveWriter.Close(); 130 m_archiveWriter.Close();
131 } 131 }
132 catch (IOException e) 132 catch (Exception e)
133 { 133 {
134 m_saveStream.Close(); 134 m_saveStream.Close();
135 reportedException = e; 135 reportedException = e;
@@ -261,39 +261,47 @@ namespace OpenSim.Region.CoreModules.Avatar.Inventory.Archiver
261 //inventoryItem = m_userInfo.RootFolder.FindItemByPath(m_invPath); 261 //inventoryItem = m_userInfo.RootFolder.FindItemByPath(m_invPath);
262 } 262 }
263 263
264 m_archiveWriter = new TarArchiveWriter(m_saveStream); 264 if (null == inventoryFolder && null == inventoryItem)
265
266 if (inventoryFolder != null)
267 {
268 m_log.DebugFormat(
269 "[INVENTORY ARCHIVER]: Found folder {0} {1} at {2}",
270 inventoryFolder.Name, inventoryFolder.ID, m_invPath);
271
272 //recurse through all dirs getting dirs and files
273 SaveInvFolder(inventoryFolder, ArchiveConstants.INVENTORY_PATH, !foundStar);
274 }
275 else if (inventoryItem != null)
276 {
277 m_log.DebugFormat(
278 "[INVENTORY ARCHIVER]: Found item {0} {1} at {2}",
279 inventoryItem.Name, inventoryItem.ID, m_invPath);
280
281 SaveInvItem(inventoryItem, ArchiveConstants.INVENTORY_PATH);
282 }
283 else
284 { 265 {
285 // We couldn't find the path indicated 266 // We couldn't find the path indicated
286 m_saveStream.Close();
287 string errorMessage = string.Format("Aborted save. Could not find inventory path {0}", m_invPath); 267 string errorMessage = string.Format("Aborted save. Could not find inventory path {0}", m_invPath);
288 m_log.ErrorFormat("[INVENTORY ARCHIVER]: {0}", errorMessage); 268 m_log.ErrorFormat("[INVENTORY ARCHIVER]: {0}", errorMessage);
289 m_module.TriggerInventoryArchiveSaved( 269 m_module.TriggerInventoryArchiveSaved(
290 m_id, false, m_userInfo, m_invPath, m_saveStream, 270 m_id, false, m_userInfo, m_invPath, m_saveStream,
291 new Exception(errorMessage)); 271 new Exception(errorMessage));
292 return; 272 return;
293 } 273 }
274
275 m_archiveWriter = new TarArchiveWriter(m_saveStream);
294 276
295 // Don't put all this profile information into the archive right now. 277 try
296 //SaveUsers(); 278 {
279 if (inventoryFolder != null)
280 {
281 m_log.DebugFormat(
282 "[INVENTORY ARCHIVER]: Found folder {0} {1} at {2}",
283 inventoryFolder.Name, inventoryFolder.ID, m_invPath);
284
285 //recurse through all dirs getting dirs and files
286 SaveInvFolder(inventoryFolder, ArchiveConstants.INVENTORY_PATH, !foundStar);
287 }
288 else if (inventoryItem != null)
289 {
290 m_log.DebugFormat(
291 "[INVENTORY ARCHIVER]: Found item {0} {1} at {2}",
292 inventoryItem.Name, inventoryItem.ID, m_invPath);
293
294 SaveInvItem(inventoryItem, ArchiveConstants.INVENTORY_PATH);
295 }
296
297 // Don't put all this profile information into the archive right now.
298 //SaveUsers();
299 }
300 catch (Exception)
301 {
302 m_archiveWriter.Close();
303 throw;
304 }
297 305
298 new AssetsRequest( 306 new AssetsRequest(
299 new AssetsArchiver(m_archiveWriter), m_assetUuids.Keys, 307 new AssetsArchiver(m_archiveWriter), m_assetUuids.Keys,