diff options
Diffstat (limited to '')
-rw-r--r-- | OpenSim/Framework/Archive/ArchiveConstants.cs (renamed from OpenSim/Region/CoreModules/World/Archiver/ArchiveConstants.cs) | 14 | ||||
-rw-r--r-- | OpenSim/Grid/AssetInventoryServer/Plugins/InventoryArchivePlugin.cs | 5 | ||||
-rw-r--r-- | OpenSim/Region/CoreModules/Avatar/Inventory/Archiver/InventoryArchiveConstants.cs | 113 | ||||
-rw-r--r-- | OpenSim/Region/CoreModules/Avatar/Inventory/Archiver/InventoryArchiveReadRequest.cs | 92 | ||||
-rw-r--r-- | OpenSim/Region/CoreModules/Avatar/Inventory/Archiver/InventoryArchiveWriteRequest.cs | 94 | ||||
-rw-r--r-- | OpenSim/Region/CoreModules/Avatar/Inventory/Archiver/Tests/InventoryArchiverTests.cs | 76 | ||||
-rw-r--r-- | OpenSim/Region/CoreModules/World/Archiver/AssetsDearchiver.cs | 1 |
7 files changed, 146 insertions, 249 deletions
diff --git a/OpenSim/Region/CoreModules/World/Archiver/ArchiveConstants.cs b/OpenSim/Framework/Archive/ArchiveConstants.cs index f5f1fdb..f830e98 100644 --- a/OpenSim/Region/CoreModules/World/Archiver/ArchiveConstants.cs +++ b/OpenSim/Framework/Archive/ArchiveConstants.cs | |||
@@ -28,7 +28,7 @@ | |||
28 | using System.Collections.Generic; | 28 | using System.Collections.Generic; |
29 | using OpenMetaverse; | 29 | using OpenMetaverse; |
30 | 30 | ||
31 | namespace OpenSim.Region.CoreModules.World.Archiver | 31 | namespace OpenSim.Framework.Archive |
32 | { | 32 | { |
33 | /// <summary> | 33 | /// <summary> |
34 | /// Constants for the archiving module | 34 | /// Constants for the archiving module |
@@ -46,6 +46,11 @@ namespace OpenSim.Region.CoreModules.World.Archiver | |||
46 | public static readonly string ASSETS_PATH = "assets/"; | 46 | public static readonly string ASSETS_PATH = "assets/"; |
47 | 47 | ||
48 | /// <summary> | 48 | /// <summary> |
49 | /// Path for the inventory data | ||
50 | /// </summary> | ||
51 | public static readonly string INVENTORY_PATH = "inventory/"; | ||
52 | |||
53 | /// <summary> | ||
49 | /// Path for the prims file | 54 | /// Path for the prims file |
50 | /// </summary> | 55 | /// </summary> |
51 | public static readonly string OBJECTS_PATH = "objects/"; | 56 | public static readonly string OBJECTS_PATH = "objects/"; |
@@ -54,7 +59,7 @@ namespace OpenSim.Region.CoreModules.World.Archiver | |||
54 | /// Path for terrains. Technically these may be assets, but I think it's quite nice to split them out. | 59 | /// Path for terrains. Technically these may be assets, but I think it's quite nice to split them out. |
55 | /// </summary> | 60 | /// </summary> |
56 | public static readonly string TERRAINS_PATH = "terrains/"; | 61 | public static readonly string TERRAINS_PATH = "terrains/"; |
57 | 62 | ||
58 | /// <summary> | 63 | /// <summary> |
59 | /// Path for region settings. | 64 | /// Path for region settings. |
60 | /// </summary> | 65 | /// </summary> |
@@ -66,6 +71,11 @@ namespace OpenSim.Region.CoreModules.World.Archiver | |||
66 | public static readonly string ASSET_EXTENSION_SEPARATOR = "_"; | 71 | public static readonly string ASSET_EXTENSION_SEPARATOR = "_"; |
67 | 72 | ||
68 | /// <summary> | 73 | /// <summary> |
74 | /// Used to separate components in an inventory node name | ||
75 | /// </summary> | ||
76 | public static readonly string INVENTORY_NODE_NAME_COMPONENT_SEPARATOR = "__"; | ||
77 | |||
78 | /// <summary> | ||
69 | /// Extensions used for asset types in the archive | 79 | /// Extensions used for asset types in the archive |
70 | /// </summary> | 80 | /// </summary> |
71 | public static readonly IDictionary<sbyte, string> ASSET_TYPE_TO_EXTENSION = new Dictionary<sbyte, string>(); | 81 | public static readonly IDictionary<sbyte, string> ASSET_TYPE_TO_EXTENSION = new Dictionary<sbyte, string>(); |
diff --git a/OpenSim/Grid/AssetInventoryServer/Plugins/InventoryArchivePlugin.cs b/OpenSim/Grid/AssetInventoryServer/Plugins/InventoryArchivePlugin.cs index ceded03..cd02a64 100644 --- a/OpenSim/Grid/AssetInventoryServer/Plugins/InventoryArchivePlugin.cs +++ b/OpenSim/Grid/AssetInventoryServer/Plugins/InventoryArchivePlugin.cs | |||
@@ -35,7 +35,6 @@ using OpenMetaverse; | |||
35 | using OpenSim.Framework; | 35 | using OpenSim.Framework; |
36 | using OpenSim.Framework.Archive; | 36 | using OpenSim.Framework.Archive; |
37 | using OpenSim.Framework.Servers; | 37 | using OpenSim.Framework.Servers; |
38 | using OpenSim.Region.CoreModules.Avatar.Inventory.Archiver; | ||
39 | using log4net; | 38 | using log4net; |
40 | 39 | ||
41 | namespace OpenSim.Grid.AssetInventoryServer.Plugins | 40 | namespace OpenSim.Grid.AssetInventoryServer.Plugins |
@@ -146,7 +145,7 @@ namespace OpenSim.Grid.AssetInventoryServer.Plugins | |||
146 | MemoryStream ms = new MemoryStream(); | 145 | MemoryStream ms = new MemoryStream(); |
147 | GZipStream gzs = new GZipStream(ms, CompressionMode.Compress, true); | 146 | GZipStream gzs = new GZipStream(ms, CompressionMode.Compress, true); |
148 | TarArchiveWriter archive = new TarArchiveWriter(gzs); | 147 | TarArchiveWriter archive = new TarArchiveWriter(gzs); |
149 | WriteInventoryFolderToArchive(archive, rootFolder, InventoryArchiveConstants.INVENTORY_PATH); | 148 | WriteInventoryFolderToArchive(archive, rootFolder, ArchiveConstants.INVENTORY_PATH); |
150 | 149 | ||
151 | archive.Close(); | 150 | archive.Close(); |
152 | 151 | ||
@@ -181,7 +180,7 @@ namespace OpenSim.Grid.AssetInventoryServer.Plugins | |||
181 | 180 | ||
182 | private static void WriteInventoryFolderToArchive(TarArchiveWriter archive, InventoryFolderWithChildren folder, string path) | 181 | private static void WriteInventoryFolderToArchive(TarArchiveWriter archive, InventoryFolderWithChildren folder, string path) |
183 | { | 182 | { |
184 | path += string.Format("{0}{1}{2}/", folder.Name, InventoryArchiveConstants.INVENTORY_NODE_NAME_COMPONENT_SEPARATOR, folder.ID); | 183 | path += string.Format("{0}{1}{2}/", folder.Name, ArchiveConstants.INVENTORY_NODE_NAME_COMPONENT_SEPARATOR, folder.ID); |
185 | archive.WriteDir(path); | 184 | archive.WriteDir(path); |
186 | 185 | ||
187 | foreach (InventoryNodeBase inventoryNode in folder.Children.Values) | 186 | foreach (InventoryNodeBase inventoryNode in folder.Children.Values) |
diff --git a/OpenSim/Region/CoreModules/Avatar/Inventory/Archiver/InventoryArchiveConstants.cs b/OpenSim/Region/CoreModules/Avatar/Inventory/Archiver/InventoryArchiveConstants.cs deleted file mode 100644 index e2bce16..0000000 --- a/OpenSim/Region/CoreModules/Avatar/Inventory/Archiver/InventoryArchiveConstants.cs +++ /dev/null | |||
@@ -1,113 +0,0 @@ | |||
1 | /* | ||
2 | * Copyright (c) Contributors, http://opensimulator.org/ | ||
3 | * See CONTRIBUTORS.TXT for a full list of copyright holders. | ||
4 | * | ||
5 | * Redistribution and use in source and binary forms, with or without | ||
6 | * modification, are permitted provided that the following conditions are met: | ||
7 | * * Redistributions of source code must retain the above copyright | ||
8 | * notice, this list of conditions and the following disclaimer. | ||
9 | * * Redistributions in binary form must reproduce the above copyright | ||
10 | * notice, this list of conditions and the following disclaimer in the | ||
11 | * documentation and/or other materials provided with the distribution. | ||
12 | * * Neither the name of the OpenSim Project nor the | ||
13 | * names of its contributors may be used to endorse or promote products | ||
14 | * derived from this software without specific prior written permission. | ||
15 | * | ||
16 | * THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS'' AND ANY | ||
17 | * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED | ||
18 | * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE | ||
19 | * DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY | ||
20 | * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES | ||
21 | * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; | ||
22 | * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND | ||
23 | * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT | ||
24 | * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS | ||
25 | * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. | ||
26 | */ | ||
27 | |||
28 | using System.Collections.Generic; | ||
29 | using OpenMetaverse; | ||
30 | |||
31 | namespace OpenSim.Region.CoreModules.Avatar.Inventory.Archiver | ||
32 | { | ||
33 | /// <summary> | ||
34 | /// Constants for the inventory archiving module | ||
35 | /// </summary> | ||
36 | public class InventoryArchiveConstants | ||
37 | { | ||
38 | /// <summary> | ||
39 | /// Path for the inventory data | ||
40 | /// </summary> | ||
41 | public static readonly string INVENTORY_PATH = "inventory/"; | ||
42 | |||
43 | /// <summary> | ||
44 | /// Path for the assets held in an archive | ||
45 | /// </summary> | ||
46 | public static readonly string ASSETS_PATH = "assets/"; | ||
47 | |||
48 | /// <summary> | ||
49 | /// The character the separates the uuid from extension information in an archived asset filename | ||
50 | /// </summary> | ||
51 | public static readonly string ASSET_EXTENSION_SEPARATOR = "_"; | ||
52 | |||
53 | /// <summary> | ||
54 | /// Used to separate components in an inventory node name | ||
55 | /// </summary> | ||
56 | public static readonly string INVENTORY_NODE_NAME_COMPONENT_SEPARATOR = "__"; | ||
57 | |||
58 | /// <summary> | ||
59 | /// Extensions used for asset types in the archive | ||
60 | /// </summary> | ||
61 | public static readonly IDictionary<sbyte, string> ASSET_TYPE_TO_EXTENSION = new Dictionary<sbyte, string>(); | ||
62 | public static readonly IDictionary<string, sbyte> EXTENSION_TO_ASSET_TYPE = new Dictionary<string, sbyte>(); | ||
63 | |||
64 | static InventoryArchiveConstants() | ||
65 | { | ||
66 | ASSET_TYPE_TO_EXTENSION[(sbyte)AssetType.Animation] = ASSET_EXTENSION_SEPARATOR + "animation.bvh"; | ||
67 | ASSET_TYPE_TO_EXTENSION[(sbyte)AssetType.Bodypart] = ASSET_EXTENSION_SEPARATOR + "bodypart.txt"; | ||
68 | ASSET_TYPE_TO_EXTENSION[(sbyte)AssetType.CallingCard] = ASSET_EXTENSION_SEPARATOR + "callingcard.txt"; | ||
69 | ASSET_TYPE_TO_EXTENSION[(sbyte)AssetType.Clothing] = ASSET_EXTENSION_SEPARATOR + "clothing.txt"; | ||
70 | ASSET_TYPE_TO_EXTENSION[(sbyte)AssetType.Folder] = ASSET_EXTENSION_SEPARATOR + "folder.txt"; // Not sure if we'll ever see this | ||
71 | ASSET_TYPE_TO_EXTENSION[(sbyte)AssetType.Gesture] = ASSET_EXTENSION_SEPARATOR + "gesture.txt"; | ||
72 | ASSET_TYPE_TO_EXTENSION[(sbyte)AssetType.ImageJPEG] = ASSET_EXTENSION_SEPARATOR + "image.jpg"; | ||
73 | ASSET_TYPE_TO_EXTENSION[(sbyte)AssetType.ImageTGA] = ASSET_EXTENSION_SEPARATOR + "image.tga"; | ||
74 | ASSET_TYPE_TO_EXTENSION[(sbyte)AssetType.Landmark] = ASSET_EXTENSION_SEPARATOR + "landmark.txt"; | ||
75 | ASSET_TYPE_TO_EXTENSION[(sbyte)AssetType.LostAndFoundFolder] = ASSET_EXTENSION_SEPARATOR + "lostandfoundfolder.txt"; // Not sure if we'll ever see this | ||
76 | ASSET_TYPE_TO_EXTENSION[(sbyte)AssetType.LSLBytecode] = ASSET_EXTENSION_SEPARATOR + "bytecode.lso"; | ||
77 | ASSET_TYPE_TO_EXTENSION[(sbyte)AssetType.LSLText] = ASSET_EXTENSION_SEPARATOR + "script.lsl"; | ||
78 | ASSET_TYPE_TO_EXTENSION[(sbyte)AssetType.Notecard] = ASSET_EXTENSION_SEPARATOR + "notecard.txt"; | ||
79 | ASSET_TYPE_TO_EXTENSION[(sbyte)AssetType.Object] = ASSET_EXTENSION_SEPARATOR + "object.xml"; | ||
80 | ASSET_TYPE_TO_EXTENSION[(sbyte)AssetType.RootFolder] = ASSET_EXTENSION_SEPARATOR + "rootfolder.txt"; // Not sure if we'll ever see this | ||
81 | ASSET_TYPE_TO_EXTENSION[(sbyte)AssetType.Simstate] = ASSET_EXTENSION_SEPARATOR + "simstate.bin"; // Not sure if we'll ever see this | ||
82 | ASSET_TYPE_TO_EXTENSION[(sbyte)AssetType.SnapshotFolder] = ASSET_EXTENSION_SEPARATOR + "snapshotfolder.txt"; // Not sure if we'll ever see this | ||
83 | ASSET_TYPE_TO_EXTENSION[(sbyte)AssetType.Sound] = ASSET_EXTENSION_SEPARATOR + "sound.ogg"; | ||
84 | ASSET_TYPE_TO_EXTENSION[(sbyte)AssetType.SoundWAV] = ASSET_EXTENSION_SEPARATOR + "sound.wav"; | ||
85 | ASSET_TYPE_TO_EXTENSION[(sbyte)AssetType.Texture] = ASSET_EXTENSION_SEPARATOR + "texture.jp2"; | ||
86 | ASSET_TYPE_TO_EXTENSION[(sbyte)AssetType.TextureTGA] = ASSET_EXTENSION_SEPARATOR + "texture.tga"; | ||
87 | ASSET_TYPE_TO_EXTENSION[(sbyte)AssetType.TrashFolder] = ASSET_EXTENSION_SEPARATOR + "trashfolder.txt"; // Not sure if we'll ever see this | ||
88 | |||
89 | EXTENSION_TO_ASSET_TYPE[ASSET_EXTENSION_SEPARATOR + "animation.bvh"] = (sbyte)AssetType.Animation; | ||
90 | EXTENSION_TO_ASSET_TYPE[ASSET_EXTENSION_SEPARATOR + "bodypart.txt"] = (sbyte)AssetType.Bodypart; | ||
91 | EXTENSION_TO_ASSET_TYPE[ASSET_EXTENSION_SEPARATOR + "callingcard.txt"] = (sbyte)AssetType.CallingCard; | ||
92 | EXTENSION_TO_ASSET_TYPE[ASSET_EXTENSION_SEPARATOR + "clothing.txt"] = (sbyte)AssetType.Clothing; | ||
93 | EXTENSION_TO_ASSET_TYPE[ASSET_EXTENSION_SEPARATOR + "folder.txt"] = (sbyte)AssetType.Folder; | ||
94 | EXTENSION_TO_ASSET_TYPE[ASSET_EXTENSION_SEPARATOR + "gesture.txt"] = (sbyte)AssetType.Gesture; | ||
95 | EXTENSION_TO_ASSET_TYPE[ASSET_EXTENSION_SEPARATOR + "image.jpg"] = (sbyte)AssetType.ImageJPEG; | ||
96 | EXTENSION_TO_ASSET_TYPE[ASSET_EXTENSION_SEPARATOR + "image.tga"] = (sbyte)AssetType.ImageTGA; | ||
97 | EXTENSION_TO_ASSET_TYPE[ASSET_EXTENSION_SEPARATOR + "landmark.txt"] = (sbyte)AssetType.Landmark; | ||
98 | EXTENSION_TO_ASSET_TYPE[ASSET_EXTENSION_SEPARATOR + "lostandfoundfolder.txt"] = (sbyte)AssetType.LostAndFoundFolder; | ||
99 | EXTENSION_TO_ASSET_TYPE[ASSET_EXTENSION_SEPARATOR + "bytecode.lso"] = (sbyte)AssetType.LSLBytecode; | ||
100 | EXTENSION_TO_ASSET_TYPE[ASSET_EXTENSION_SEPARATOR + "script.lsl"] = (sbyte)AssetType.LSLText; | ||
101 | EXTENSION_TO_ASSET_TYPE[ASSET_EXTENSION_SEPARATOR + "notecard.txt"] = (sbyte)AssetType.Notecard; | ||
102 | EXTENSION_TO_ASSET_TYPE[ASSET_EXTENSION_SEPARATOR + "object.xml"] = (sbyte)AssetType.Object; | ||
103 | EXTENSION_TO_ASSET_TYPE[ASSET_EXTENSION_SEPARATOR + "rootfolder.txt"] = (sbyte)AssetType.RootFolder; | ||
104 | EXTENSION_TO_ASSET_TYPE[ASSET_EXTENSION_SEPARATOR + "simstate.bin"] = (sbyte)AssetType.Simstate; | ||
105 | EXTENSION_TO_ASSET_TYPE[ASSET_EXTENSION_SEPARATOR + "snapshotfolder.txt"] = (sbyte)AssetType.SnapshotFolder; | ||
106 | EXTENSION_TO_ASSET_TYPE[ASSET_EXTENSION_SEPARATOR + "sound.ogg"] = (sbyte)AssetType.Sound; | ||
107 | EXTENSION_TO_ASSET_TYPE[ASSET_EXTENSION_SEPARATOR + "sound.wav"] = (sbyte)AssetType.SoundWAV; | ||
108 | EXTENSION_TO_ASSET_TYPE[ASSET_EXTENSION_SEPARATOR + "texture.jp2"] = (sbyte)AssetType.Texture; | ||
109 | EXTENSION_TO_ASSET_TYPE[ASSET_EXTENSION_SEPARATOR + "texture.tga"] = (sbyte)AssetType.TextureTGA; | ||
110 | EXTENSION_TO_ASSET_TYPE[ASSET_EXTENSION_SEPARATOR + "trashfolder.txt"] = (sbyte)AssetType.TrashFolder; | ||
111 | } | ||
112 | } | ||
113 | } | ||
diff --git a/OpenSim/Region/CoreModules/Avatar/Inventory/Archiver/InventoryArchiveReadRequest.cs b/OpenSim/Region/CoreModules/Avatar/Inventory/Archiver/InventoryArchiveReadRequest.cs index 5de8adc..d794f00 100644 --- a/OpenSim/Region/CoreModules/Avatar/Inventory/Archiver/InventoryArchiveReadRequest.cs +++ b/OpenSim/Region/CoreModules/Avatar/Inventory/Archiver/InventoryArchiveReadRequest.cs | |||
@@ -51,32 +51,32 @@ namespace OpenSim.Region.CoreModules.Avatar.Inventory.Archiver | |||
51 | 51 | ||
52 | private CachedUserInfo m_userInfo; | 52 | private CachedUserInfo m_userInfo; |
53 | private string m_invPath; | 53 | private string m_invPath; |
54 | 54 | ||
55 | /// <value> | 55 | /// <value> |
56 | /// The stream from which the inventory archive will be loaded. | 56 | /// The stream from which the inventory archive will be loaded. |
57 | /// </value> | 57 | /// </value> |
58 | private Stream m_loadStream; | 58 | private Stream m_loadStream; |
59 | 59 | ||
60 | CommunicationsManager commsManager; | 60 | CommunicationsManager commsManager; |
61 | 61 | ||
62 | public InventoryArchiveReadRequest( | 62 | public InventoryArchiveReadRequest( |
63 | CachedUserInfo userInfo, string invPath, string loadPath, CommunicationsManager commsManager) | 63 | CachedUserInfo userInfo, string invPath, string loadPath, CommunicationsManager commsManager) |
64 | : this( | 64 | : this( |
65 | userInfo, | 65 | userInfo, |
66 | invPath, | 66 | invPath, |
67 | new GZipStream(new FileStream(loadPath, FileMode.Open), CompressionMode.Decompress), | 67 | new GZipStream(new FileStream(loadPath, FileMode.Open), CompressionMode.Decompress), |
68 | commsManager) | 68 | commsManager) |
69 | { | 69 | { |
70 | } | 70 | } |
71 | 71 | ||
72 | public InventoryArchiveReadRequest( | 72 | public InventoryArchiveReadRequest( |
73 | CachedUserInfo userInfo, string invPath, Stream loadStream, CommunicationsManager commsManager) | 73 | CachedUserInfo userInfo, string invPath, Stream loadStream, CommunicationsManager commsManager) |
74 | { | 74 | { |
75 | m_userInfo = userInfo; | 75 | m_userInfo = userInfo; |
76 | m_invPath = invPath; | 76 | m_invPath = invPath; |
77 | m_loadStream = loadStream; | 77 | m_loadStream = loadStream; |
78 | this.commsManager = commsManager; | 78 | this.commsManager = commsManager; |
79 | } | 79 | } |
80 | 80 | ||
81 | protected InventoryItemBase LoadInvItem(string contents) | 81 | protected InventoryItemBase LoadInvItem(string contents) |
82 | { | 82 | { |
@@ -157,11 +157,11 @@ namespace OpenSim.Region.CoreModules.Avatar.Inventory.Archiver | |||
157 | int failedAssetRestores = 0; | 157 | int failedAssetRestores = 0; |
158 | int successfulItemRestores = 0; | 158 | int successfulItemRestores = 0; |
159 | List<InventoryNodeBase> nodesLoaded = new List<InventoryNodeBase>(); | 159 | List<InventoryNodeBase> nodesLoaded = new List<InventoryNodeBase>(); |
160 | 160 | ||
161 | if (!m_userInfo.HasReceivedInventory) | 161 | if (!m_userInfo.HasReceivedInventory) |
162 | { | 162 | { |
163 | // If the region server has access to the user admin service (by which users are created), | 163 | // If the region server has access to the user admin service (by which users are created), |
164 | // then we'll assume that it's okay to fiddle with the user's inventory even if they are not on the | 164 | // then we'll assume that it's okay to fiddle with the user's inventory even if they are not on the |
165 | // server. | 165 | // server. |
166 | // | 166 | // |
167 | // FIXME: FetchInventory should probably be assumed to by async anyway, since even standalones might | 167 | // FIXME: FetchInventory should probably be assumed to by async anyway, since even standalones might |
@@ -191,7 +191,7 @@ namespace OpenSim.Region.CoreModules.Avatar.Inventory.Archiver | |||
191 | } | 191 | } |
192 | 192 | ||
193 | archive = new TarArchiveReader(m_loadStream); | 193 | archive = new TarArchiveReader(m_loadStream); |
194 | 194 | ||
195 | // In order to load identically named folders, we need to keep track of the folders that we have already | 195 | // In order to load identically named folders, we need to keep track of the folders that we have already |
196 | // created | 196 | // created |
197 | Dictionary <string, InventoryFolderImpl> foldersCreated = new Dictionary<string, InventoryFolderImpl>(); | 197 | Dictionary <string, InventoryFolderImpl> foldersCreated = new Dictionary<string, InventoryFolderImpl>(); |
@@ -200,18 +200,18 @@ namespace OpenSim.Region.CoreModules.Avatar.Inventory.Archiver | |||
200 | TarArchiveReader.TarEntryType entryType; | 200 | TarArchiveReader.TarEntryType entryType; |
201 | while ((data = archive.ReadEntry(out filePath, out entryType)) != null) | 201 | while ((data = archive.ReadEntry(out filePath, out entryType)) != null) |
202 | { | 202 | { |
203 | if (entryType == TarArchiveReader.TarEntryType.TYPE_DIRECTORY) | 203 | if (entryType == TarArchiveReader.TarEntryType.TYPE_DIRECTORY) |
204 | { | 204 | { |
205 | m_log.WarnFormat("[INVENTORY ARCHIVER]: Ignoring directory entry {0}", filePath); | 205 | m_log.WarnFormat("[INVENTORY ARCHIVER]: Ignoring directory entry {0}", filePath); |
206 | } | 206 | } |
207 | else if (filePath.StartsWith(InventoryArchiveConstants.ASSETS_PATH)) | 207 | else if (filePath.StartsWith(ArchiveConstants.ASSETS_PATH)) |
208 | { | 208 | { |
209 | if (LoadAsset(filePath, data)) | 209 | if (LoadAsset(filePath, data)) |
210 | successfulAssetRestores++; | 210 | successfulAssetRestores++; |
211 | else | 211 | else |
212 | failedAssetRestores++; | 212 | failedAssetRestores++; |
213 | } | 213 | } |
214 | else if (filePath.StartsWith(InventoryArchiveConstants.INVENTORY_PATH)) | 214 | else if (filePath.StartsWith(ArchiveConstants.INVENTORY_PATH)) |
215 | { | 215 | { |
216 | InventoryItemBase item = LoadInvItem(m_asciiEncoding.GetString(data)); | 216 | InventoryItemBase item = LoadInvItem(m_asciiEncoding.GetString(data)); |
217 | 217 | ||
@@ -219,16 +219,16 @@ namespace OpenSim.Region.CoreModules.Avatar.Inventory.Archiver | |||
219 | { | 219 | { |
220 | // Don't use the item ID that's in the file | 220 | // Don't use the item ID that's in the file |
221 | item.ID = UUID.Random(); | 221 | item.ID = UUID.Random(); |
222 | 222 | ||
223 | item.Creator = m_userInfo.UserProfile.ID; | 223 | item.Creator = m_userInfo.UserProfile.ID; |
224 | item.Owner = m_userInfo.UserProfile.ID; | 224 | item.Owner = m_userInfo.UserProfile.ID; |
225 | 225 | ||
226 | string fsPath = filePath.Substring(InventoryArchiveConstants.INVENTORY_PATH.Length); | 226 | string fsPath = filePath.Substring(ArchiveConstants.INVENTORY_PATH.Length); |
227 | fsPath = fsPath.Remove(fsPath.LastIndexOf("/") + 1); | 227 | fsPath = fsPath.Remove(fsPath.LastIndexOf("/") + 1); |
228 | string originalFsPath = fsPath; | 228 | string originalFsPath = fsPath; |
229 | 229 | ||
230 | m_log.DebugFormat("[INVENTORY ARCHIVER]: Loading to folder {0}", fsPath); | 230 | m_log.DebugFormat("[INVENTORY ARCHIVER]: Loading to folder {0}", fsPath); |
231 | 231 | ||
232 | InventoryFolderImpl foundFolder = null; | 232 | InventoryFolderImpl foundFolder = null; |
233 | while (null == foundFolder && fsPath.Length > 0) | 233 | while (null == foundFolder && fsPath.Length > 0) |
234 | { | 234 | { |
@@ -241,7 +241,7 @@ namespace OpenSim.Region.CoreModules.Avatar.Inventory.Archiver | |||
241 | { | 241 | { |
242 | // Don't include the last slash | 242 | // Don't include the last slash |
243 | int penultimateSlashIndex = fsPath.LastIndexOf("/", fsPath.Length - 2); | 243 | int penultimateSlashIndex = fsPath.LastIndexOf("/", fsPath.Length - 2); |
244 | 244 | ||
245 | if (penultimateSlashIndex >= 0) | 245 | if (penultimateSlashIndex >= 0) |
246 | { | 246 | { |
247 | fsPath = fsPath.Remove(penultimateSlashIndex + 1); | 247 | fsPath = fsPath.Remove(penultimateSlashIndex + 1); |
@@ -254,42 +254,42 @@ namespace OpenSim.Region.CoreModules.Avatar.Inventory.Archiver | |||
254 | fsPath = string.Empty; | 254 | fsPath = string.Empty; |
255 | foundFolder = rootDestinationFolder; | 255 | foundFolder = rootDestinationFolder; |
256 | } | 256 | } |
257 | } | 257 | } |
258 | } | 258 | } |
259 | 259 | ||
260 | string fsPathSectionToCreate = originalFsPath.Substring(fsPath.Length); | 260 | string fsPathSectionToCreate = originalFsPath.Substring(fsPath.Length); |
261 | string[] rawDirsToCreate | 261 | string[] rawDirsToCreate |
262 | = fsPathSectionToCreate.Split(new char[] { '/' }, StringSplitOptions.RemoveEmptyEntries); | 262 | = fsPathSectionToCreate.Split(new char[] { '/' }, StringSplitOptions.RemoveEmptyEntries); |
263 | int i = 0; | 263 | int i = 0; |
264 | 264 | ||
265 | while (i < rawDirsToCreate.Length) | 265 | while (i < rawDirsToCreate.Length) |
266 | { | 266 | { |
267 | m_log.DebugFormat("[INVENTORY ARCHIVER]: Creating folder {0}", rawDirsToCreate[i]); | 267 | m_log.DebugFormat("[INVENTORY ARCHIVER]: Creating folder {0}", rawDirsToCreate[i]); |
268 | 268 | ||
269 | int identicalNameIdentifierIndex | 269 | int identicalNameIdentifierIndex |
270 | = rawDirsToCreate[i].LastIndexOf( | 270 | = rawDirsToCreate[i].LastIndexOf( |
271 | InventoryArchiveConstants.INVENTORY_NODE_NAME_COMPONENT_SEPARATOR); | 271 | ArchiveConstants.INVENTORY_NODE_NAME_COMPONENT_SEPARATOR); |
272 | string folderName = rawDirsToCreate[i].Remove(identicalNameIdentifierIndex); | 272 | string folderName = rawDirsToCreate[i].Remove(identicalNameIdentifierIndex); |
273 | 273 | ||
274 | UUID newFolderId = UUID.Random(); | 274 | UUID newFolderId = UUID.Random(); |
275 | m_userInfo.CreateFolder( | 275 | m_userInfo.CreateFolder( |
276 | folderName, newFolderId, (ushort)AssetType.Folder, foundFolder.ID); | 276 | folderName, newFolderId, (ushort)AssetType.Folder, foundFolder.ID); |
277 | foundFolder = foundFolder.GetChildFolder(newFolderId); | 277 | foundFolder = foundFolder.GetChildFolder(newFolderId); |
278 | 278 | ||
279 | // Record that we have now created this folder | 279 | // Record that we have now created this folder |
280 | fsPath += rawDirsToCreate[i] + "/"; | 280 | fsPath += rawDirsToCreate[i] + "/"; |
281 | m_log.DebugFormat("[INVENTORY ARCHIVER]: Recording creation of fs path {0}", fsPath); | 281 | m_log.DebugFormat("[INVENTORY ARCHIVER]: Recording creation of fs path {0}", fsPath); |
282 | foldersCreated[fsPath] = foundFolder; | 282 | foldersCreated[fsPath] = foundFolder; |
283 | 283 | ||
284 | if (0 == i) | 284 | if (0 == i) |
285 | nodesLoaded.Add(foundFolder); | 285 | nodesLoaded.Add(foundFolder); |
286 | 286 | ||
287 | i++; | 287 | i++; |
288 | } | 288 | } |
289 | 289 | ||
290 | /* | 290 | /* |
291 | string[] rawFolders = filePath.Split(new char[] { '/' }); | 291 | string[] rawFolders = filePath.Split(new char[] { '/' }); |
292 | 292 | ||
293 | // Find the folders that do exist along the path given | 293 | // Find the folders that do exist along the path given |
294 | int i = 0; | 294 | int i = 0; |
295 | bool noFolder = false; | 295 | bool noFolder = false; |
@@ -306,27 +306,27 @@ namespace OpenSim.Region.CoreModules.Avatar.Inventory.Archiver | |||
306 | else | 306 | else |
307 | { | 307 | { |
308 | noFolder = true; | 308 | noFolder = true; |
309 | } | 309 | } |
310 | } | 310 | } |
311 | 311 | ||
312 | // Create any folders that did not previously exist | 312 | // Create any folders that did not previously exist |
313 | while (i < rawFolders.Length) | 313 | while (i < rawFolders.Length) |
314 | { | 314 | { |
315 | m_log.DebugFormat("[INVENTORY ARCHIVER]: Creating folder {0}", rawFolders[i]); | 315 | m_log.DebugFormat("[INVENTORY ARCHIVER]: Creating folder {0}", rawFolders[i]); |
316 | 316 | ||
317 | UUID newFolderId = UUID.Random(); | 317 | UUID newFolderId = UUID.Random(); |
318 | m_userInfo.CreateFolder( | 318 | m_userInfo.CreateFolder( |
319 | rawFolders[i++], newFolderId, (ushort)AssetType.Folder, foundFolder.ID); | 319 | rawFolders[i++], newFolderId, (ushort)AssetType.Folder, foundFolder.ID); |
320 | foundFolder = foundFolder.GetChildFolder(newFolderId); | 320 | foundFolder = foundFolder.GetChildFolder(newFolderId); |
321 | } | 321 | } |
322 | */ | 322 | */ |
323 | 323 | ||
324 | // Reset folder ID to the one in which we want to load it | 324 | // Reset folder ID to the one in which we want to load it |
325 | item.Folder = foundFolder.ID; | 325 | item.Folder = foundFolder.ID; |
326 | 326 | ||
327 | m_userInfo.AddItem(item); | 327 | m_userInfo.AddItem(item); |
328 | successfulItemRestores++; | 328 | successfulItemRestores++; |
329 | 329 | ||
330 | // If we're loading an item directly into the given destination folder then we need to record | 330 | // If we're loading an item directly into the given destination folder then we need to record |
331 | // it separately from any loaded root folders | 331 | // it separately from any loaded root folders |
332 | if (rootDestinationFolder == foundFolder) | 332 | if (rootDestinationFolder == foundFolder) |
@@ -339,7 +339,7 @@ namespace OpenSim.Region.CoreModules.Avatar.Inventory.Archiver | |||
339 | 339 | ||
340 | m_log.DebugFormat("[INVENTORY ARCHIVER]: Restored {0} assets", successfulAssetRestores); | 340 | m_log.DebugFormat("[INVENTORY ARCHIVER]: Restored {0} assets", successfulAssetRestores); |
341 | m_log.InfoFormat("[INVENTORY ARCHIVER]: Restored {0} items", successfulItemRestores); | 341 | m_log.InfoFormat("[INVENTORY ARCHIVER]: Restored {0} items", successfulItemRestores); |
342 | 342 | ||
343 | return nodesLoaded; | 343 | return nodesLoaded; |
344 | } | 344 | } |
345 | 345 | ||
@@ -353,14 +353,14 @@ namespace OpenSim.Region.CoreModules.Avatar.Inventory.Archiver | |||
353 | { | 353 | { |
354 | //IRegionSerialiser serialiser = scene.RequestModuleInterface<IRegionSerialiser>(); | 354 | //IRegionSerialiser serialiser = scene.RequestModuleInterface<IRegionSerialiser>(); |
355 | // Right now we're nastily obtaining the UUID from the filename | 355 | // Right now we're nastily obtaining the UUID from the filename |
356 | string filename = assetPath.Remove(0, InventoryArchiveConstants.ASSETS_PATH.Length); | 356 | string filename = assetPath.Remove(0, ArchiveConstants.ASSETS_PATH.Length); |
357 | int i = filename.LastIndexOf(InventoryArchiveConstants.ASSET_EXTENSION_SEPARATOR); | 357 | int i = filename.LastIndexOf(ArchiveConstants.ASSET_EXTENSION_SEPARATOR); |
358 | 358 | ||
359 | if (i == -1) | 359 | if (i == -1) |
360 | { | 360 | { |
361 | m_log.ErrorFormat( | 361 | m_log.ErrorFormat( |
362 | "[INVENTORY ARCHIVER]: Could not find extension information in asset path {0} since it's missing the separator {1}. Skipping", | 362 | "[INVENTORY ARCHIVER]: Could not find extension information in asset path {0} since it's missing the separator {1}. Skipping", |
363 | assetPath, InventoryArchiveConstants.ASSET_EXTENSION_SEPARATOR); | 363 | assetPath, ArchiveConstants.ASSET_EXTENSION_SEPARATOR); |
364 | 364 | ||
365 | return false; | 365 | return false; |
366 | } | 366 | } |
@@ -368,9 +368,9 @@ namespace OpenSim.Region.CoreModules.Avatar.Inventory.Archiver | |||
368 | string extension = filename.Substring(i); | 368 | string extension = filename.Substring(i); |
369 | string uuid = filename.Remove(filename.Length - extension.Length); | 369 | string uuid = filename.Remove(filename.Length - extension.Length); |
370 | 370 | ||
371 | if (InventoryArchiveConstants.EXTENSION_TO_ASSET_TYPE.ContainsKey(extension)) | 371 | if (ArchiveConstants.EXTENSION_TO_ASSET_TYPE.ContainsKey(extension)) |
372 | { | 372 | { |
373 | sbyte assetType = InventoryArchiveConstants.EXTENSION_TO_ASSET_TYPE[extension]; | 373 | sbyte assetType = ArchiveConstants.EXTENSION_TO_ASSET_TYPE[extension]; |
374 | 374 | ||
375 | //m_log.DebugFormat("[INVENTORY ARCHIVER]: Importing asset {0}, type {1}", uuid, assetType); | 375 | //m_log.DebugFormat("[INVENTORY ARCHIVER]: Importing asset {0}, type {1}", uuid, assetType); |
376 | 376 | ||
diff --git a/OpenSim/Region/CoreModules/Avatar/Inventory/Archiver/InventoryArchiveWriteRequest.cs b/OpenSim/Region/CoreModules/Avatar/Inventory/Archiver/InventoryArchiveWriteRequest.cs index 71c4740..364dc28 100644 --- a/OpenSim/Region/CoreModules/Avatar/Inventory/Archiver/InventoryArchiveWriteRequest.cs +++ b/OpenSim/Region/CoreModules/Avatar/Inventory/Archiver/InventoryArchiveWriteRequest.cs | |||
@@ -41,47 +41,47 @@ using OpenSim.Region.CoreModules.World.Archiver; | |||
41 | using OpenSim.Region.Framework.Scenes; | 41 | using OpenSim.Region.Framework.Scenes; |
42 | 42 | ||
43 | namespace OpenSim.Region.CoreModules.Avatar.Inventory.Archiver | 43 | namespace OpenSim.Region.CoreModules.Avatar.Inventory.Archiver |
44 | { | 44 | { |
45 | public class InventoryArchiveWriteRequest | 45 | public class InventoryArchiveWriteRequest |
46 | { | 46 | { |
47 | private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); | 47 | private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); |
48 | 48 | ||
49 | protected TarArchiveWriter m_archive; | 49 | protected TarArchiveWriter m_archive; |
50 | protected UuidGatherer m_assetGatherer; | 50 | protected UuidGatherer m_assetGatherer; |
51 | protected Dictionary<UUID, int> assetUuids = new Dictionary<UUID, int>(); | 51 | protected Dictionary<UUID, int> assetUuids = new Dictionary<UUID, int>(); |
52 | 52 | ||
53 | private InventoryArchiverModule m_module; | 53 | private InventoryArchiverModule m_module; |
54 | private CachedUserInfo m_userInfo; | 54 | private CachedUserInfo m_userInfo; |
55 | private string m_invPath; | 55 | private string m_invPath; |
56 | 56 | ||
57 | /// <value> | 57 | /// <value> |
58 | /// The stream to which the inventory archive will be saved. | 58 | /// The stream to which the inventory archive will be saved. |
59 | /// </value> | 59 | /// </value> |
60 | private Stream m_saveStream; | 60 | private Stream m_saveStream; |
61 | 61 | ||
62 | /// <summary> | 62 | /// <summary> |
63 | /// Constructor | 63 | /// Constructor |
64 | /// </summary> | 64 | /// </summary> |
65 | public InventoryArchiveWriteRequest( | 65 | public InventoryArchiveWriteRequest( |
66 | InventoryArchiverModule module, CachedUserInfo userInfo, string invPath, string savePath) | 66 | InventoryArchiverModule module, CachedUserInfo userInfo, string invPath, string savePath) |
67 | : this( | 67 | : this( |
68 | module, | 68 | module, |
69 | userInfo, | 69 | userInfo, |
70 | invPath, | 70 | invPath, |
71 | new GZipStream(new FileStream(savePath, FileMode.Create), CompressionMode.Compress)) | 71 | new GZipStream(new FileStream(savePath, FileMode.Create), CompressionMode.Compress)) |
72 | { | 72 | { |
73 | } | 73 | } |
74 | 74 | ||
75 | /// <summary> | 75 | /// <summary> |
76 | /// Constructor | 76 | /// Constructor |
77 | /// </summary> | 77 | /// </summary> |
78 | public InventoryArchiveWriteRequest( | 78 | public InventoryArchiveWriteRequest( |
79 | InventoryArchiverModule module, CachedUserInfo userInfo, string invPath, Stream saveStream) | 79 | InventoryArchiverModule module, CachedUserInfo userInfo, string invPath, Stream saveStream) |
80 | { | 80 | { |
81 | m_module = module; | 81 | m_module = module; |
82 | m_userInfo = userInfo; | 82 | m_userInfo = userInfo; |
83 | m_invPath = invPath; | 83 | m_invPath = invPath; |
84 | m_saveStream = saveStream; | 84 | m_saveStream = saveStream; |
85 | m_assetGatherer = new UuidGatherer(m_module.CommsManager.AssetCache); | 85 | m_assetGatherer = new UuidGatherer(m_module.CommsManager.AssetCache); |
86 | } | 86 | } |
87 | 87 | ||
@@ -89,22 +89,22 @@ namespace OpenSim.Region.CoreModules.Avatar.Inventory.Archiver | |||
89 | { | 89 | { |
90 | AssetsArchiver assetsArchiver = new AssetsArchiver(assetsFound); | 90 | AssetsArchiver assetsArchiver = new AssetsArchiver(assetsFound); |
91 | assetsArchiver.Archive(m_archive); | 91 | assetsArchiver.Archive(m_archive); |
92 | 92 | ||
93 | Exception reportedException = null; | 93 | Exception reportedException = null; |
94 | bool succeeded = true; | 94 | bool succeeded = true; |
95 | 95 | ||
96 | try | 96 | try |
97 | { | 97 | { |
98 | m_archive.Close(); | 98 | m_archive.Close(); |
99 | } | 99 | } |
100 | catch (IOException e) | 100 | catch (IOException e) |
101 | { | 101 | { |
102 | m_saveStream.Close(); | 102 | m_saveStream.Close(); |
103 | reportedException = e; | 103 | reportedException = e; |
104 | succeeded = false; | 104 | succeeded = false; |
105 | } | 105 | } |
106 | 106 | ||
107 | m_module.TriggerInventoryArchiveSaved(succeeded, m_userInfo, m_invPath, m_saveStream, reportedException); | 107 | m_module.TriggerInventoryArchiveSaved(succeeded, m_userInfo, m_invPath, m_saveStream, reportedException); |
108 | } | 108 | } |
109 | 109 | ||
110 | protected void SaveInvItem(InventoryItemBase inventoryItem, string path) | 110 | protected void SaveInvItem(InventoryItemBase inventoryItem, string path) |
@@ -113,9 +113,9 @@ namespace OpenSim.Region.CoreModules.Avatar.Inventory.Archiver | |||
113 | StringWriter sw = new StringWriter(); | 113 | StringWriter sw = new StringWriter(); |
114 | XmlTextWriter writer = new XmlTextWriter(sw); | 114 | XmlTextWriter writer = new XmlTextWriter(sw); |
115 | writer.Formatting = Formatting.Indented; | 115 | writer.Formatting = Formatting.Indented; |
116 | 116 | ||
117 | writer.WriteStartElement("InventoryItem"); | 117 | writer.WriteStartElement("InventoryItem"); |
118 | 118 | ||
119 | writer.WriteStartElement("Name"); | 119 | writer.WriteStartElement("Name"); |
120 | writer.WriteString(inventoryItem.Name); | 120 | writer.WriteString(inventoryItem.Name); |
121 | writer.WriteEndElement(); | 121 | writer.WriteEndElement(); |
@@ -170,7 +170,7 @@ namespace OpenSim.Region.CoreModules.Avatar.Inventory.Archiver | |||
170 | writer.WriteStartElement("GroupOwned"); | 170 | writer.WriteStartElement("GroupOwned"); |
171 | writer.WriteString(inventoryItem.GroupOwned.ToString()); | 171 | writer.WriteString(inventoryItem.GroupOwned.ToString()); |
172 | writer.WriteEndElement(); | 172 | writer.WriteEndElement(); |
173 | 173 | ||
174 | writer.WriteEndElement(); | 174 | writer.WriteEndElement(); |
175 | 175 | ||
176 | m_archive.WriteFile(filename, sw.ToString()); | 176 | m_archive.WriteFile(filename, sw.ToString()); |
@@ -180,43 +180,43 @@ namespace OpenSim.Region.CoreModules.Avatar.Inventory.Archiver | |||
180 | 180 | ||
181 | protected void SaveInvDir(InventoryFolderImpl inventoryFolder, string path) | 181 | protected void SaveInvDir(InventoryFolderImpl inventoryFolder, string path) |
182 | { | 182 | { |
183 | path += | 183 | path += |
184 | string.Format( | 184 | string.Format( |
185 | "{0}{1}{2}/", | 185 | "{0}{1}{2}/", |
186 | inventoryFolder.Name, | 186 | inventoryFolder.Name, |
187 | InventoryArchiveConstants.INVENTORY_NODE_NAME_COMPONENT_SEPARATOR, | 187 | ArchiveConstants.INVENTORY_NODE_NAME_COMPONENT_SEPARATOR, |
188 | inventoryFolder.ID); | 188 | inventoryFolder.ID); |
189 | m_archive.WriteDir(path); | 189 | m_archive.WriteDir(path); |
190 | 190 | ||
191 | List<InventoryFolderImpl> childFolders = inventoryFolder.RequestListOfFolderImpls(); | 191 | List<InventoryFolderImpl> childFolders = inventoryFolder.RequestListOfFolderImpls(); |
192 | List<InventoryItemBase> items = inventoryFolder.RequestListOfItems(); | 192 | List<InventoryItemBase> items = inventoryFolder.RequestListOfItems(); |
193 | 193 | ||
194 | /* | 194 | /* |
195 | Dictionary identicalFolderNames = new Dictionary<string, int>(); | 195 | Dictionary identicalFolderNames = new Dictionary<string, int>(); |
196 | 196 | ||
197 | foreach (InventoryFolderImpl folder in inventories) | 197 | foreach (InventoryFolderImpl folder in inventories) |
198 | { | 198 | { |
199 | 199 | ||
200 | if (!identicalFolderNames.ContainsKey(folder.Name)) | 200 | if (!identicalFolderNames.ContainsKey(folder.Name)) |
201 | identicalFolderNames[folder.Name] = 0; | 201 | identicalFolderNames[folder.Name] = 0; |
202 | else | 202 | else |
203 | identicalFolderNames[folder.Name] = identicalFolderNames[folder.Name]++; | 203 | identicalFolderNames[folder.Name] = identicalFolderNames[folder.Name]++; |
204 | 204 | ||
205 | int folderNameNumber = identicalFolderName[folder.Name]; | 205 | int folderNameNumber = identicalFolderName[folder.Name]; |
206 | 206 | ||
207 | SaveInvDir( | 207 | SaveInvDir( |
208 | folder, | 208 | folder, |
209 | string.Format( | 209 | string.Format( |
210 | "{0}{1}{2}/", | 210 | "{0}{1}{2}/", |
211 | path, InventoryArchiveConstants.INVENTORY_NODE_NAME_COMPONENT_SEPARATOR, folderNameNumber)); | 211 | path, ArchiveConstants.INVENTORY_NODE_NAME_COMPONENT_SEPARATOR, folderNameNumber)); |
212 | } | 212 | } |
213 | */ | 213 | */ |
214 | 214 | ||
215 | foreach (InventoryFolderImpl childFolder in childFolders) | 215 | foreach (InventoryFolderImpl childFolder in childFolders) |
216 | { | 216 | { |
217 | SaveInvDir(childFolder, path); | 217 | SaveInvDir(childFolder, path); |
218 | } | 218 | } |
219 | 219 | ||
220 | foreach (InventoryItemBase item in items) | 220 | foreach (InventoryItemBase item in items) |
221 | { | 221 | { |
222 | SaveInvItem(item, path); | 222 | SaveInvItem(item, path); |
@@ -232,9 +232,9 @@ namespace OpenSim.Region.CoreModules.Avatar.Inventory.Archiver | |||
232 | InventoryItemBase inventoryItem = null; | 232 | InventoryItemBase inventoryItem = null; |
233 | 233 | ||
234 | if (!m_userInfo.HasReceivedInventory) | 234 | if (!m_userInfo.HasReceivedInventory) |
235 | { | 235 | { |
236 | // If the region server has access to the user admin service (by which users are created), | 236 | // If the region server has access to the user admin service (by which users are created), |
237 | // then we'll assume that it's okay to fiddle with the user's inventory even if they are not on the | 237 | // then we'll assume that it's okay to fiddle with the user's inventory even if they are not on the |
238 | // server. | 238 | // server. |
239 | // | 239 | // |
240 | // FIXME: FetchInventory should probably be assumed to by async anyway, since even standalones might | 240 | // FIXME: FetchInventory should probably be assumed to by async anyway, since even standalones might |
@@ -252,7 +252,7 @@ namespace OpenSim.Region.CoreModules.Avatar.Inventory.Archiver | |||
252 | m_userInfo.FetchInventory(); | 252 | m_userInfo.FetchInventory(); |
253 | } | 253 | } |
254 | } | 254 | } |
255 | 255 | ||
256 | // Eliminate double slashes and any leading / on the path. This might be better done within InventoryFolderImpl | 256 | // Eliminate double slashes and any leading / on the path. This might be better done within InventoryFolderImpl |
257 | // itself (possibly at a small loss in efficiency). | 257 | // itself (possibly at a small loss in efficiency). |
258 | string[] components | 258 | string[] components |
@@ -280,8 +280,8 @@ namespace OpenSim.Region.CoreModules.Avatar.Inventory.Archiver | |||
280 | { | 280 | { |
281 | inventoryItem = m_userInfo.RootFolder.FindItemByPath(m_invPath); | 281 | inventoryItem = m_userInfo.RootFolder.FindItemByPath(m_invPath); |
282 | } | 282 | } |
283 | 283 | ||
284 | m_archive = new TarArchiveWriter(m_saveStream); | 284 | m_archive = new TarArchiveWriter(m_saveStream); |
285 | 285 | ||
286 | if (null == inventoryFolder) | 286 | if (null == inventoryFolder) |
287 | { | 287 | { |
@@ -289,16 +289,16 @@ namespace OpenSim.Region.CoreModules.Avatar.Inventory.Archiver | |||
289 | { | 289 | { |
290 | m_saveStream.Close(); | 290 | m_saveStream.Close(); |
291 | m_module.TriggerInventoryArchiveSaved( | 291 | m_module.TriggerInventoryArchiveSaved( |
292 | false, m_userInfo, m_invPath, m_saveStream, | 292 | false, m_userInfo, m_invPath, m_saveStream, |
293 | new Exception(string.Format("Could not find inventory entry at path {0}", m_invPath))); | 293 | new Exception(string.Format("Could not find inventory entry at path {0}", m_invPath))); |
294 | return; | 294 | return; |
295 | } | 295 | } |
296 | else | 296 | else |
297 | { | 297 | { |
298 | m_log.DebugFormat( | 298 | m_log.DebugFormat( |
299 | "[INVENTORY ARCHIVER]: Found item {0} {1} at {2}", | 299 | "[INVENTORY ARCHIVER]: Found item {0} {1} at {2}", |
300 | inventoryItem.Name, inventoryItem.ID, m_invPath); | 300 | inventoryItem.Name, inventoryItem.ID, m_invPath); |
301 | 301 | ||
302 | //get and export item info | 302 | //get and export item info |
303 | SaveInvItem(inventoryItem, m_invPath); | 303 | SaveInvItem(inventoryItem, m_invPath); |
304 | } | 304 | } |
@@ -306,11 +306,11 @@ namespace OpenSim.Region.CoreModules.Avatar.Inventory.Archiver | |||
306 | else | 306 | else |
307 | { | 307 | { |
308 | m_log.DebugFormat( | 308 | m_log.DebugFormat( |
309 | "[INVENTORY ARCHIVER]: Found folder {0} {1} at {2}", | 309 | "[INVENTORY ARCHIVER]: Found folder {0} {1} at {2}", |
310 | inventoryFolder.Name, inventoryFolder.ID, m_invPath); | 310 | inventoryFolder.Name, inventoryFolder.ID, m_invPath); |
311 | 311 | ||
312 | //recurse through all dirs getting dirs and files | 312 | //recurse through all dirs getting dirs and files |
313 | SaveInvDir(inventoryFolder, InventoryArchiveConstants.INVENTORY_PATH); | 313 | SaveInvDir(inventoryFolder, ArchiveConstants.INVENTORY_PATH); |
314 | } | 314 | } |
315 | 315 | ||
316 | new AssetsRequest(assetUuids.Keys, m_module.CommsManager.AssetCache, ReceivedAllAssets).Execute(); | 316 | new AssetsRequest(assetUuids.Keys, m_module.CommsManager.AssetCache, ReceivedAllAssets).Execute(); |
diff --git a/OpenSim/Region/CoreModules/Avatar/Inventory/Archiver/Tests/InventoryArchiverTests.cs b/OpenSim/Region/CoreModules/Avatar/Inventory/Archiver/Tests/InventoryArchiverTests.cs index ef7f93f..ea72f08 100644 --- a/OpenSim/Region/CoreModules/Avatar/Inventory/Archiver/Tests/InventoryArchiverTests.cs +++ b/OpenSim/Region/CoreModules/Avatar/Inventory/Archiver/Tests/InventoryArchiverTests.cs | |||
@@ -53,31 +53,31 @@ namespace OpenSim.Region.CoreModules.Avatar.Inventory.Archiver.Tests | |||
53 | lock (this) | 53 | lock (this) |
54 | { | 54 | { |
55 | Monitor.PulseAll(this); | 55 | Monitor.PulseAll(this); |
56 | } | 56 | } |
57 | } | 57 | } |
58 | 58 | ||
59 | /// <summary> | 59 | /// <summary> |
60 | /// Test saving a V0.1 OpenSim Inventory Archive (subject to change since there is no fixed format yet). | 60 | /// Test saving a V0.1 OpenSim Inventory Archive (subject to change since there is no fixed format yet). |
61 | /// </summary> | 61 | /// </summary> |
62 | [Test] | 62 | [Test] |
63 | public void TestSaveIarV0p1() | 63 | public void TestSaveIarV0p1() |
64 | { | 64 | { |
65 | //log4net.Config.XmlConfigurator.Configure(); | 65 | //log4net.Config.XmlConfigurator.Configure(); |
66 | 66 | ||
67 | InventoryArchiverModule archiverModule = new InventoryArchiverModule(); | 67 | InventoryArchiverModule archiverModule = new InventoryArchiverModule(); |
68 | 68 | ||
69 | Scene scene = SceneSetupHelpers.SetupScene(); | 69 | Scene scene = SceneSetupHelpers.SetupScene(); |
70 | SceneSetupHelpers.SetupSceneModules(scene, archiverModule); | 70 | SceneSetupHelpers.SetupSceneModules(scene, archiverModule); |
71 | CommunicationsManager cm = scene.CommsManager; | 71 | CommunicationsManager cm = scene.CommsManager; |
72 | 72 | ||
73 | // Create user | 73 | // Create user |
74 | string userFirstName = "Jock"; | 74 | string userFirstName = "Jock"; |
75 | string userLastName = "Stirrup"; | 75 | string userLastName = "Stirrup"; |
76 | UUID userId = UUID.Parse("00000000-0000-0000-0000-000000000020"); | 76 | UUID userId = UUID.Parse("00000000-0000-0000-0000-000000000020"); |
77 | cm.UserAdminService.AddUser(userFirstName, userLastName, string.Empty, string.Empty, 1000, 1000, userId); | 77 | cm.UserAdminService.AddUser(userFirstName, userLastName, string.Empty, string.Empty, 1000, 1000, userId); |
78 | CachedUserInfo userInfo = cm.UserProfileCacheService.GetUserDetails(userId); | 78 | CachedUserInfo userInfo = cm.UserProfileCacheService.GetUserDetails(userId); |
79 | userInfo.FetchInventory(); | 79 | userInfo.FetchInventory(); |
80 | 80 | ||
81 | // Create asset | 81 | // Create asset |
82 | SceneObjectGroup object1; | 82 | SceneObjectGroup object1; |
83 | SceneObjectPart part1; | 83 | SceneObjectPart part1; |
@@ -88,81 +88,81 @@ namespace OpenSim.Region.CoreModules.Avatar.Inventory.Archiver.Tests | |||
88 | Vector3 groupPosition = new Vector3(10, 20, 30); | 88 | Vector3 groupPosition = new Vector3(10, 20, 30); |
89 | Quaternion rotationOffset = new Quaternion(20, 30, 40, 50); | 89 | Quaternion rotationOffset = new Quaternion(20, 30, 40, 50); |
90 | Vector3 offsetPosition = new Vector3(5, 10, 15); | 90 | Vector3 offsetPosition = new Vector3(5, 10, 15); |
91 | 91 | ||
92 | part1 | 92 | part1 |
93 | = new SceneObjectPart( | 93 | = new SceneObjectPart( |
94 | ownerId, shape, groupPosition, rotationOffset, offsetPosition); | 94 | ownerId, shape, groupPosition, rotationOffset, offsetPosition); |
95 | part1.Name = partName; | 95 | part1.Name = partName; |
96 | 96 | ||
97 | object1 = new SceneObjectGroup(part1); | 97 | object1 = new SceneObjectGroup(part1); |
98 | } | 98 | } |
99 | 99 | ||
100 | UUID asset1Id = UUID.Parse("00000000-0000-0000-0000-000000000060"); | 100 | UUID asset1Id = UUID.Parse("00000000-0000-0000-0000-000000000060"); |
101 | AssetBase asset1 = new AssetBase(); | 101 | AssetBase asset1 = new AssetBase(); |
102 | asset1.FullID = asset1Id; | 102 | asset1.FullID = asset1Id; |
103 | asset1.Data = Encoding.ASCII.GetBytes(object1.ToXmlString2()); | 103 | asset1.Data = Encoding.ASCII.GetBytes(object1.ToXmlString2()); |
104 | cm.AssetCache.AddAsset(asset1); | 104 | cm.AssetCache.AddAsset(asset1); |
105 | 105 | ||
106 | // Create item | 106 | // Create item |
107 | UUID item1Id = UUID.Parse("00000000-0000-0000-0000-000000000080"); | 107 | UUID item1Id = UUID.Parse("00000000-0000-0000-0000-000000000080"); |
108 | InventoryItemBase item1 = new InventoryItemBase(); | 108 | InventoryItemBase item1 = new InventoryItemBase(); |
109 | item1.Name = "My Little Dog"; | 109 | item1.Name = "My Little Dog"; |
110 | item1.AssetID = asset1.FullID; | 110 | item1.AssetID = asset1.FullID; |
111 | item1.ID = item1Id; | 111 | item1.ID = item1Id; |
112 | item1.Folder = userInfo.RootFolder.FindFolderByPath("Objects").ID; | 112 | item1.Folder = userInfo.RootFolder.FindFolderByPath("Objects").ID; |
113 | scene.AddInventoryItem(userId, item1); | 113 | scene.AddInventoryItem(userId, item1); |
114 | 114 | ||
115 | MemoryStream archiveWriteStream = new MemoryStream(); | 115 | MemoryStream archiveWriteStream = new MemoryStream(); |
116 | archiverModule.OnInventoryArchiveSaved += SaveCompleted; | 116 | archiverModule.OnInventoryArchiveSaved += SaveCompleted; |
117 | 117 | ||
118 | lock (this) | 118 | lock (this) |
119 | { | 119 | { |
120 | archiverModule.ArchiveInventory(userFirstName, userLastName, "Objects", archiveWriteStream); | 120 | archiverModule.ArchiveInventory(userFirstName, userLastName, "Objects", archiveWriteStream); |
121 | Monitor.Wait(this, 60000); | 121 | Monitor.Wait(this, 60000); |
122 | } | 122 | } |
123 | 123 | ||
124 | byte[] archive = archiveWriteStream.ToArray(); | 124 | byte[] archive = archiveWriteStream.ToArray(); |
125 | MemoryStream archiveReadStream = new MemoryStream(archive); | 125 | MemoryStream archiveReadStream = new MemoryStream(archive); |
126 | TarArchiveReader tar = new TarArchiveReader(archiveReadStream); | 126 | TarArchiveReader tar = new TarArchiveReader(archiveReadStream); |
127 | 127 | ||
128 | InventoryFolderImpl objectsFolder = userInfo.RootFolder.FindFolderByPath("Objects"); | 128 | InventoryFolderImpl objectsFolder = userInfo.RootFolder.FindFolderByPath("Objects"); |
129 | 129 | ||
130 | //bool gotControlFile = false; | 130 | //bool gotControlFile = false; |
131 | bool gotObject1File = false; | 131 | bool gotObject1File = false; |
132 | //bool gotObject2File = false; | 132 | //bool gotObject2File = false; |
133 | string expectedObject1FilePath = string.Format( | 133 | string expectedObject1FilePath = string.Format( |
134 | "{0}{1}/{2}_{3}.xml", | 134 | "{0}{1}/{2}_{3}.xml", |
135 | InventoryArchiveConstants.INVENTORY_PATH, | 135 | ArchiveConstants.INVENTORY_PATH, |
136 | string.Format( | 136 | string.Format( |
137 | "Objects{0}{1}", InventoryArchiveConstants.INVENTORY_NODE_NAME_COMPONENT_SEPARATOR, objectsFolder.ID), | 137 | "Objects{0}{1}", ArchiveConstants.INVENTORY_NODE_NAME_COMPONENT_SEPARATOR, objectsFolder.ID), |
138 | item1.Name, | 138 | item1.Name, |
139 | item1Id); | 139 | item1Id); |
140 | 140 | ||
141 | /* | 141 | /* |
142 | string expectedObject2FileName = string.Format( | 142 | string expectedObject2FileName = string.Format( |
143 | "{0}_{1:000}-{2:000}-{3:000}__{4}.xml", | 143 | "{0}_{1:000}-{2:000}-{3:000}__{4}.xml", |
144 | part2.Name, | 144 | part2.Name, |
145 | Math.Round(part2.GroupPosition.X), Math.Round(part2.GroupPosition.Y), Math.Round(part2.GroupPosition.Z), | 145 | Math.Round(part2.GroupPosition.X), Math.Round(part2.GroupPosition.Y), Math.Round(part2.GroupPosition.Z), |
146 | part2.UUID); | 146 | part2.UUID); |
147 | */ | 147 | */ |
148 | 148 | ||
149 | string filePath; | 149 | string filePath; |
150 | TarArchiveReader.TarEntryType tarEntryType; | 150 | TarArchiveReader.TarEntryType tarEntryType; |
151 | 151 | ||
152 | while (tar.ReadEntry(out filePath, out tarEntryType) != null) | 152 | while (tar.ReadEntry(out filePath, out tarEntryType) != null) |
153 | { | 153 | { |
154 | Console.WriteLine("Got {0}", filePath); | 154 | Console.WriteLine("Got {0}", filePath); |
155 | 155 | ||
156 | /* | 156 | /* |
157 | if (ArchiveConstants.CONTROL_FILE_PATH == filePath) | 157 | if (ArchiveConstants.CONTROL_FILE_PATH == filePath) |
158 | { | 158 | { |
159 | gotControlFile = true; | 159 | gotControlFile = true; |
160 | } | 160 | } |
161 | */ | 161 | */ |
162 | if (filePath.StartsWith(InventoryArchiveConstants.INVENTORY_PATH) && filePath.EndsWith(".xml")) | 162 | if (filePath.StartsWith(ArchiveConstants.INVENTORY_PATH) && filePath.EndsWith(".xml")) |
163 | { | 163 | { |
164 | //string fileName = filePath.Remove(0, "Objects/".Length); | 164 | //string fileName = filePath.Remove(0, "Objects/".Length); |
165 | 165 | ||
166 | //if (fileName.StartsWith(part1.Name)) | 166 | //if (fileName.StartsWith(part1.Name)) |
167 | //{ | 167 | //{ |
168 | Assert.That(filePath, Is.EqualTo(expectedObject1FilePath)); | 168 | Assert.That(filePath, Is.EqualTo(expectedObject1FilePath)); |
@@ -171,7 +171,7 @@ namespace OpenSim.Region.CoreModules.Avatar.Inventory.Archiver.Tests | |||
171 | //else if (fileName.StartsWith(part2.Name)) | 171 | //else if (fileName.StartsWith(part2.Name)) |
172 | //{ | 172 | //{ |
173 | // Assert.That(fileName, Is.EqualTo(expectedObject2FileName)); | 173 | // Assert.That(fileName, Is.EqualTo(expectedObject2FileName)); |
174 | // gotObject2File = true; | 174 | // gotObject2File = true; |
175 | //} | 175 | //} |
176 | } | 176 | } |
177 | } | 177 | } |
@@ -179,8 +179,8 @@ namespace OpenSim.Region.CoreModules.Avatar.Inventory.Archiver.Tests | |||
179 | //Assert.That(gotControlFile, Is.True, "No control file in archive"); | 179 | //Assert.That(gotControlFile, Is.True, "No control file in archive"); |
180 | Assert.That(gotObject1File, Is.True, "No item1 file in archive"); | 180 | Assert.That(gotObject1File, Is.True, "No item1 file in archive"); |
181 | //Assert.That(gotObject2File, Is.True, "No object2 file in archive"); | 181 | //Assert.That(gotObject2File, Is.True, "No object2 file in archive"); |
182 | 182 | ||
183 | // TODO: Test presence of more files and contents of files. | 183 | // TODO: Test presence of more files and contents of files. |
184 | } | 184 | } |
185 | } | 185 | } |
186 | } | 186 | } |
diff --git a/OpenSim/Region/CoreModules/World/Archiver/AssetsDearchiver.cs b/OpenSim/Region/CoreModules/World/Archiver/AssetsDearchiver.cs index cb267d7..67562a9 100644 --- a/OpenSim/Region/CoreModules/World/Archiver/AssetsDearchiver.cs +++ b/OpenSim/Region/CoreModules/World/Archiver/AssetsDearchiver.cs | |||
@@ -34,6 +34,7 @@ using System.Xml; | |||
34 | using log4net; | 34 | using log4net; |
35 | using OpenMetaverse; | 35 | using OpenMetaverse; |
36 | using OpenSim.Framework; | 36 | using OpenSim.Framework; |
37 | using OpenSim.Framework.Archive; | ||
37 | 38 | ||
38 | namespace OpenSim.Region.CoreModules.World.Archiver | 39 | namespace OpenSim.Region.CoreModules.World.Archiver |
39 | { | 40 | { |