diff options
author | Justin Clark-Casey (justincc) | 2014-12-20 01:46:32 +0000 |
---|---|---|
committer | Justin Clark-Casey (justincc) | 2014-12-20 01:46:32 +0000 |
commit | 9cff0bbd7c2d1743c252af000a712f4735f3141d (patch) | |
tree | 63660a285ee2b49cc3eaa210dc6b2294e7f4e700 /OpenSim/Region | |
parent | minor: Correct propery doc RestClient._resource spelling mistake (diff) | |
download | opensim-SC_OLD-9cff0bbd7c2d1743c252af000a712f4735f3141d.zip opensim-SC_OLD-9cff0bbd7c2d1743c252af000a712f4735f3141d.tar.gz opensim-SC_OLD-9cff0bbd7c2d1743c252af000a712f4735f3141d.tar.bz2 opensim-SC_OLD-9cff0bbd7c2d1743c252af000a712f4735f3141d.tar.xz |
In XBakesModule.Get() use using() to always dispose of RestClient which disposes the stream rather than disposing the stream directly
Diffstat (limited to 'OpenSim/Region')
-rw-r--r-- | OpenSim/Region/CoreModules/Avatar/BakedTextures/XBakesModule.cs | 66 |
1 files changed, 35 insertions, 31 deletions
diff --git a/OpenSim/Region/CoreModules/Avatar/BakedTextures/XBakesModule.cs b/OpenSim/Region/CoreModules/Avatar/BakedTextures/XBakesModule.cs index c6c54b2..7d2cad6 100644 --- a/OpenSim/Region/CoreModules/Avatar/BakedTextures/XBakesModule.cs +++ b/OpenSim/Region/CoreModules/Avatar/BakedTextures/XBakesModule.cs | |||
@@ -103,47 +103,51 @@ namespace OpenSim.Region.CoreModules.Avatar.BakedTextures | |||
103 | return null; | 103 | return null; |
104 | 104 | ||
105 | int size = 0; | 105 | int size = 0; |
106 | RestClient rc = new RestClient(m_URL); | ||
107 | List<WearableCacheItem> ret = new List<WearableCacheItem>(); | ||
108 | rc.AddResourcePath("bakes"); | ||
109 | rc.AddResourcePath(id.ToString()); | ||
110 | 106 | ||
111 | rc.RequestMethod = "GET"; | 107 | using (RestClient rc = new RestClient(m_URL)) |
112 | |||
113 | try | ||
114 | { | 108 | { |
115 | using (Stream s = rc.Request(m_Auth)) | 109 | List<WearableCacheItem> ret = new List<WearableCacheItem>(); |
116 | using (XmlTextReader sr = new XmlTextReader(s)) | 110 | rc.AddResourcePath("bakes"); |
111 | rc.AddResourcePath(id.ToString()); | ||
112 | |||
113 | rc.RequestMethod = "GET"; | ||
114 | |||
115 | try | ||
117 | { | 116 | { |
118 | sr.ReadStartElement("BakedAppearance"); | 117 | Stream s = rc.Request(m_Auth); |
119 | while (sr.LocalName == "BakedTexture") | 118 | |
119 | using (XmlTextReader sr = new XmlTextReader(s)) | ||
120 | { | 120 | { |
121 | string sTextureIndex = sr.GetAttribute("TextureIndex"); | 121 | sr.ReadStartElement("BakedAppearance"); |
122 | int lTextureIndex = Convert.ToInt32(sTextureIndex); | 122 | while (sr.LocalName == "BakedTexture") |
123 | string sCacheId = sr.GetAttribute("CacheId"); | ||
124 | UUID lCacheId = UUID.Zero; | ||
125 | if (!(UUID.TryParse(sCacheId, out lCacheId))) | ||
126 | { | 123 | { |
127 | // ?? Nothing here | 124 | string sTextureIndex = sr.GetAttribute("TextureIndex"); |
125 | int lTextureIndex = Convert.ToInt32(sTextureIndex); | ||
126 | string sCacheId = sr.GetAttribute("CacheId"); | ||
127 | UUID lCacheId = UUID.Zero; | ||
128 | if (!(UUID.TryParse(sCacheId, out lCacheId))) | ||
129 | { | ||
130 | // ?? Nothing here | ||
131 | } | ||
132 | |||
133 | ++size; | ||
134 | |||
135 | sr.ReadStartElement("BakedTexture"); | ||
136 | AssetBase a = (AssetBase)m_serializer.Deserialize(sr); | ||
137 | ret.Add(new WearableCacheItem() { CacheId = lCacheId, TextureIndex = (uint)lTextureIndex, TextureAsset = a, TextureID = a.FullID }); | ||
138 | |||
139 | sr.ReadEndElement(); | ||
128 | } | 140 | } |
129 | 141 | ||
130 | ++size; | 142 | m_log.DebugFormat("[XBakes]: read {0} textures for user {1}", ret.Count, id); |
131 | |||
132 | sr.ReadStartElement("BakedTexture"); | ||
133 | AssetBase a = (AssetBase)m_serializer.Deserialize(sr); | ||
134 | ret.Add(new WearableCacheItem() { CacheId = lCacheId, TextureIndex = (uint)lTextureIndex, TextureAsset = a, TextureID = a.FullID }); | ||
135 | |||
136 | sr.ReadEndElement(); | ||
137 | } | 143 | } |
138 | 144 | ||
139 | m_log.DebugFormat("[XBakes]: read {0} textures for user {1}", ret.Count, id); | 145 | return ret.ToArray(); |
146 | } | ||
147 | catch (XmlException) | ||
148 | { | ||
149 | return null; | ||
140 | } | 150 | } |
141 | |||
142 | return ret.ToArray(); | ||
143 | } | ||
144 | catch (XmlException) | ||
145 | { | ||
146 | return null; | ||
147 | } | 151 | } |
148 | } | 152 | } |
149 | 153 | ||