Opened 3 days ago

Last modified 3 days ago

#19334 new enhancement

provide an option to add custom attributes to index in FileTypes

Reported by: grexe Owned by: axeld
Priority: normal Milestone: Unscheduled
Component: Preferences/FileTypes Version: R1/Development
Keywords: Cc:
Blocked By: Blocking:
Platform: All

Description (last modified by grexe)

FileTypes currently does not provide the UI for adding an attribute to the filesystem index. This is really a great lack of functionality and deprives average users of a core feature unique to Haiku/BFS.

Similar to "Visible" and "Editable", this option could be added below the group as "Searchable" (easier to understand) or "Add to index" (too techy) that affects how Tracker displays it.

This feature would introduce a new property in the META:ATTR_INFO message of a filetype definition, something like attr:searchable.

If true, the attribute is added to the index; if false, we need to check if the attribute is used by another MIME type and if not (i.e. orphaned index), remove it.

cf:

Eventually, a simple preferences application for maintaining indices would be good, but is not required for now.

However, the current situation having indices only available on the command line is very unfortunate, as this is a feature many users would really need and we want to empower users and not restrict them to the default configuration...

Change History (2)

comment:1 by grexe, 3 days ago

Description: modified (diff)

comment:2 by grexe, 3 days ago

here is a trivial working sample code from my simple MIME tool:

BMessage message; // prefilled with MIME type attrInfo message
// check if attribute should be added to index
int32 indexAttrCount;
message.GetInfo(ATTR_INDEX, NULL, &indexAttrCount);
BVolume bootVolume; // FIXME
BVolumeRoster().GetBootVolume(&bootVolume);

for (int i = 0; i < indexAttrCount; i++) {
    const char* attrName = message.GetString("attr:name", i, "");
    const char* attrPublicName = message.GetString("attr:public_name", i, "");
    uint32      attrType = message.GetUInt32("attr:type", i, B_STRING_TYPE);

    if (message.GetBool("attr:searchable", i, false)) {
        // add to index
        printf("adding attribute %s ['%s'] to index...", attrPublicName, attrName);
        int result = fs_create_index(bootVolume.Device(), attrName, attrType, 0);
        if (result == 0) {
            printf("OK\n");
        } else {
            printf("ERROR: %s\n", strerror(result));
        }
    } else {
        printf("keeping attribute %s ['%s'] in index...", attrPublicName, attrName);
        printf("OK\n");
    }
}
Note: See TracTickets for help on using tickets.