diff options
author | Justin Clark-Casey (justincc) | 2011-03-12 00:35:40 +0000 |
---|---|---|
committer | Justin Clark-Casey (justincc) | 2011-03-12 00:35:40 +0000 |
commit | c4060e56ef2aa2d4d68d33ae3081c6a0d2d37f7c (patch) | |
tree | da5a061f2ef146f695d48c9990208cb02930b818 | |
parent | refactor: make boolean load indicators on load iars instance fields (diff) | |
download | opensim-SC-c4060e56ef2aa2d4d68d33ae3081c6a0d2d37f7c.zip opensim-SC-c4060e56ef2aa2d4d68d33ae3081c6a0d2d37f7c.tar.gz opensim-SC-c4060e56ef2aa2d4d68d33ae3081c6a0d2d37f7c.tar.bz2 opensim-SC-c4060e56ef2aa2d4d68d33ae3081c6a0d2d37f7c.tar.xz |
factor out iar asset load code into its own method
-rw-r--r-- | OpenSim/Region/CoreModules/Avatar/Inventory/Archiver/InventoryArchiveReadRequest.cs | 69 |
1 files changed, 40 insertions, 29 deletions
diff --git a/OpenSim/Region/CoreModules/Avatar/Inventory/Archiver/InventoryArchiveReadRequest.cs b/OpenSim/Region/CoreModules/Avatar/Inventory/Archiver/InventoryArchiveReadRequest.cs index 367960c..cf4ba91 100644 --- a/OpenSim/Region/CoreModules/Avatar/Inventory/Archiver/InventoryArchiveReadRequest.cs +++ b/OpenSim/Region/CoreModules/Avatar/Inventory/Archiver/InventoryArchiveReadRequest.cs | |||
@@ -86,6 +86,9 @@ namespace OpenSim.Region.CoreModules.Avatar.Inventory.Archiver | |||
86 | protected bool m_controlFileLoaded; | 86 | protected bool m_controlFileLoaded; |
87 | protected bool m_assetsLoaded; | 87 | protected bool m_assetsLoaded; |
88 | protected bool m_inventoryNodesLoaded; | 88 | protected bool m_inventoryNodesLoaded; |
89 | |||
90 | protected int m_successfulAssetRestores; | ||
91 | protected int m_failedAssetRestores; | ||
89 | 92 | ||
90 | public InventoryArchiveReadRequest( | 93 | public InventoryArchiveReadRequest( |
91 | Scene scene, UserAccount userInfo, string invPath, string loadPath, bool merge) | 94 | Scene scene, UserAccount userInfo, string invPath, string loadPath, bool merge) |
@@ -121,8 +124,6 @@ namespace OpenSim.Region.CoreModules.Avatar.Inventory.Archiver | |||
121 | try | 124 | try |
122 | { | 125 | { |
123 | string filePath = "ERROR"; | 126 | string filePath = "ERROR"; |
124 | int successfulAssetRestores = 0; | ||
125 | int failedAssetRestores = 0; | ||
126 | int successfulItemRestores = 0; | 127 | int successfulItemRestores = 0; |
127 | 128 | ||
128 | HashSet<InventoryNodeBase> loadedNodes = new HashSet<InventoryNodeBase>(); | 129 | HashSet<InventoryNodeBase> loadedNodes = new HashSet<InventoryNodeBase>(); |
@@ -154,33 +155,10 @@ namespace OpenSim.Region.CoreModules.Avatar.Inventory.Archiver | |||
154 | if (filePath == ArchiveConstants.CONTROL_FILE_PATH) | 155 | if (filePath == ArchiveConstants.CONTROL_FILE_PATH) |
155 | { | 156 | { |
156 | LoadControlFile(filePath, data); | 157 | LoadControlFile(filePath, data); |
157 | m_controlFileLoaded = true; | 158 | } |
158 | } | ||
159 | else if (filePath.StartsWith(ArchiveConstants.ASSETS_PATH)) | 159 | else if (filePath.StartsWith(ArchiveConstants.ASSETS_PATH)) |
160 | { | 160 | { |
161 | if (!m_controlFileLoaded) | 161 | LoadAssetFile(filePath, data); |
162 | throw new Exception( | ||
163 | string.Format( | ||
164 | "The IAR you are trying to load does not list {0} before {1}. Aborting load", | ||
165 | ArchiveConstants.CONTROL_FILE_PATH, ArchiveConstants.ASSETS_PATH)); | ||
166 | |||
167 | if (!m_inventoryNodesLoaded) | ||
168 | throw new Exception( | ||
169 | string.Format( | ||
170 | "The IAR you are trying to load does not list all {0} before {1}. Aborting load", | ||
171 | ArchiveConstants.INVENTORY_PATH, ArchiveConstants.ASSETS_PATH)); | ||
172 | |||
173 | if (LoadAsset(filePath, data)) | ||
174 | successfulAssetRestores++; | ||
175 | else | ||
176 | failedAssetRestores++; | ||
177 | |||
178 | if ((successfulAssetRestores) % 50 == 0) | ||
179 | m_log.DebugFormat( | ||
180 | "[INVENTORY ARCHIVER]: Loaded {0} assets...", | ||
181 | successfulAssetRestores); | ||
182 | |||
183 | m_assetsLoaded = true; | ||
184 | } | 162 | } |
185 | else if (filePath.StartsWith(ArchiveConstants.INVENTORY_PATH)) | 163 | else if (filePath.StartsWith(ArchiveConstants.INVENTORY_PATH)) |
186 | { | 164 | { |
@@ -229,7 +207,7 @@ namespace OpenSim.Region.CoreModules.Avatar.Inventory.Archiver | |||
229 | 207 | ||
230 | m_log.DebugFormat( | 208 | m_log.DebugFormat( |
231 | "[INVENTORY ARCHIVER]: Successfully loaded {0} assets with {1} failures", | 209 | "[INVENTORY ARCHIVER]: Successfully loaded {0} assets with {1} failures", |
232 | successfulAssetRestores, failedAssetRestores); | 210 | m_successfulAssetRestores, m_failedAssetRestores); |
233 | m_log.InfoFormat("[INVENTORY ARCHIVER]: Successfully loaded {0} items", successfulItemRestores); | 211 | m_log.InfoFormat("[INVENTORY ARCHIVER]: Successfully loaded {0} items", successfulItemRestores); |
234 | 212 | ||
235 | return loadedNodes; | 213 | return loadedNodes; |
@@ -566,7 +544,40 @@ namespace OpenSim.Region.CoreModules.Avatar.Inventory.Archiver | |||
566 | majorVersion, MAX_MAJOR_VERSION)); | 544 | majorVersion, MAX_MAJOR_VERSION)); |
567 | } | 545 | } |
568 | 546 | ||
569 | m_log.InfoFormat("[INVENTORY ARCHIVER]: Loading IAR with version {0}", version); | 547 | m_controlFileLoaded = true; |
548 | m_log.InfoFormat("[INVENTORY ARCHIVER]: Loading IAR with version {0}", version); | ||
570 | } | 549 | } |
550 | |||
551 | /// <summary> | ||
552 | /// Load asset file | ||
553 | /// </summary> | ||
554 | /// <param name="path"></param> | ||
555 | /// <param name="data"></param> | ||
556 | protected void LoadAssetFile(string path, byte[] data) | ||
557 | { | ||
558 | if (!m_controlFileLoaded) | ||
559 | throw new Exception( | ||
560 | string.Format( | ||
561 | "The IAR you are trying to load does not list {0} before {1}. Aborting load", | ||
562 | ArchiveConstants.CONTROL_FILE_PATH, ArchiveConstants.ASSETS_PATH)); | ||
563 | |||
564 | if (!m_inventoryNodesLoaded) | ||
565 | throw new Exception( | ||
566 | string.Format( | ||
567 | "The IAR you are trying to load does not list all {0} before {1}. Aborting load", | ||
568 | ArchiveConstants.INVENTORY_PATH, ArchiveConstants.ASSETS_PATH)); | ||
569 | |||
570 | if (LoadAsset(path, data)) | ||
571 | m_successfulAssetRestores++; | ||
572 | else | ||
573 | m_failedAssetRestores++; | ||
574 | |||
575 | if ((m_successfulAssetRestores) % 50 == 0) | ||
576 | m_log.DebugFormat( | ||
577 | "[INVENTORY ARCHIVER]: Loaded {0} assets...", | ||
578 | m_successfulAssetRestores); | ||
579 | |||
580 | m_assetsLoaded = true; | ||
581 | } | ||
571 | } | 582 | } |
572 | } \ No newline at end of file | 583 | } \ No newline at end of file |