diff options
author | Justin Clarke Casey | 2009-02-25 18:07:32 +0000 |
---|---|---|
committer | Justin Clarke Casey | 2009-02-25 18:07:32 +0000 |
commit | 17a336f21fe44a88fb18850f660926a9f2fe3e9a (patch) | |
tree | 995df58218c751f278406d3015559f78b66ddb11 /OpenSim/Region/CoreModules/Avatar/Inventory/Archiver/InventoryArchiveReadRequest.cs | |
parent | * Store inventory data in an 'inventory' directory rather than in the root of... (diff) | |
download | opensim-SC_OLD-17a336f21fe44a88fb18850f660926a9f2fe3e9a.zip opensim-SC_OLD-17a336f21fe44a88fb18850f660926a9f2fe3e9a.tar.gz opensim-SC_OLD-17a336f21fe44a88fb18850f660926a9f2fe3e9a.tar.bz2 opensim-SC_OLD-17a336f21fe44a88fb18850f660926a9f2fe3e9a.tar.xz |
* Add InventoryArchiveConstants that I missed from last commit
* This commit also does a first pass at creating folders for an inventory archive (previously everything was dumped in the same destiantion folder).
* This code might not work yet and nobody else should be using it yet anyway :)
Diffstat (limited to 'OpenSim/Region/CoreModules/Avatar/Inventory/Archiver/InventoryArchiveReadRequest.cs')
-rw-r--r-- | OpenSim/Region/CoreModules/Avatar/Inventory/Archiver/InventoryArchiveReadRequest.cs | 35 |
1 files changed, 29 insertions, 6 deletions
diff --git a/OpenSim/Region/CoreModules/Avatar/Inventory/Archiver/InventoryArchiveReadRequest.cs b/OpenSim/Region/CoreModules/Avatar/Inventory/Archiver/InventoryArchiveReadRequest.cs index d2b59ae..2090558 100644 --- a/OpenSim/Region/CoreModules/Avatar/Inventory/Archiver/InventoryArchiveReadRequest.cs +++ b/OpenSim/Region/CoreModules/Avatar/Inventory/Archiver/InventoryArchiveReadRequest.cs | |||
@@ -77,7 +77,7 @@ namespace OpenSim.Region.CoreModules.Avatar.Inventory.Archiver | |||
77 | this.commsManager = commsManager; | 77 | this.commsManager = commsManager; |
78 | } | 78 | } |
79 | 79 | ||
80 | protected InventoryItemBase LoadInvItem(string path, string contents) | 80 | protected InventoryItemBase LoadInvItem(string contents) |
81 | { | 81 | { |
82 | InventoryItemBase item = new InventoryItemBase(); | 82 | InventoryItemBase item = new InventoryItemBase(); |
83 | StringReader sr = new StringReader(contents); | 83 | StringReader sr = new StringReader(contents); |
@@ -183,9 +183,9 @@ namespace OpenSim.Region.CoreModules.Avatar.Inventory.Archiver | |||
183 | } | 183 | } |
184 | } | 184 | } |
185 | 185 | ||
186 | InventoryFolderImpl inventoryFolder = m_userInfo.RootFolder.FindFolderByPath(m_invPath); | 186 | InventoryFolderImpl rootDestinationFolder = m_userInfo.RootFolder.FindFolderByPath(m_invPath); |
187 | 187 | ||
188 | if (null == inventoryFolder) | 188 | if (null == rootDestinationFolder) |
189 | { | 189 | { |
190 | // TODO: Later on, automatically create this folder if it does not exist | 190 | // TODO: Later on, automatically create this folder if it does not exist |
191 | m_log.ErrorFormat("[INVENTORY ARCHIVER]: Inventory path {0} does not exist", m_invPath); | 191 | m_log.ErrorFormat("[INVENTORY ARCHIVER]: Inventory path {0} does not exist", m_invPath); |
@@ -199,7 +199,8 @@ namespace OpenSim.Region.CoreModules.Avatar.Inventory.Archiver | |||
199 | TarArchiveReader.TarEntryType entryType; | 199 | TarArchiveReader.TarEntryType entryType; |
200 | while ((data = archive.ReadEntry(out filePath, out entryType)) != null) | 200 | while ((data = archive.ReadEntry(out filePath, out entryType)) != null) |
201 | { | 201 | { |
202 | if (entryType == TarArchiveReader.TarEntryType.TYPE_DIRECTORY) { | 202 | if (entryType == TarArchiveReader.TarEntryType.TYPE_DIRECTORY) |
203 | { | ||
203 | m_log.WarnFormat("[INVENTORY ARCHIVER]: Ignoring directory entry {0}", filePath); | 204 | m_log.WarnFormat("[INVENTORY ARCHIVER]: Ignoring directory entry {0}", filePath); |
204 | } | 205 | } |
205 | else if (filePath.StartsWith(InventoryArchiveConstants.ASSETS_PATH)) | 206 | else if (filePath.StartsWith(InventoryArchiveConstants.ASSETS_PATH)) |
@@ -211,7 +212,7 @@ namespace OpenSim.Region.CoreModules.Avatar.Inventory.Archiver | |||
211 | } | 212 | } |
212 | else if (filePath.StartsWith(InventoryArchiveConstants.INVENTORY_PATH)) | 213 | else if (filePath.StartsWith(InventoryArchiveConstants.INVENTORY_PATH)) |
213 | { | 214 | { |
214 | InventoryItemBase item = LoadInvItem(filePath, m_asciiEncoding.GetString(data)); | 215 | InventoryItemBase item = LoadInvItem(m_asciiEncoding.GetString(data)); |
215 | 216 | ||
216 | if (item != null) | 217 | if (item != null) |
217 | { | 218 | { |
@@ -220,11 +221,33 @@ namespace OpenSim.Region.CoreModules.Avatar.Inventory.Archiver | |||
220 | 221 | ||
221 | item.Creator = m_userInfo.UserProfile.ID; | 222 | item.Creator = m_userInfo.UserProfile.ID; |
222 | item.Owner = m_userInfo.UserProfile.ID; | 223 | item.Owner = m_userInfo.UserProfile.ID; |
224 | |||
225 | filePath = filePath.Substring(InventoryArchiveConstants.INVENTORY_PATH.Length); | ||
226 | string[] rawFolders = filePath.Split(new char[] { '/' }); | ||
227 | |||
228 | // Find the folders that do exist along the path given | ||
229 | int i = 0; | ||
230 | bool noFolder = false; | ||
231 | InventoryFolderImpl foundFolder = rootDestinationFolder; | ||
232 | while (!noFolder && i < rawFolders.Length) | ||
233 | { | ||
234 | foundFolder = foundFolder.FindFolderByPath(rawFolders[i]); | ||
235 | if (null == foundFolder) | ||
236 | noFolder = true; | ||
237 | else | ||
238 | i++; | ||
239 | } | ||
240 | |||
241 | // Create any folders that did not previously exist | ||
242 | while (i < rawFolders.Length) | ||
243 | { | ||
244 | foundFolder.CreateChildFolder(UUID.Random(), rawFolders[i++], (ushort)AssetType.Folder); | ||
245 | } | ||
223 | 246 | ||
224 | // Reset folder ID to the one in which we want to load it | 247 | // Reset folder ID to the one in which we want to load it |
225 | // TODO: Properly restore entire folder structure. At the moment all items are dumped in this | 248 | // TODO: Properly restore entire folder structure. At the moment all items are dumped in this |
226 | // single folder no matter where in the saved folder structure they are. | 249 | // single folder no matter where in the saved folder structure they are. |
227 | item.Folder = inventoryFolder.ID; | 250 | item.Folder = foundFolder.ID; |
228 | 251 | ||
229 | m_userInfo.AddItem(item); | 252 | m_userInfo.AddItem(item); |
230 | successfulItemRestores++; | 253 | successfulItemRestores++; |