diff --git a/OpenSim/Region/CoreModules/Avatar/Inventory/Archiver/InventoryArchiveReadRequest.cs b/OpenSim/Region/CoreModules/Avatar/Inventory/Archiver/InventoryArchiveReadRequest.cs index 1e21b743bf..3fd12887ed 100644 --- a/OpenSim/Region/CoreModules/Avatar/Inventory/Archiver/InventoryArchiveReadRequest.cs +++ b/OpenSim/Region/CoreModules/Avatar/Inventory/Archiver/InventoryArchiveReadRequest.cs @@ -503,9 +503,9 @@ namespace OpenSim.Region.CoreModules.Avatar.Inventory.Archiver //IRegionSerialiser serialiser = scene.RequestModuleInterface(); // Right now we're nastily obtaining the UUID from the filename string filename = assetPath.Remove(0, ArchiveConstants.ASSETS_PATH.Length); - int i = filename.LastIndexOf(ArchiveConstants.ASSET_EXTENSION_SEPARATOR); + int indx = filename.LastIndexOf(ArchiveConstants.ASSET_EXTENSION_SEPARATOR); - if (i == -1) + if (indx < 32) { m_log.ErrorFormat( "[INVENTORY ARCHIVER]: Could not find extension information in asset path {0} since it's missing the separator {1}. Skipping", @@ -514,11 +514,8 @@ namespace OpenSim.Region.CoreModules.Avatar.Inventory.Archiver return false; } - string extension = filename.Substring(i); - string rawUuid = filename.Remove(filename.Length - extension.Length); - UUID assetId = new UUID(rawUuid); - - if (!ArchiveConstants.EXTENSION_TO_ASSET_TYPE.ContainsKey(extension)) + string extension = filename.Substring(indx); + if (!ArchiveConstants.EXTENSION_TO_ASSET_TYPE.TryGetValue(extension, out sbyte assetType)) { m_log.ErrorFormat( "[INVENTORY ARCHIVER]: Tried to dearchive data with path {0} with an unknown type extension {1}", @@ -526,7 +523,10 @@ namespace OpenSim.Region.CoreModules.Avatar.Inventory.Archiver return false; } - sbyte assetType = ArchiveConstants.EXTENSION_TO_ASSET_TYPE[extension]; + string rawUuid = filename.Remove(indx); + if (!UUID.TryParse(rawUuid, out UUID assetId)) + return false; + if (assetType == (sbyte)AssetType.Unknown) { m_log.WarnFormat("[INVENTORY ARCHIVER]: Importing {0} byte asset {1} with unknown type", data.Length, assetId); diff --git a/OpenSim/Region/CoreModules/World/Archiver/ArchiveReadRequest.cs b/OpenSim/Region/CoreModules/World/Archiver/ArchiveReadRequest.cs index 568907b076..0dfaeebd7e 100644 --- a/OpenSim/Region/CoreModules/World/Archiver/ArchiveReadRequest.cs +++ b/OpenSim/Region/CoreModules/World/Archiver/ArchiveReadRequest.cs @@ -309,7 +309,7 @@ namespace OpenSim.Region.CoreModules.World.Archiver string filename = assetPath.Substring(ArchiveConstants.ASSETS_PATH.Length); int indx = filename.LastIndexOf(ArchiveConstants.ASSET_EXTENSION_SEPARATOR); - if (indx < 0) + if (indx < 32) { m_log.ErrorFormat( "[ARCHIVER]: Could not find extension information in asset path {0} since it's missing the separator {1}. Skipping", @@ -318,7 +318,7 @@ namespace OpenSim.Region.CoreModules.World.Archiver continue; } string extension = filename.Substring(indx); - if (ArchiveConstants.EXTENSION_TO_ASSET_TYPE.ContainsKey(extension)) + if (ArchiveConstants.EXTENSION_TO_ASSET_TYPE.TryGetValue(extension, out sbyte ext)) { string id = filename.Remove(indx); if (UUID.TryParse(id, out UUID uuid)) @@ -326,7 +326,7 @@ namespace OpenSim.Region.CoreModules.World.Archiver ids.Add(id); uuids.Add(uuid); datas.Add(data); - types.Add(ArchiveConstants.EXTENSION_TO_ASSET_TYPE[extension]); + types.Add(ext); continue; } } @@ -1061,8 +1061,9 @@ namespace OpenSim.Region.CoreModules.World.Archiver AssetBase asset = new AssetBase(assetID, string.Empty, assetType, UUID.Zero.ToString()); asset.Data = data; - m_assetService.Store(asset); - return true; // not right + //m_assetService.Store(asset); + //return true; // not right + return !string.IsNullOrEmpty(m_assetService.Store(asset)); } ///