diff options
author | Justin Clark-Casey (justincc) | 2009-11-24 18:27:31 +0000 |
---|---|---|
committer | Justin Clark-Casey (justincc) | 2009-11-24 18:27:31 +0000 |
commit | f605d59136ef5a6ada9f332fb775f58adc1ec36a (patch) | |
tree | 108e59945dc00128fa468bba1a5fe752b9f77dbc /OpenSim/Region/CoreModules/Avatar/Inventory/Archiver/InventoryArchiveReadRequest.cs | |
parent | make save and load oar slightly more robust by always closing the archive str... (diff) | |
download | opensim-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/InventoryArchiveReadRequest.cs | 68 |
1 files changed, 37 insertions, 31 deletions
diff --git a/OpenSim/Region/CoreModules/Avatar/Inventory/Archiver/InventoryArchiveReadRequest.cs b/OpenSim/Region/CoreModules/Avatar/Inventory/Archiver/InventoryArchiveReadRequest.cs index 9e76d79..8532d03 100644 --- a/OpenSim/Region/CoreModules/Avatar/Inventory/Archiver/InventoryArchiveReadRequest.cs +++ b/OpenSim/Region/CoreModules/Avatar/Inventory/Archiver/InventoryArchiveReadRequest.cs | |||
@@ -121,45 +121,51 @@ namespace OpenSim.Region.CoreModules.Avatar.Inventory.Archiver | |||
121 | 121 | ||
122 | byte[] data; | 122 | byte[] data; |
123 | TarArchiveReader.TarEntryType entryType; | 123 | TarArchiveReader.TarEntryType entryType; |
124 | while ((data = archive.ReadEntry(out filePath, out entryType)) != null) | ||
125 | { | ||
126 | if (filePath.StartsWith(ArchiveConstants.ASSETS_PATH)) | ||
127 | { | ||
128 | if (LoadAsset(filePath, data)) | ||
129 | successfulAssetRestores++; | ||
130 | else | ||
131 | failedAssetRestores++; | ||
132 | 124 | ||
133 | if ((successfulAssetRestores) % 50 == 0) | 125 | try |
134 | m_log.DebugFormat( | 126 | { |
135 | "[INVENTORY ARCHIVER]: Loaded {0} assets...", | 127 | while ((data = archive.ReadEntry(out filePath, out entryType)) != null) |
136 | successfulAssetRestores); | ||
137 | } | ||
138 | else if (filePath.StartsWith(ArchiveConstants.INVENTORY_PATH)) | ||
139 | { | 128 | { |
140 | InventoryFolderBase foundFolder | 129 | if (filePath.StartsWith(ArchiveConstants.ASSETS_PATH)) |
141 | = ReplicateArchivePathToUserInventory( | ||
142 | filePath, TarArchiveReader.TarEntryType.TYPE_DIRECTORY == entryType, | ||
143 | rootDestinationFolder, foldersCreated, nodesLoaded); | ||
144 | |||
145 | if (TarArchiveReader.TarEntryType.TYPE_DIRECTORY != entryType) | ||
146 | { | 130 | { |
147 | InventoryItemBase item = LoadItem(data, foundFolder); | 131 | if (LoadAsset(filePath, data)) |
148 | 132 | successfulAssetRestores++; | |
149 | if (item != null) | 133 | else |
134 | failedAssetRestores++; | ||
135 | |||
136 | if ((successfulAssetRestores) % 50 == 0) | ||
137 | m_log.DebugFormat( | ||
138 | "[INVENTORY ARCHIVER]: Loaded {0} assets...", | ||
139 | successfulAssetRestores); | ||
140 | } | ||
141 | else if (filePath.StartsWith(ArchiveConstants.INVENTORY_PATH)) | ||
142 | { | ||
143 | InventoryFolderBase foundFolder | ||
144 | = ReplicateArchivePathToUserInventory( | ||
145 | filePath, TarArchiveReader.TarEntryType.TYPE_DIRECTORY == entryType, | ||
146 | rootDestinationFolder, foldersCreated, nodesLoaded); | ||
147 | |||
148 | if (TarArchiveReader.TarEntryType.TYPE_DIRECTORY != entryType) | ||
150 | { | 149 | { |
151 | successfulItemRestores++; | 150 | InventoryItemBase item = LoadItem(data, foundFolder); |
152 | 151 | ||
153 | // If we're loading an item directly into the given destination folder then we need to record | 152 | if (item != null) |
154 | // it separately from any loaded root folders | 153 | { |
155 | if (rootDestinationFolder == foundFolder) | 154 | successfulItemRestores++; |
156 | nodesLoaded.Add(item); | 155 | |
156 | // If we're loading an item directly into the given destination folder then we need to record | ||
157 | // it separately from any loaded root folders | ||
158 | if (rootDestinationFolder == foundFolder) | ||
159 | nodesLoaded.Add(item); | ||
160 | } | ||
157 | } | 161 | } |
158 | } | 162 | } |
159 | } | 163 | } |
160 | } | 164 | } |
161 | 165 | finally | |
162 | archive.Close(); | 166 | { |
167 | archive.Close(); | ||
168 | } | ||
163 | 169 | ||
164 | m_log.DebugFormat( | 170 | m_log.DebugFormat( |
165 | "[INVENTORY ARCHIVER]: Successfully loaded {0} assets with {1} failures", | 171 | "[INVENTORY ARCHIVER]: Successfully loaded {0} assets with {1} failures", |