add some error messages for abuse of our IInventoryData interface

(i.e. using add to update, or update to add).
0.6.0-stable
Sean Dague 2008-04-07 15:01:00 +00:00
parent 8833a72388
commit 2b23734a16
1 changed files with 18 additions and 6 deletions

View File

@ -126,7 +126,7 @@ namespace OpenSim.Data.SQLite
row["inventoryEveryOnePermissions"] = item.inventoryEveryOnePermissions; row["inventoryEveryOnePermissions"] = item.inventoryEveryOnePermissions;
} }
private void addFolder(InventoryFolderBase folder) private void addFolder(InventoryFolderBase folder, bool add)
{ {
lock (ds) lock (ds)
{ {
@ -135,12 +135,18 @@ namespace OpenSim.Data.SQLite
DataRow inventoryRow = inventoryFolderTable.Rows.Find(Util.ToRawUuidString(folder.folderID)); DataRow inventoryRow = inventoryFolderTable.Rows.Find(Util.ToRawUuidString(folder.folderID));
if (inventoryRow == null) if (inventoryRow == null)
{ {
if (! add)
m_log.ErrorFormat("Interface Misuse: Attempting to Update non-existant inventory folder: {0}", folder.folderID);
inventoryRow = inventoryFolderTable.NewRow(); inventoryRow = inventoryFolderTable.NewRow();
fillFolderRow(inventoryRow, folder); fillFolderRow(inventoryRow, folder);
inventoryFolderTable.Rows.Add(inventoryRow); inventoryFolderTable.Rows.Add(inventoryRow);
} }
else else
{ {
if (add)
m_log.ErrorFormat("Interface Misuse: Attempting to Add inventory folder that already exists: {0}", folder.folderID);
fillFolderRow(inventoryRow, folder); fillFolderRow(inventoryRow, folder);
} }
@ -170,7 +176,7 @@ namespace OpenSim.Data.SQLite
} }
} }
private void addItem(InventoryItemBase item) private void addItem(InventoryItemBase item, bool add)
{ {
lock (ds) lock (ds)
{ {
@ -179,12 +185,18 @@ namespace OpenSim.Data.SQLite
DataRow inventoryRow = inventoryItemTable.Rows.Find(Util.ToRawUuidString(item.inventoryID)); DataRow inventoryRow = inventoryItemTable.Rows.Find(Util.ToRawUuidString(item.inventoryID));
if (inventoryRow == null) if (inventoryRow == null)
{ {
if (! add)
m_log.ErrorFormat("Interface Misuse: Attempting to Update non-existant inventory item: {0}", item.inventoryID);
inventoryRow = inventoryItemTable.NewRow(); inventoryRow = inventoryItemTable.NewRow();
fillItemRow(inventoryRow, item); fillItemRow(inventoryRow, item);
inventoryItemTable.Rows.Add(inventoryRow); inventoryItemTable.Rows.Add(inventoryRow);
} }
else else
{ {
if (add)
m_log.ErrorFormat("Interface Misuse: Attempting to Add inventory item that already exists: {0}", item.inventoryID);
fillItemRow(inventoryRow, item); fillItemRow(inventoryRow, item);
} }
invItemsDa.Update(ds, "inventoryitems"); invItemsDa.Update(ds, "inventoryitems");
@ -385,7 +397,7 @@ namespace OpenSim.Data.SQLite
/// <param name="item">The item to be created</param> /// <param name="item">The item to be created</param>
public void addInventoryItem(InventoryItemBase item) public void addInventoryItem(InventoryItemBase item)
{ {
addItem(item); addItem(item, true);
} }
/// <summary> /// <summary>
@ -394,7 +406,7 @@ namespace OpenSim.Data.SQLite
/// <param name="item">The updated item</param> /// <param name="item">The updated item</param>
public void updateInventoryItem(InventoryItemBase item) public void updateInventoryItem(InventoryItemBase item)
{ {
addItem(item); addItem(item, false);
} }
/// <summary> /// <summary>
@ -436,7 +448,7 @@ namespace OpenSim.Data.SQLite
/// <param name="folder">The inventory folder</param> /// <param name="folder">The inventory folder</param>
public void addInventoryFolder(InventoryFolderBase folder) public void addInventoryFolder(InventoryFolderBase folder)
{ {
addFolder(folder); addFolder(folder, true);
} }
/// <summary> /// <summary>
@ -445,7 +457,7 @@ namespace OpenSim.Data.SQLite
/// <param name="folder">The inventory folder</param> /// <param name="folder">The inventory folder</param>
public void updateInventoryFolder(InventoryFolderBase folder) public void updateInventoryFolder(InventoryFolderBase folder)
{ {
addFolder(folder); addFolder(folder, false);
} }
/// <summary> /// <summary>