From 63ebfa8d0837adbce171d06c4fd783bc0a6d4b48 Mon Sep 17 00:00:00 2001 From: Rene Gollent Date: Wed, 28 Apr 2010 18:30:04 +0000 Subject: [PATCH] When creating Trash directories, Tracker would only set the hidden and/or icon attributes at startup for volumes mounted at that point in time. Volumes mounted later would have the directory created, but not marked hidden or otherwise attributed, which would lead to confusing situations where the root Trash dirs would appear randomly while browsing the filesystem. Instead, Tracker now always writes those attributes when calling FSGetTrashDir(), which is reused by FSCreateTrashDirs(). Fixes ticket #5827. git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@36520 a95241bf-73f2-0310-859d-f6bbb57e9c96 --- src/kits/tracker/FSUtils.cpp | 67 ++++++++++++++++++------------------ 1 file changed, 33 insertions(+), 34 deletions(-) diff --git a/src/kits/tracker/FSUtils.cpp b/src/kits/tracker/FSUtils.cpp index 732f9c91f8..e6284f3d76 100644 --- a/src/kits/tracker/FSUtils.cpp +++ b/src/kits/tracker/FSUtils.cpp @@ -2356,7 +2356,6 @@ CalcItemsAndSize(CopyLoopControl* loopControl, BObjectList *refList, status_t FSGetTrashDir(BDirectory *trashDir, dev_t dev) { - BVolume volume(dev); status_t result = volume.InitCheck(); if (result != B_OK) @@ -2371,6 +2370,38 @@ FSGetTrashDir(BDirectory *trashDir, dev_t dev) if (result != B_OK) return result; + // make trash invisible + StatStruct sbuf; + trashDir->GetStat(&sbuf); + + PoseInfo poseInfo; + poseInfo.fInvisible = true; + poseInfo.fInitedDirectory = sbuf.st_ino; + trashDir->WriteAttr(kAttrPoseInfo, B_RAW_TYPE, 0, &poseInfo, + sizeof(PoseInfo)); + + size_t size; + const void* data = GetTrackerResources()-> + LoadResource('ICON', R_TrashIcon, &size); + if (data != NULL) { + trashDir->WriteAttr(kAttrLargeIcon, 'ICON', 0, + data, size); + } + data = GetTrackerResources()-> + LoadResource('MICN', R_TrashIcon, &size); + if (data != NULL) { + trashDir->WriteAttr(kAttrMiniIcon, 'MICN', 0, + data, size); + } +#ifdef __HAIKU__ + data = GetTrackerResources()-> + LoadResource(B_VECTOR_ICON_TYPE, R_TrashIcon, &size); + if (data != NULL) { + trashDir->WriteAttr(kAttrIcon, B_VECTOR_ICON_TYPE, 0, + data, size); + } +#endif + return B_OK; } @@ -2855,39 +2886,7 @@ FSCreateTrashDirs() find_directory(B_TRASH_DIRECTORY, &path, true, &volume); BDirectory trashDir; - if (FSGetTrashDir(&trashDir, volume.Device()) == B_OK) { - // make trash invisible - StatStruct sbuf; - trashDir.GetStat(&sbuf); - - PoseInfo poseInfo; - poseInfo.fInvisible = true; - poseInfo.fInitedDirectory = sbuf.st_ino; - trashDir.WriteAttr(kAttrPoseInfo, B_RAW_TYPE, 0, &poseInfo, - sizeof(PoseInfo)); - - size_t size; - const void* data = GetTrackerResources()-> - LoadResource('ICON', R_TrashIcon, &size); - if (data != NULL) { - trashDir.WriteAttr(kAttrLargeIcon, 'ICON', 0, - data, size); - } - data = GetTrackerResources()-> - LoadResource('MICN', R_TrashIcon, &size); - if (data != NULL) { - trashDir.WriteAttr(kAttrMiniIcon, 'MICN', 0, - data, size); - } -#ifdef __HAIKU - data = GetTrackerResources()-> - LoadResource(B_VECTOR_ICON_TYPE, R_TrashIcon, &size); - if (data != NULL) { - trashDir.WriteAttr(kAttrIcon, B_VECTOR_ICON_TYPE, 0, - data, size); - } -#endif - } + FSGetTrashDir(&trashDir, volume.Device()); } }