From e1d37632bb534f950117fee49223ede624c968ac Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Axel=20D=C3=B6rfler?= Date: Mon, 26 May 2003 01:47:06 +0000 Subject: [PATCH] Now takes changed function of Index::Update() into account - queries on non-indexed attributes now finally work as they should. git-svn-id: file:///srv/svn/repos/haiku/trunk/current@3330 a95241bf-73f2-0310-859d-f6bbb57e9c96 --- src/add-ons/kernel/file_systems/bfs/Inode.cpp | 23 ++++++++++--------- 1 file changed, 12 insertions(+), 11 deletions(-) diff --git a/src/add-ons/kernel/file_systems/bfs/Inode.cpp b/src/add-ons/kernel/file_systems/bfs/Inode.cpp index 92d660ec7a..aeb2c0540f 100644 --- a/src/add-ons/kernel/file_systems/bfs/Inode.cpp +++ b/src/add-ons/kernel/file_systems/bfs/Inode.cpp @@ -733,7 +733,7 @@ Inode::WriteAttribute(Transaction *transaction, const char *name, int32 type, of if (attribute->ReadAt(0, oldBuffer, &oldLength) == B_OK) oldData = oldBuffer; } - // ToDo: check if the data fits in the inode now and delete the file if so + // ToDo: check if the data fits in the inode now and delete the attribute file if so status = attribute->WriteAt(transaction, pos, buffer, _length); attribute->Lock().UnlockWrite(); @@ -743,17 +743,18 @@ Inode::WriteAttribute(Transaction *transaction, const char *name, int32 type, of ReleaseAttribute(attribute); } - if (status == B_OK) { - // ToDo: find a better way for that "pos" thing... - // Update index - if (hasIndex && pos == 0) { - // index only the first BPLUSTREE_MAX_KEY_LENGTH bytes - uint16 length = *_length; - if (length > BPLUSTREE_MAX_KEY_LENGTH) - length = BPLUSTREE_MAX_KEY_LENGTH; + // ToDo: find a better way than this "pos" thing (the begin of the old key + // must be copied to the start of the new one for a comparison) + if (status == B_OK && pos == 0) { + // index only the first BPLUSTREE_MAX_KEY_LENGTH bytes + uint16 length = *_length; + if (length > BPLUSTREE_MAX_KEY_LENGTH) + length = BPLUSTREE_MAX_KEY_LENGTH; - index.Update(transaction, name, 0, oldData, oldLength, buffer, length, this); - } + // Update index. Note, Index::Update() may be called even if initializing + // the index failed - it will just update the live queries in this case + if (pos < length || pos < oldLength) + index.Update(transaction, name, type, oldData, oldLength, buffer, length, this); } return status; }