diff options
Diffstat (limited to 'OpenSim/Framework/Communications/Cache')
-rw-r--r-- | OpenSim/Framework/Communications/Cache/AssetServer.cs | 786 | ||||
-rw-r--r-- | OpenSim/Framework/Communications/Cache/SQLAssetServer.cs | 34 |
2 files changed, 410 insertions, 410 deletions
diff --git a/OpenSim/Framework/Communications/Cache/AssetServer.cs b/OpenSim/Framework/Communications/Cache/AssetServer.cs index 8c63b30..e5329ec 100644 --- a/OpenSim/Framework/Communications/Cache/AssetServer.cs +++ b/OpenSim/Framework/Communications/Cache/AssetServer.cs | |||
@@ -1,393 +1,393 @@ | |||
1 | /* | 1 | /* |
2 | * Copyright (c) Contributors, http://opensimulator.org/ | 2 | * Copyright (c) Contributors, http://opensimulator.org/ |
3 | * See CONTRIBUTORS.TXT for a full list of copyright holders. | 3 | * See CONTRIBUTORS.TXT for a full list of copyright holders. |
4 | * | 4 | * |
5 | * Redistribution and use in source and binary forms, with or without | 5 | * Redistribution and use in source and binary forms, with or without |
6 | * modification, are permitted provided that the following conditions are met: | 6 | * modification, are permitted provided that the following conditions are met: |
7 | * * Redistributions of source code must retain the above copyright | 7 | * * Redistributions of source code must retain the above copyright |
8 | * notice, this list of conditions and the following disclaimer. | 8 | * notice, this list of conditions and the following disclaimer. |
9 | * * Redistributions in binary form must reproduce the above copyright | 9 | * * Redistributions in binary form must reproduce the above copyright |
10 | * notice, this list of conditions and the following disclaimer in the | 10 | * notice, this list of conditions and the following disclaimer in the |
11 | * documentation and/or other materials provided with the distribution. | 11 | * documentation and/or other materials provided with the distribution. |
12 | * * Neither the name of the OpenSim Project nor the | 12 | * * Neither the name of the OpenSim Project nor the |
13 | * names of its contributors may be used to endorse or promote products | 13 | * names of its contributors may be used to endorse or promote products |
14 | * derived from this software without specific prior written permission. | 14 | * derived from this software without specific prior written permission. |
15 | * | 15 | * |
16 | * THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS AND ANY | 16 | * THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS AND ANY |
17 | * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED | 17 | * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED |
18 | * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE | 18 | * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE |
19 | * DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY | 19 | * DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY |
20 | * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES | 20 | * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES |
21 | * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; | 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 | 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 | 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 | 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. | 25 | * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
26 | * | 26 | * |
27 | */ | 27 | */ |
28 | using System; | 28 | using System; |
29 | using System.IO; | 29 | using System.IO; |
30 | using System.Threading; | 30 | using System.Threading; |
31 | using Db4objects.Db4o; | 31 | using Db4objects.Db4o; |
32 | using Db4objects.Db4o.Query; | 32 | using Db4objects.Db4o.Query; |
33 | using libsecondlife; | 33 | using libsecondlife; |
34 | using Nini.Config; | 34 | using Nini.Config; |
35 | using OpenSim.Framework.Console; | 35 | using OpenSim.Framework.Console; |
36 | using OpenSim.Framework.Interfaces; | 36 | using OpenSim.Framework.Interfaces; |
37 | using OpenSim.Framework.Types; | 37 | using OpenSim.Framework.Types; |
38 | using OpenSim.Framework.Utilities; | 38 | using OpenSim.Framework.Utilities; |
39 | 39 | ||
40 | namespace OpenSim.Framework.Communications.Caches | 40 | namespace OpenSim.Framework.Communications.Caches |
41 | { | 41 | { |
42 | 42 | ||
43 | public class LocalAssetServer : IAssetServer | 43 | public class LocalAssetServer : IAssetServer |
44 | { | 44 | { |
45 | private IAssetReceiver _receiver; | 45 | private IAssetReceiver _receiver; |
46 | private BlockingQueue<ARequest> _assetRequests; | 46 | private BlockingQueue<ARequest> _assetRequests; |
47 | private IObjectContainer db; | 47 | private IObjectContainer db; |
48 | private Thread _localAssetServerThread; | 48 | private Thread _localAssetServerThread; |
49 | 49 | ||
50 | public LocalAssetServer() | 50 | public LocalAssetServer() |
51 | { | 51 | { |
52 | System.Console.WriteLine("Starting Db4o asset storage system"); | 52 | System.Console.WriteLine("Starting Db4o asset storage system"); |
53 | bool yapfile; | 53 | bool yapfile; |
54 | this._assetRequests = new BlockingQueue<ARequest>(); | 54 | this._assetRequests = new BlockingQueue<ARequest>(); |
55 | yapfile = File.Exists(Path.Combine(Util.dataDir(), "regionassets.yap")); | 55 | yapfile = File.Exists(Path.Combine(Util.dataDir(), "regionassets.yap")); |
56 | 56 | ||
57 | MainLog.Instance.Verbose("Local Asset Server class created"); | 57 | MainLog.Instance.Verbose("Local Asset Server class created"); |
58 | db = Db4oFactory.OpenFile(Path.Combine(Util.dataDir(), "regionassets.yap")); | 58 | db = Db4oFactory.OpenFile(Path.Combine(Util.dataDir(), "regionassets.yap")); |
59 | MainLog.Instance.Verbose("Db4 Asset database creation"); | 59 | MainLog.Instance.Verbose("Db4 Asset database creation"); |
60 | 60 | ||
61 | if (!yapfile) | 61 | if (!yapfile) |
62 | { | 62 | { |
63 | this.SetUpAssetDatabase(); | 63 | this.SetUpAssetDatabase(); |
64 | } | 64 | } |
65 | 65 | ||
66 | this._localAssetServerThread = new Thread(new ThreadStart(RunRequests)); | 66 | this._localAssetServerThread = new Thread(new ThreadStart(RunRequests)); |
67 | this._localAssetServerThread.IsBackground = true; | 67 | this._localAssetServerThread.IsBackground = true; |
68 | this._localAssetServerThread.Start(); | 68 | this._localAssetServerThread.Start(); |
69 | 69 | ||
70 | } | 70 | } |
71 | 71 | ||
72 | public void SetReceiver(IAssetReceiver receiver) | 72 | public void SetReceiver(IAssetReceiver receiver) |
73 | { | 73 | { |
74 | this._receiver = receiver; | 74 | this._receiver = receiver; |
75 | } | 75 | } |
76 | 76 | ||
77 | public void FetchAsset(LLUUID assetID, bool isTexture) | 77 | public void FetchAsset(LLUUID assetID, bool isTexture) |
78 | { | 78 | { |
79 | ARequest req = new ARequest(); | 79 | ARequest req = new ARequest(); |
80 | req.AssetID = assetID; | 80 | req.AssetID = assetID; |
81 | req.IsTexture = isTexture; | 81 | req.IsTexture = isTexture; |
82 | this._assetRequests.Enqueue(req); | 82 | this._assetRequests.Enqueue(req); |
83 | } | 83 | } |
84 | 84 | ||
85 | public void UpdateAsset(AssetBase asset) | 85 | public void UpdateAsset(AssetBase asset) |
86 | { | 86 | { |
87 | 87 | ||
88 | } | 88 | } |
89 | 89 | ||
90 | public void CreateAsset(AssetBase asset) | 90 | public void CreateAsset(AssetBase asset) |
91 | { | 91 | { |
92 | AssetStorage store = new AssetStorage(); | 92 | AssetStorage store = new AssetStorage(); |
93 | store.Data = asset.Data; | 93 | store.Data = asset.Data; |
94 | store.Name = asset.Name; | 94 | store.Name = asset.Name; |
95 | store.UUID = asset.FullID; | 95 | store.UUID = asset.FullID; |
96 | db.Set(store); | 96 | db.Set(store); |
97 | db.Commit(); | 97 | db.Commit(); |
98 | } | 98 | } |
99 | 99 | ||
100 | public void SetServerInfo(string ServerUrl, string ServerKey) | 100 | public void SetServerInfo(string ServerUrl, string ServerKey) |
101 | { | 101 | { |
102 | 102 | ||
103 | } | 103 | } |
104 | public void Close() | 104 | public void Close() |
105 | { | 105 | { |
106 | if (db != null) | 106 | if (db != null) |
107 | { | 107 | { |
108 | MainLog.Instance.Verbose("Closing local asset server database"); | 108 | MainLog.Instance.Verbose("Closing local asset server database"); |
109 | db.Close(); | 109 | db.Close(); |
110 | } | 110 | } |
111 | } | 111 | } |
112 | 112 | ||
113 | private void RunRequests() | 113 | private void RunRequests() |
114 | { | 114 | { |
115 | while (true) | 115 | while (true) |
116 | { | 116 | { |
117 | byte[] idata = null; | 117 | byte[] idata = null; |
118 | bool found = false; | 118 | bool found = false; |
119 | AssetStorage foundAsset = null; | 119 | AssetStorage foundAsset = null; |
120 | ARequest req = this._assetRequests.Dequeue(); | 120 | ARequest req = this._assetRequests.Dequeue(); |
121 | IObjectSet result = db.Query(new AssetUUIDQuery(req.AssetID)); | 121 | IObjectSet result = db.Query(new AssetUUIDQuery(req.AssetID)); |
122 | if (result.Count > 0) | 122 | if (result.Count > 0) |
123 | { | 123 | { |
124 | foundAsset = (AssetStorage)result.Next(); | 124 | foundAsset = (AssetStorage)result.Next(); |
125 | found = true; | 125 | found = true; |
126 | } | 126 | } |
127 | 127 | ||
128 | AssetBase asset = new AssetBase(); | 128 | AssetBase asset = new AssetBase(); |
129 | if (found) | 129 | if (found) |
130 | { | 130 | { |
131 | asset.FullID = foundAsset.UUID; | 131 | asset.FullID = foundAsset.UUID; |
132 | asset.Type = foundAsset.Type; | 132 | asset.Type = foundAsset.Type; |
133 | asset.InvType = foundAsset.Type; | 133 | asset.InvType = foundAsset.Type; |
134 | asset.Name = foundAsset.Name; | 134 | asset.Name = foundAsset.Name; |
135 | idata = foundAsset.Data; | 135 | idata = foundAsset.Data; |
136 | asset.Data = idata; | 136 | asset.Data = idata; |
137 | _receiver.AssetReceived(asset, req.IsTexture); | 137 | _receiver.AssetReceived(asset, req.IsTexture); |
138 | } | 138 | } |
139 | else | 139 | else |
140 | { | 140 | { |
141 | //asset.FullID = ; | 141 | //asset.FullID = ; |
142 | _receiver.AssetNotFound(req.AssetID); | 142 | _receiver.AssetNotFound(req.AssetID); |
143 | } | 143 | } |
144 | 144 | ||
145 | } | 145 | } |
146 | 146 | ||
147 | } | 147 | } |
148 | 148 | ||
149 | private void SetUpAssetDatabase() | 149 | private void SetUpAssetDatabase() |
150 | { | 150 | { |
151 | MainLog.Instance.Verbose("Setting up asset database"); | 151 | MainLog.Instance.Verbose("Setting up asset database"); |
152 | 152 | ||
153 | AssetBase Image = new AssetBase(); | 153 | AssetBase Image = new AssetBase(); |
154 | Image.FullID = new LLUUID("00000000-0000-0000-9999-000000000001"); | 154 | Image.FullID = new LLUUID("00000000-0000-0000-9999-000000000001"); |
155 | Image.Name = "Bricks"; | 155 | Image.Name = "Bricks"; |
156 | this.LoadAsset(Image, true, "bricks.jp2"); | 156 | this.LoadAsset(Image, true, "bricks.jp2"); |
157 | AssetStorage store = new AssetStorage(); | 157 | AssetStorage store = new AssetStorage(); |
158 | store.Data = Image.Data; | 158 | store.Data = Image.Data; |
159 | store.Name = Image.Name; | 159 | store.Name = Image.Name; |
160 | store.UUID = Image.FullID; | 160 | store.UUID = Image.FullID; |
161 | db.Set(store); | 161 | db.Set(store); |
162 | db.Commit(); | 162 | db.Commit(); |
163 | 163 | ||
164 | Image = new AssetBase(); | 164 | Image = new AssetBase(); |
165 | Image.FullID = new LLUUID("00000000-0000-0000-9999-000000000002"); | 165 | Image.FullID = new LLUUID("00000000-0000-0000-9999-000000000002"); |
166 | Image.Name = "Plywood"; | 166 | Image.Name = "Plywood"; |
167 | this.LoadAsset(Image, true, "plywood.jp2"); | 167 | this.LoadAsset(Image, true, "plywood.jp2"); |
168 | store = new AssetStorage(); | 168 | store = new AssetStorage(); |
169 | store.Data = Image.Data; | 169 | store.Data = Image.Data; |
170 | store.Name = Image.Name; | 170 | store.Name = Image.Name; |
171 | store.UUID = Image.FullID; | 171 | store.UUID = Image.FullID; |
172 | db.Set(store); | 172 | db.Set(store); |
173 | db.Commit(); | 173 | db.Commit(); |
174 | 174 | ||
175 | Image = new AssetBase(); | 175 | Image = new AssetBase(); |
176 | Image.FullID = new LLUUID("00000000-0000-0000-9999-000000000003"); | 176 | Image.FullID = new LLUUID("00000000-0000-0000-9999-000000000003"); |
177 | Image.Name = "Rocks"; | 177 | Image.Name = "Rocks"; |
178 | this.LoadAsset(Image, true, "rocks.jp2"); | 178 | this.LoadAsset(Image, true, "rocks.jp2"); |
179 | store = new AssetStorage(); | 179 | store = new AssetStorage(); |
180 | store.Data = Image.Data; | 180 | store.Data = Image.Data; |
181 | store.Name = Image.Name; | 181 | store.Name = Image.Name; |
182 | store.UUID = Image.FullID; | 182 | store.UUID = Image.FullID; |
183 | db.Set(store); | 183 | db.Set(store); |
184 | db.Commit(); | 184 | db.Commit(); |
185 | 185 | ||
186 | Image = new AssetBase(); | 186 | Image = new AssetBase(); |
187 | Image.FullID = new LLUUID("00000000-0000-0000-9999-000000000004"); | 187 | Image.FullID = new LLUUID("00000000-0000-0000-9999-000000000004"); |
188 | Image.Name = "Granite"; | 188 | Image.Name = "Granite"; |
189 | this.LoadAsset(Image, true, "granite.jp2"); | 189 | this.LoadAsset(Image, true, "granite.jp2"); |
190 | store = new AssetStorage(); | 190 | store = new AssetStorage(); |
191 | store.Data = Image.Data; | 191 | store.Data = Image.Data; |
192 | store.Name = Image.Name; | 192 | store.Name = Image.Name; |
193 | store.UUID = Image.FullID; | 193 | store.UUID = Image.FullID; |
194 | db.Set(store); | 194 | db.Set(store); |
195 | db.Commit(); | 195 | db.Commit(); |
196 | 196 | ||
197 | Image = new AssetBase(); | 197 | Image = new AssetBase(); |
198 | Image.FullID = new LLUUID("00000000-0000-0000-9999-000000000005"); | 198 | Image.FullID = new LLUUID("00000000-0000-0000-9999-000000000005"); |
199 | Image.Name = "Hardwood"; | 199 | Image.Name = "Hardwood"; |
200 | this.LoadAsset(Image, true, "hardwood.jp2"); | 200 | this.LoadAsset(Image, true, "hardwood.jp2"); |
201 | store = new AssetStorage(); | 201 | store = new AssetStorage(); |
202 | store.Data = Image.Data; | 202 | store.Data = Image.Data; |
203 | store.Name = Image.Name; | 203 | store.Name = Image.Name; |
204 | store.UUID = Image.FullID; | 204 | store.UUID = Image.FullID; |
205 | db.Set(store); | 205 | db.Set(store); |
206 | db.Commit(); | 206 | db.Commit(); |
207 | 207 | ||
208 | Image = new AssetBase(); | 208 | Image = new AssetBase(); |
209 | Image.FullID = new LLUUID("00000000-0000-0000-5005-000000000005"); | 209 | Image.FullID = new LLUUID("00000000-0000-0000-5005-000000000005"); |
210 | Image.Name = "Prim Base Texture"; | 210 | Image.Name = "Prim Base Texture"; |
211 | this.LoadAsset(Image, true, "plywood.jp2"); | 211 | this.LoadAsset(Image, true, "plywood.jp2"); |
212 | store = new AssetStorage(); | 212 | store = new AssetStorage(); |
213 | store.Data = Image.Data; | 213 | store.Data = Image.Data; |
214 | store.Name = Image.Name; | 214 | store.Name = Image.Name; |
215 | store.UUID = Image.FullID; | 215 | store.UUID = Image.FullID; |
216 | db.Set(store); | 216 | db.Set(store); |
217 | db.Commit(); | 217 | db.Commit(); |
218 | 218 | ||
219 | Image = new AssetBase(); | 219 | Image = new AssetBase(); |
220 | Image.FullID = new LLUUID("00000000-0000-0000-9999-000000000006"); | 220 | Image.FullID = new LLUUID("00000000-0000-0000-9999-000000000006"); |
221 | Image.Name = "Map Base Texture"; | 221 | Image.Name = "Map Base Texture"; |
222 | this.LoadAsset(Image, true, "map_base.jp2"); | 222 | this.LoadAsset(Image, true, "map_base.jp2"); |
223 | store = new AssetStorage(); | 223 | store = new AssetStorage(); |
224 | store.Data = Image.Data; | 224 | store.Data = Image.Data; |
225 | store.Name = Image.Name; | 225 | store.Name = Image.Name; |
226 | store.UUID = Image.FullID; | 226 | store.UUID = Image.FullID; |
227 | db.Set(store); | 227 | db.Set(store); |
228 | db.Commit(); | 228 | db.Commit(); |
229 | 229 | ||
230 | Image = new AssetBase(); | 230 | Image = new AssetBase(); |
231 | Image.FullID = new LLUUID("00000000-0000-0000-9999-000000000007"); | 231 | Image.FullID = new LLUUID("00000000-0000-0000-9999-000000000007"); |
232 | Image.Name = "Map Texture"; | 232 | Image.Name = "Map Texture"; |
233 | this.LoadAsset(Image, true, "map1.jp2"); | 233 | this.LoadAsset(Image, true, "map1.jp2"); |
234 | store = new AssetStorage(); | 234 | store = new AssetStorage(); |
235 | store.Data = Image.Data; | 235 | store.Data = Image.Data; |
236 | store.Name = Image.Name; | 236 | store.Name = Image.Name; |
237 | store.UUID = Image.FullID; | 237 | store.UUID = Image.FullID; |
238 | db.Set(store); | 238 | db.Set(store); |
239 | db.Commit(); | 239 | db.Commit(); |
240 | 240 | ||
241 | Image = new AssetBase(); | 241 | Image = new AssetBase(); |
242 | Image.FullID = new LLUUID("00000000-0000-1111-9999-000000000010"); | 242 | Image.FullID = new LLUUID("00000000-0000-1111-9999-000000000010"); |
243 | Image.Name = "Female Body Texture"; | 243 | Image.Name = "Female Body Texture"; |
244 | this.LoadAsset(Image, true, "femalebody.jp2"); | 244 | this.LoadAsset(Image, true, "femalebody.jp2"); |
245 | store = new AssetStorage(); | 245 | store = new AssetStorage(); |
246 | store.Data = Image.Data; | 246 | store.Data = Image.Data; |
247 | store.Name = Image.Name; | 247 | store.Name = Image.Name; |
248 | store.UUID = Image.FullID; | 248 | store.UUID = Image.FullID; |
249 | db.Set(store); | 249 | db.Set(store); |
250 | db.Commit(); | 250 | db.Commit(); |
251 | 251 | ||
252 | Image = new AssetBase(); | 252 | Image = new AssetBase(); |
253 | Image.FullID = new LLUUID("00000000-0000-1111-9999-000000000011"); | 253 | Image.FullID = new LLUUID("00000000-0000-1111-9999-000000000011"); |
254 | Image.Name = "Female Bottom Texture"; | 254 | Image.Name = "Female Bottom Texture"; |
255 | this.LoadAsset(Image, true, "femalebottom.jp2"); | 255 | this.LoadAsset(Image, true, "femalebottom.jp2"); |
256 | store = new AssetStorage(); | 256 | store = new AssetStorage(); |
257 | store.Data = Image.Data; | 257 | store.Data = Image.Data; |
258 | store.Name = Image.Name; | 258 | store.Name = Image.Name; |
259 | store.UUID = Image.FullID; | 259 | store.UUID = Image.FullID; |
260 | db.Set(store); | 260 | db.Set(store); |
261 | db.Commit(); | 261 | db.Commit(); |
262 | 262 | ||
263 | Image = new AssetBase(); | 263 | Image = new AssetBase(); |
264 | Image.FullID = new LLUUID("00000000-0000-1111-9999-000000000012"); | 264 | Image.FullID = new LLUUID("00000000-0000-1111-9999-000000000012"); |
265 | Image.Name = "Female Face Texture"; | 265 | Image.Name = "Female Face Texture"; |
266 | this.LoadAsset(Image, true, "femaleface.jp2"); | 266 | this.LoadAsset(Image, true, "femaleface.jp2"); |
267 | store = new AssetStorage(); | 267 | store = new AssetStorage(); |
268 | store.Data = Image.Data; | 268 | store.Data = Image.Data; |
269 | store.Name = Image.Name; | 269 | store.Name = Image.Name; |
270 | store.UUID = Image.FullID; | 270 | store.UUID = Image.FullID; |
271 | db.Set(store); | 271 | db.Set(store); |
272 | db.Commit(); | 272 | db.Commit(); |
273 | 273 | ||
274 | Image = new AssetBase(); | 274 | Image = new AssetBase(); |
275 | Image.FullID = new LLUUID("77c41e39-38f9-f75a-024e-585989bbabbb"); | 275 | Image.FullID = new LLUUID("77c41e39-38f9-f75a-024e-585989bbabbb"); |
276 | Image.Name = "Skin"; | 276 | Image.Name = "Skin"; |
277 | Image.Type = 13; | 277 | Image.Type = 13; |
278 | Image.InvType = 13; | 278 | Image.InvType = 13; |
279 | this.LoadAsset(Image, false, "base_skin.dat"); | 279 | this.LoadAsset(Image, false, "base_skin.dat"); |
280 | store = new AssetStorage(); | 280 | store = new AssetStorage(); |
281 | store.Data = Image.Data; | 281 | store.Data = Image.Data; |
282 | store.Name = Image.Name; | 282 | store.Name = Image.Name; |
283 | store.UUID = Image.FullID; | 283 | store.UUID = Image.FullID; |
284 | db.Set(store); | 284 | db.Set(store); |
285 | db.Commit(); | 285 | db.Commit(); |
286 | 286 | ||
287 | 287 | ||
288 | Image = new AssetBase(); | 288 | Image = new AssetBase(); |
289 | Image.FullID = new LLUUID("66c41e39-38f9-f75a-024e-585989bfab73"); | 289 | Image.FullID = new LLUUID("66c41e39-38f9-f75a-024e-585989bfab73"); |
290 | Image.Name = "Shape"; | 290 | Image.Name = "Shape"; |
291 | Image.Type = 13; | 291 | Image.Type = 13; |
292 | Image.InvType = 13; | 292 | Image.InvType = 13; |
293 | this.LoadAsset(Image, false, "base_shape.dat"); | 293 | this.LoadAsset(Image, false, "base_shape.dat"); |
294 | store = new AssetStorage(); | 294 | store = new AssetStorage(); |
295 | store.Data = Image.Data; | 295 | store.Data = Image.Data; |
296 | store.Name = Image.Name; | 296 | store.Name = Image.Name; |
297 | store.UUID = Image.FullID; | 297 | store.UUID = Image.FullID; |
298 | db.Set(store); | 298 | db.Set(store); |
299 | db.Commit(); | 299 | db.Commit(); |
300 | 300 | ||
301 | Image = new AssetBase(); | 301 | Image = new AssetBase(); |
302 | Image.FullID = new LLUUID("00000000-38f9-1111-024e-222222111110"); | 302 | Image.FullID = new LLUUID("00000000-38f9-1111-024e-222222111110"); |
303 | Image.Name = "Shirt"; | 303 | Image.Name = "Shirt"; |
304 | Image.Type = 5; | 304 | Image.Type = 5; |
305 | Image.InvType = 18; | 305 | Image.InvType = 18; |
306 | this.LoadAsset(Image, false, "newshirt.dat"); | 306 | this.LoadAsset(Image, false, "newshirt.dat"); |
307 | store = new AssetStorage(); | 307 | store = new AssetStorage(); |
308 | store.Data = Image.Data; | 308 | store.Data = Image.Data; |
309 | store.Name = Image.Name; | 309 | store.Name = Image.Name; |
310 | store.UUID = Image.FullID; | 310 | store.UUID = Image.FullID; |
311 | db.Set(store); | 311 | db.Set(store); |
312 | db.Commit(); | 312 | db.Commit(); |
313 | 313 | ||
314 | Image = new AssetBase(); | 314 | Image = new AssetBase(); |
315 | Image.FullID = new LLUUID("00000000-38f9-1111-024e-222222111120"); | 315 | Image.FullID = new LLUUID("00000000-38f9-1111-024e-222222111120"); |
316 | Image.Name = "Shirt"; | 316 | Image.Name = "Shirt"; |
317 | Image.Type = 5; | 317 | Image.Type = 5; |
318 | Image.InvType = 18; | 318 | Image.InvType = 18; |
319 | this.LoadAsset(Image, false, "newpants.dat"); | 319 | this.LoadAsset(Image, false, "newpants.dat"); |
320 | store = new AssetStorage(); | 320 | store = new AssetStorage(); |
321 | store.Data = Image.Data; | 321 | store.Data = Image.Data; |
322 | store.Name = Image.Name; | 322 | store.Name = Image.Name; |
323 | store.UUID = Image.FullID; | 323 | store.UUID = Image.FullID; |
324 | db.Set(store); | 324 | db.Set(store); |
325 | db.Commit(); | 325 | db.Commit(); |
326 | 326 | ||
327 | string filePath = Path.Combine(Util.configDir(), "OpenSimAssetSet.xml"); | 327 | string filePath = Path.Combine(Util.configDir(), "OpenSimAssetSet.xml"); |
328 | if (File.Exists(filePath)) | 328 | if (File.Exists(filePath)) |
329 | { | 329 | { |
330 | XmlConfigSource source = new XmlConfigSource(filePath); | 330 | XmlConfigSource source = new XmlConfigSource(filePath); |
331 | ReadAssetDetails(source); | 331 | ReadAssetDetails(source); |
332 | } | 332 | } |
333 | } | 333 | } |
334 | 334 | ||
335 | protected void ReadAssetDetails(IConfigSource source) | 335 | protected void ReadAssetDetails(IConfigSource source) |
336 | { | 336 | { |
337 | AssetBase newAsset = null; | 337 | AssetBase newAsset = null; |
338 | for (int i = 0; i < source.Configs.Count; i++) | 338 | for (int i = 0; i < source.Configs.Count; i++) |
339 | { | 339 | { |
340 | newAsset = new AssetBase(); | 340 | newAsset = new AssetBase(); |
341 | newAsset.FullID = new LLUUID(source.Configs[i].GetString("assetID", LLUUID.Random().ToStringHyphenated())); | 341 | newAsset.FullID = new LLUUID(source.Configs[i].GetString("assetID", LLUUID.Random().ToStringHyphenated())); |
342 | newAsset.Name = source.Configs[i].GetString("name", ""); | 342 | newAsset.Name = source.Configs[i].GetString("name", ""); |
343 | newAsset.Type = (sbyte)source.Configs[i].GetInt("assetType", 0); | 343 | newAsset.Type = (sbyte)source.Configs[i].GetInt("assetType", 0); |
344 | newAsset.InvType = (sbyte)source.Configs[i].GetInt("inventoryType", 0); | 344 | newAsset.InvType = (sbyte)source.Configs[i].GetInt("inventoryType", 0); |
345 | string fileName = source.Configs[i].GetString("fileName", ""); | 345 | string fileName = source.Configs[i].GetString("fileName", ""); |
346 | if (fileName != "") | 346 | if (fileName != "") |
347 | { | 347 | { |
348 | this.LoadAsset(newAsset, false, fileName); | 348 | this.LoadAsset(newAsset, false, fileName); |
349 | AssetStorage store = new AssetStorage(); | 349 | AssetStorage store = new AssetStorage(); |
350 | store.Data = newAsset.Data; | 350 | store.Data = newAsset.Data; |
351 | store.Name = newAsset.Name; | 351 | store.Name = newAsset.Name; |
352 | store.UUID = newAsset.FullID; | 352 | store.UUID = newAsset.FullID; |
353 | db.Set(store); | 353 | db.Set(store); |
354 | db.Commit(); | 354 | db.Commit(); |
355 | } | 355 | } |
356 | } | 356 | } |
357 | } | 357 | } |
358 | 358 | ||
359 | private void LoadAsset(AssetBase info, bool image, string filename) | 359 | private void LoadAsset(AssetBase info, bool image, string filename) |
360 | { | 360 | { |
361 | //should request Asset from storage manager | 361 | //should request Asset from storage manager |
362 | //but for now read from file | 362 | //but for now read from file |
363 | 363 | ||
364 | string dataPath = Path.Combine(AppDomain.CurrentDomain.BaseDirectory, "assets"); //+ folder; | 364 | string dataPath = Path.Combine(AppDomain.CurrentDomain.BaseDirectory, "assets"); //+ folder; |
365 | string fileName = Path.Combine(dataPath, filename); | 365 | string fileName = Path.Combine(dataPath, filename); |
366 | FileInfo fInfo = new FileInfo(fileName); | 366 | FileInfo fInfo = new FileInfo(fileName); |
367 | long numBytes = fInfo.Length; | 367 | long numBytes = fInfo.Length; |
368 | FileStream fStream = new FileStream(fileName, FileMode.Open, FileAccess.Read); | 368 | FileStream fStream = new FileStream(fileName, FileMode.Open, FileAccess.Read); |
369 | byte[] idata = new byte[numBytes]; | 369 | byte[] idata = new byte[numBytes]; |
370 | BinaryReader br = new BinaryReader(fStream); | 370 | BinaryReader br = new BinaryReader(fStream); |
371 | idata = br.ReadBytes((int)numBytes); | 371 | idata = br.ReadBytes((int)numBytes); |
372 | br.Close(); | 372 | br.Close(); |
373 | fStream.Close(); | 373 | fStream.Close(); |
374 | info.Data = idata; | 374 | info.Data = idata; |
375 | //info.loaded=true; | 375 | //info.loaded=true; |
376 | } | 376 | } |
377 | } | 377 | } |
378 | public class AssetUUIDQuery : Predicate | 378 | public class AssetUUIDQuery : Predicate |
379 | { | 379 | { |
380 | private LLUUID _findID; | 380 | private LLUUID _findID; |
381 | 381 | ||
382 | public AssetUUIDQuery(LLUUID find) | 382 | public AssetUUIDQuery(LLUUID find) |
383 | { | 383 | { |
384 | _findID = find; | 384 | _findID = find; |
385 | } | 385 | } |
386 | public bool Match(AssetStorage asset) | 386 | public bool Match(AssetStorage asset) |
387 | { | 387 | { |
388 | return (asset.UUID == _findID); | 388 | return (asset.UUID == _findID); |
389 | } | 389 | } |
390 | } | 390 | } |
391 | 391 | ||
392 | } | 392 | } |
393 | 393 | ||
diff --git a/OpenSim/Framework/Communications/Cache/SQLAssetServer.cs b/OpenSim/Framework/Communications/Cache/SQLAssetServer.cs index a965ee0..a64d195 100644 --- a/OpenSim/Framework/Communications/Cache/SQLAssetServer.cs +++ b/OpenSim/Framework/Communications/Cache/SQLAssetServer.cs | |||
@@ -44,7 +44,7 @@ namespace OpenSim.Framework.Communications.Caches | |||
44 | private IAssetReceiver _receiver; | 44 | private IAssetReceiver _receiver; |
45 | private BlockingQueue<ARequest> _assetRequests; | 45 | private BlockingQueue<ARequest> _assetRequests; |
46 | private Thread _localAssetServerThread; | 46 | private Thread _localAssetServerThread; |
47 | protected IAssetProvider m_plugin; | 47 | protected IAssetProvider m_plugin; |
48 | private object syncLock = new object(); | 48 | private object syncLock = new object(); |
49 | 49 | ||
50 | 50 | ||
@@ -102,20 +102,20 @@ namespace OpenSim.Framework.Communications.Caches | |||
102 | } | 102 | } |
103 | 103 | ||
104 | public void UpdateAsset(AssetBase asset) | 104 | public void UpdateAsset(AssetBase asset) |
105 | { | 105 | { |
106 | lock (syncLock) | 106 | lock (syncLock) |
107 | { | 107 | { |
108 | m_plugin.UpdateAsset(asset); | 108 | m_plugin.UpdateAsset(asset); |
109 | m_plugin.CommitAssets(); | 109 | m_plugin.CommitAssets(); |
110 | } | 110 | } |
111 | } | 111 | } |
112 | 112 | ||
113 | public void CreateAsset(AssetBase asset) | 113 | public void CreateAsset(AssetBase asset) |
114 | { | 114 | { |
115 | lock (syncLock) | 115 | lock (syncLock) |
116 | { | 116 | { |
117 | m_plugin.CreateAsset(asset); | 117 | m_plugin.CreateAsset(asset); |
118 | m_plugin.CommitAssets(); | 118 | m_plugin.CommitAssets(); |
119 | } | 119 | } |
120 | } | 120 | } |
121 | 121 | ||
@@ -135,12 +135,12 @@ namespace OpenSim.Framework.Communications.Caches | |||
135 | { | 135 | { |
136 | ARequest req = this._assetRequests.Dequeue(); | 136 | ARequest req = this._assetRequests.Dequeue(); |
137 | 137 | ||
138 | MainLog.Instance.Verbose("Requesting asset: " + req.AssetID); | 138 | MainLog.Instance.Verbose("Requesting asset: " + req.AssetID); |
139 | 139 | ||
140 | AssetBase asset = null; | 140 | AssetBase asset = null; |
141 | lock (syncLock) | 141 | lock (syncLock) |
142 | { | 142 | { |
143 | asset = m_plugin.FetchAsset(req.AssetID); | 143 | asset = m_plugin.FetchAsset(req.AssetID); |
144 | } | 144 | } |
145 | if (asset != null) | 145 | if (asset != null) |
146 | { | 146 | { |