Opened 6 years ago

Last modified 3 years ago

#10067 new enhancement

Extension should determine file type with same sniffer rule

Reported by: humdinger Owned by: bonefish
Priority: normal Milestone: R1
Component: Servers/registrar Version: R1/Package Management
Keywords: Cc:
Blocked By: Blocking: #10917
Has a Patch: no Platform: All

Description

This is hrev46173.

If you have several file types with the same sniffer rule, the extension should determine what mime type a file is assigned.

For example, RAR archives and CBR (a comic book archive, consisting of rar-archived images) both have the rule '("Rar!")'. Naturally, since they are both RAR archives. In this case, the file extension should decide if it's a .rar or a .cbr.

Change History (4)

comment:1 by axeld, 6 years ago

Summary: Extention should determine file type with same sniffer ruleExtension should determine file type with same sniffer rule

comment:2 by diver, 5 years ago

Blocking: 10917 added

comment:3 by Giova84, 3 years ago

Hi, I have a suggestion for the implementing of this enhancement.

For those which aren't aware, there is an Haiku app called Filer (Humdinger certainly know this app ;-) ): https://github.com/HaikuArchives/Filer

Well, let's see the readme of this app:

Filer is an automatic file organizer. It takes the files it's opened with or that are dropped on it and moves, renames, copies or does all sorts of other things with them according to rules created by the user. Filer is accompanied by AutoFiler. Instead of working on a set of files provided by the user, it can be started (automatically with Haiku) to monitor certain folders and deal with new files appearing there according to the user-defined rules.


In practice, the "Autofiler" element, is able to monitor folders on the system and automatically performs a bunch of actions, also including shell commands; for some parts it acts like a sort of registrar.

The following is an example on my system:

As Humdinger stated

RAR archives and CBR (a comic book archive, consisting of rar-archived images) both have the rule '("Rar!")'. Naturally, since they are both RAR archives. In this case, the file extension should decide if it's a .rar or a .cbr.

Well, on my system I manage *.cbr files (I can open them using a QT *cbr and *cbz reader), and when I place them in my system (inside of certain folders), AutofileFiler, thanks to Filer, will automatically launch the following commands on such files, which end with the *.cbz and *.cbr extension

settype -t application/x-cbr
settype -t application/x-cbz

http://s33.postimg.org/6fb28674v/Autofiler_CBR_Rule.png

In this way I finally avoid the confusion with *.zip and *.rar archives (because if i set the same sniffing rule for *.cbr and *.cbz, zip and rar files will be mistakenly marked as cbr and cbz).

In facts now I lowered the value of the sniffing rule:

Rule for *.cbr
0.10 ("Rar!")
Rule for *.cbz
0.10 ("PK")

But thanks to Filer/AutoFiler, these files are properly recognized also with the lower value "0.10"

So: would be the case to grab/borrow the code from Filer/AutoFiler and implement this feature inside the registrar?

Last edited 3 years ago by Giova84 (previous) (diff)

comment:4 by humdinger, 3 years ago

You manually force-set the correct MIME type with the "settype" command according to the file extension. I'm afraid, AFAIKS, there is nothing in Filer that can be re-used for the registrar.

Note: See TracTickets for help on using tickets.