Index::SetTo() now sets fName even if the index initialization failed (for
whatever reason). Index::Update() is now allowed to be called for those indices - in this case it will just update all live queries. Added some comments. git-svn-id: file:///srv/svn/repos/haiku/trunk/current@3329 a95241bf-73f2-0310-859d-f6bbb57e9c96
This commit is contained in:
@@ -46,14 +46,29 @@ Index::Unset()
|
|||||||
|
|
||||||
put_vnode(fVolume->ID(), fNode->ID());
|
put_vnode(fVolume->ID(), fNode->ID());
|
||||||
fNode = NULL;
|
fNode = NULL;
|
||||||
|
fName = NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/** Sets the index to specified one. Returns an error if the index could
|
||||||
|
* not be found or initialized.
|
||||||
|
* Note, Index::Update() may be called on the object even if this method
|
||||||
|
* failed previously. In this case, it will only update live queries for
|
||||||
|
* the updated attribute.
|
||||||
|
*/
|
||||||
|
|
||||||
status_t
|
status_t
|
||||||
Index::SetTo(const char *name)
|
Index::SetTo(const char *name)
|
||||||
{
|
{
|
||||||
// remove the old node, if the index is set for the second time
|
// remove the old node, if the index is set for the second time
|
||||||
Unset();
|
Unset();
|
||||||
|
|
||||||
|
fName = name;
|
||||||
|
// only stores the pointer, so it assumes that it will stay constant
|
||||||
|
// in further comparisons (currently only used in Index::Update())
|
||||||
|
|
||||||
|
// Note, the name is saved even if the index couldn't be initialized!
|
||||||
|
// This is used to optimize Index::Update() in case there is no index
|
||||||
|
|
||||||
Inode *indices = fVolume->IndicesNode();
|
Inode *indices = fVolume->IndicesNode();
|
||||||
if (indices == NULL)
|
if (indices == NULL)
|
||||||
@@ -76,14 +91,16 @@ Index::SetTo(const char *name)
|
|||||||
put_vnode(fVolume->ID(), id);
|
put_vnode(fVolume->ID(), id);
|
||||||
return B_ERROR;
|
return B_ERROR;
|
||||||
}
|
}
|
||||||
fName = name;
|
|
||||||
// only stores the pointer, so it assumes that it will stay constant
|
|
||||||
// in further comparisons (currently only used in Index::Update())
|
|
||||||
|
|
||||||
return B_OK;
|
return B_OK;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/** Returns a standard type code for the stat() index type codes. Returns
|
||||||
|
* zero if the type is not known (can only happen if the mode field is
|
||||||
|
* corrupted somehow or not that of an index).
|
||||||
|
*/
|
||||||
|
|
||||||
uint32
|
uint32
|
||||||
Index::Type()
|
Index::Type()
|
||||||
{
|
{
|
||||||
@@ -217,7 +234,8 @@ Index::Update(Transaction *transaction, const char *name, int32 type, const uint
|
|||||||
fVolume->UpdateLiveQueries(inode, name, type, oldKey, oldLength, newKey, newLength);
|
fVolume->UpdateLiveQueries(inode, name, type, oldKey, oldLength, newKey, newLength);
|
||||||
|
|
||||||
status_t status;
|
status_t status;
|
||||||
if (name != fName && (status = SetTo(name)) < B_OK)
|
if (((name != fName || strcmp(name, fName)) && (status = SetTo(name)) < B_OK)
|
||||||
|
|| fNode == NULL)
|
||||||
return B_BAD_INDEX;
|
return B_BAD_INDEX;
|
||||||
|
|
||||||
// now that we have the type, check again for equality
|
// now that we have the type, check again for equality
|
||||||
|
|||||||
Reference in New Issue
Block a user