diff options
Diffstat (limited to 'OpenSim/Services/InventoryService/XInventoryService.cs')
-rw-r--r-- | OpenSim/Services/InventoryService/XInventoryService.cs | 53 |
1 files changed, 40 insertions, 13 deletions
diff --git a/OpenSim/Services/InventoryService/XInventoryService.cs b/OpenSim/Services/InventoryService/XInventoryService.cs index 0e7a358..3355428 100644 --- a/OpenSim/Services/InventoryService/XInventoryService.cs +++ b/OpenSim/Services/InventoryService/XInventoryService.cs | |||
@@ -52,6 +52,7 @@ namespace OpenSim.Services.InventoryService | |||
52 | : this(config, "InventoryService") | 52 | : this(config, "InventoryService") |
53 | { | 53 | { |
54 | } | 54 | } |
55 | |||
55 | public XInventoryService(IConfigSource config, string configName) : base(config) | 56 | public XInventoryService(IConfigSource config, string configName) : base(config) |
56 | { | 57 | { |
57 | if (configName != string.Empty) | 58 | if (configName != string.Empty) |
@@ -301,46 +302,62 @@ namespace OpenSim.Services.InventoryService | |||
301 | 302 | ||
302 | public virtual bool AddFolder(InventoryFolderBase folder) | 303 | public virtual bool AddFolder(InventoryFolderBase folder) |
303 | { | 304 | { |
304 | //m_log.DebugFormat("[XINVENTORY]: Add folder {0} type {1} in parent {2}", folder.Name, folder.Type, folder.ParentID); | 305 | // m_log.DebugFormat("[XINVENTORY]: Add folder {0} type {1} in parent {2}", folder.Name, folder.Type, folder.ParentID); |
306 | |||
305 | InventoryFolderBase check = GetFolder(folder); | 307 | InventoryFolderBase check = GetFolder(folder); |
306 | if (check != null) | 308 | if (check != null) |
307 | return false; | 309 | return false; |
308 | 310 | ||
309 | if (folder.Type == (short)AssetType.Folder || folder.Type == (short)AssetType.Unknown || | 311 | if (folder.Type == (short)AssetType.Folder |
310 | GetFolderForType(folder.Owner, (AssetType)(folder.Type)) == null) | 312 | || folder.Type == (short)AssetType.Unknown |
313 | || folder.Type == (short)AssetType.OutfitFolder | ||
314 | || GetFolderForType(folder.Owner, (AssetType)(folder.Type)) == null) | ||
311 | { | 315 | { |
312 | XInventoryFolder xFolder = ConvertFromOpenSim(folder); | 316 | XInventoryFolder xFolder = ConvertFromOpenSim(folder); |
313 | return m_Database.StoreFolder(xFolder); | 317 | return m_Database.StoreFolder(xFolder); |
314 | } | 318 | } |
315 | else | 319 | else |
316 | m_log.DebugFormat("[XINVENTORY]: Folder {0} of type {1} already exists", folder.Name, folder.Type); | 320 | { |
321 | m_log.WarnFormat( | ||
322 | "[XINVENTORY]: Folder of type {0} already exists when tried to add {1} to {2} for {3}", | ||
323 | folder.Type, folder.Name, folder.ParentID, folder.Owner); | ||
324 | } | ||
317 | 325 | ||
318 | return false; | 326 | return false; |
319 | } | 327 | } |
320 | 328 | ||
321 | public virtual bool UpdateFolder(InventoryFolderBase folder) | 329 | public virtual bool UpdateFolder(InventoryFolderBase folder) |
322 | { | 330 | { |
323 | //m_log.DebugFormat("[XINVENTORY]: Update folder {0} {1} ({2})", folder.Name, folder.Type, folder.ID); | 331 | // m_log.DebugFormat("[XINVENTORY]: Update folder {0} {1} ({2})", folder.Name, folder.Type, folder.ID); |
332 | |||
324 | XInventoryFolder xFolder = ConvertFromOpenSim(folder); | 333 | XInventoryFolder xFolder = ConvertFromOpenSim(folder); |
325 | InventoryFolderBase check = GetFolder(folder); | 334 | InventoryFolderBase check = GetFolder(folder); |
335 | |||
326 | if (check == null) | 336 | if (check == null) |
327 | return AddFolder(folder); | 337 | return AddFolder(folder); |
328 | 338 | ||
329 | if (check.Type != -1 || xFolder.type != -1) | 339 | if ((check.Type != (short)AssetType.Unknown || xFolder.type != (short)AssetType.Unknown) |
340 | && (check.Type != (short)AssetType.OutfitFolder || xFolder.type != (short)AssetType.OutfitFolder)) | ||
330 | { | 341 | { |
331 | if (xFolder.version < check.Version) | 342 | if (xFolder.version < check.Version) |
332 | { | 343 | { |
333 | //m_log.DebugFormat("[XINVENTORY]: {0} < {1} can't do", xFolder.version, check.Version); | 344 | // m_log.DebugFormat("[XINVENTORY]: {0} < {1} can't do", xFolder.version, check.Version); |
334 | return false; | 345 | return false; |
335 | } | 346 | } |
347 | |||
336 | check.Version = (ushort)xFolder.version; | 348 | check.Version = (ushort)xFolder.version; |
337 | xFolder = ConvertFromOpenSim(check); | 349 | xFolder = ConvertFromOpenSim(check); |
338 | //m_log.DebugFormat("[XINVENTORY]: Storing {0} {1} {2}", xFolder.folderName, xFolder.version, xFolder.type); | 350 | |
351 | // m_log.DebugFormat( | ||
352 | // "[XINVENTORY]: Storing version only update to system folder {0} {1} {2}", | ||
353 | // xFolder.folderName, xFolder.version, xFolder.type); | ||
354 | |||
339 | return m_Database.StoreFolder(xFolder); | 355 | return m_Database.StoreFolder(xFolder); |
340 | } | 356 | } |
341 | 357 | ||
342 | if (xFolder.version < check.Version) | 358 | if (xFolder.version < check.Version) |
343 | xFolder.version = check.Version; | 359 | xFolder.version = check.Version; |
360 | |||
344 | xFolder.folderID = check.ID; | 361 | xFolder.folderID = check.ID; |
345 | 362 | ||
346 | return m_Database.StoreFolder(xFolder); | 363 | return m_Database.StoreFolder(xFolder); |
@@ -364,6 +381,11 @@ namespace OpenSim.Services.InventoryService | |||
364 | // | 381 | // |
365 | public virtual bool DeleteFolders(UUID principalID, List<UUID> folderIDs) | 382 | public virtual bool DeleteFolders(UUID principalID, List<UUID> folderIDs) |
366 | { | 383 | { |
384 | return DeleteFolders(principalID, folderIDs, true); | ||
385 | } | ||
386 | |||
387 | public virtual bool DeleteFolders(UUID principalID, List<UUID> folderIDs, bool onlyIfTrash) | ||
388 | { | ||
367 | if (!m_AllowDelete) | 389 | if (!m_AllowDelete) |
368 | return false; | 390 | return false; |
369 | 391 | ||
@@ -371,11 +393,12 @@ namespace OpenSim.Services.InventoryService | |||
371 | // | 393 | // |
372 | foreach (UUID id in folderIDs) | 394 | foreach (UUID id in folderIDs) |
373 | { | 395 | { |
374 | if (!ParentIsTrash(id)) | 396 | if (onlyIfTrash && !ParentIsTrash(id)) |
375 | continue; | 397 | continue; |
398 | //m_log.InfoFormat("[XINVENTORY SERVICE]: Delete folder {0}", id); | ||
376 | InventoryFolderBase f = new InventoryFolderBase(); | 399 | InventoryFolderBase f = new InventoryFolderBase(); |
377 | f.ID = id; | 400 | f.ID = id; |
378 | PurgeFolder(f); | 401 | PurgeFolder(f, onlyIfTrash); |
379 | m_Database.DeleteFolders("folderID", id.ToString()); | 402 | m_Database.DeleteFolders("folderID", id.ToString()); |
380 | } | 403 | } |
381 | 404 | ||
@@ -384,10 +407,15 @@ namespace OpenSim.Services.InventoryService | |||
384 | 407 | ||
385 | public virtual bool PurgeFolder(InventoryFolderBase folder) | 408 | public virtual bool PurgeFolder(InventoryFolderBase folder) |
386 | { | 409 | { |
410 | return PurgeFolder(folder, true); | ||
411 | } | ||
412 | |||
413 | public virtual bool PurgeFolder(InventoryFolderBase folder, bool onlyIfTrash) | ||
414 | { | ||
387 | if (!m_AllowDelete) | 415 | if (!m_AllowDelete) |
388 | return false; | 416 | return false; |
389 | 417 | ||
390 | if (!ParentIsTrash(folder.ID)) | 418 | if (onlyIfTrash && !ParentIsTrash(folder.ID)) |
391 | return false; | 419 | return false; |
392 | 420 | ||
393 | XInventoryFolder[] subFolders = m_Database.GetFolders( | 421 | XInventoryFolder[] subFolders = m_Database.GetFolders( |
@@ -396,7 +424,7 @@ namespace OpenSim.Services.InventoryService | |||
396 | 424 | ||
397 | foreach (XInventoryFolder x in subFolders) | 425 | foreach (XInventoryFolder x in subFolders) |
398 | { | 426 | { |
399 | PurgeFolder(ConvertToOpenSim(x)); | 427 | PurgeFolder(ConvertToOpenSim(x), onlyIfTrash); |
400 | m_Database.DeleteFolders("folderID", x.folderID.ToString()); | 428 | m_Database.DeleteFolders("folderID", x.folderID.ToString()); |
401 | } | 429 | } |
402 | 430 | ||
@@ -415,7 +443,6 @@ namespace OpenSim.Services.InventoryService | |||
415 | 443 | ||
416 | public virtual bool UpdateItem(InventoryItemBase item) | 444 | public virtual bool UpdateItem(InventoryItemBase item) |
417 | { | 445 | { |
418 | // throw new Exception("urrgh"); | ||
419 | if (!m_AllowDelete) | 446 | if (!m_AllowDelete) |
420 | if (item.AssetType == (sbyte)AssetType.Link || item.AssetType == (sbyte)AssetType.LinkFolder) | 447 | if (item.AssetType == (sbyte)AssetType.Link || item.AssetType == (sbyte)AssetType.LinkFolder) |
421 | return false; | 448 | return false; |