From 7676dedf5711cebc9db288079882d085365a2223 Mon Sep 17 00:00:00 2001 From: "Bruno G. Albuquerque" Date: Fri, 22 Sep 2006 02:55:54 +0000 Subject: [PATCH] Fixed live query notification for new files being created. It seems using Inode::GetName() in the middle of a transaction is not a good idea. Axel, can you check if we really need to keep the old code there as it is now or if we can completelly remove it? I think we can but maybe there is some case I did not consider. // We have to special-case the name attribute here because // Inode::Getname will return NULL as we are in the middle // of the transaction at this point when a new file is // created. We just use newKey which happens to contain // the new file name anyway. // // TODO: Check if there is any sense in leaving this if // statement as it is or if we can completelly remove the // original code. git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@18909 a95241bf-73f2-0310-859d-f6bbb57e9c96 --- src/add-ons/kernel/file_systems/bfs/Query.cpp | 22 ++++++++++++++++--- 1 file changed, 19 insertions(+), 3 deletions(-) diff --git a/src/add-ons/kernel/file_systems/bfs/Query.cpp b/src/add-ons/kernel/file_systems/bfs/Query.cpp index 7b8b8a8852..30039b6439 100644 --- a/src/add-ons/kernel/file_systems/bfs/Query.cpp +++ b/src/add-ons/kernel/file_systems/bfs/Query.cpp @@ -1600,9 +1600,25 @@ Query::LiveUpdate(Inode *inode, const char *attribute, int32 type, const uint8 * char nameBuffer[B_FILE_NAME_LENGTH]; if (name == NULL) { - if (inode->GetName(nameBuffer) != B_OK) - nameBuffer[0] = '\0'; - name = nameBuffer; + + // We have to special-case the name attribute here because + // Inode::Getname will return NULL as we are in the middle + // of the transaction at this point when a new file is + // created. We just use newKey which happens to contain + // the new file name anyway. + // + // TODO: Check if there is any sense in leaving this if + // statement as it is or if we can completelly remove the + // original code. + if (strcmp(attribute, "name") == 0) { + name = (const char *)newKey; + } + else + { + if (inode->GetName(nameBuffer) != B_OK) + nameBuffer[0] = '\0'; + name = nameBuffer; + } } // notify query listeners