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
This commit is contained in:
Rene Gollent
2010-04-28 18:30:04 +00:00
parent 4fe399e426
commit 63ebfa8d08
+33 -34
View File
@@ -2356,7 +2356,6 @@ CalcItemsAndSize(CopyLoopControl* loopControl, BObjectList<entry_ref> *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());
}
}