[svn.haxx.se] · SVN Dev · SVN Users · SVN Org · TSVN Dev · TSVN Users · Subclipse Dev · Subclipse Users · this month's index

RE: Improved mime-type guessing (issue #1233)

From: Bert Huijben <bert_at_qqmail.nl>
Date: Fri, 1 Aug 2008 10:02:59 +0200

> -----Original Message-----
> From: Hyrum K. Wright [mailto:hyrum_wright_at_mail.utexas.edu]
> Sent: vrijdag 1 augustus 2008 7:40
> To: dev_at_subversion.tigris.org
> Subject: Improved mime-type guessing (issue #1233)
>
> While performing a random walk through the issue tracker, I came across
> issue
> #1233, which includes a patch to use the /etc/mime.types file on *nix
> systems to
> improve our mime-type guessing. It looked interesting, so I started
> digging in,
> only to realize that there were more issues at play than at first
> blush.
>
> Before go too deeply into the code, I have a few questions I was hoping
> people
> could answer:
>
> * Does this even matter? Would adding this functionality be a
> benefit to our
> users, and if so, does the overhead of adding and maintaining it
> outweigh the
> derived benefit?

I think most of this is issue is already implemented in 1.5:

# svn log -v -c 23306
------------------------------------------------------------------------
r23306 | cmpilato | 2007-01-30 23:37:46 +0100 (di, 30 jan 2007) | 41 lines
Changed paths:
   M /trunk/subversion/include/svn_client.h
   M /trunk/subversion/include/svn_config.h
   M /trunk/subversion/include/svn_io.h
   M /trunk/subversion/libsvn_client/add.c
   M /trunk/subversion/libsvn_subr/config_file.c
   M /trunk/subversion/libsvn_subr/io.c
   M /trunk/subversion/svn/main.c

Add a new runtime configuration operation ("mime-types-file") which,
when present, specifies the location of a MIME types file (such as
/etc/mime.types) which is used by the 'add' and 'import' operations
for the auto-detection of MIME types of added/imported files.

I'm not especially thrilled with the change to the svn_client_ctx_t.
I don't want to parse the mime.types file multiple times in a single
invocation. And, ideally, I wouldn't parse it for operations that I
know won't use it. So it seemed natural to hang the types map on the
svn_client_ctx_t, but leave it NULL for everything except 'add' and
'import'. However, this leaves the public API without any
cross-reference between this structure and the svn_client_add3() and
svn_client_import2() functions that use it. But then again, you can't
tell from the public API that those things make use of the runtime
config's autoprop stuff, either. Comments and suggestions welcome.

* subversion/include/svn_io.h,
* subversion/libsvn_subr/io.c
  (svn_io_parse_mimetypes_file): New.
  (svn_io_detect_mimetype2): Was svn_io_detect_mimetype. Now accepts
    an optional mimetype_map parameter from which mime types are now
    chosen by default.
  (svn_io_detect_mimetype): Now just a wrapper around
svn_io_detect_mimetype2.

* subversion/include/svn_config.h
  (SVN_CONFIG_OPTION_MIMETYPES_FILE): New.

* subversion/libsvn_subr/config_file.c
  (svn_config_ensure): Note the new mime-types-file option in the
    default 'config' configuration file contents.

* subversion/include/svn_client.h
  (svn_client_ctx_t): Add 'mimetypes_map' member.

* subversion/libsvn_client/add.c
  (svn_client__get_auto_props): Use svn_io_detect_mimetype2() instead of
    svn_io_detect_mimetype().

* subversion/svn/main.c
  (main): For 'add' and 'import', parse any configured MIME types file.

------------------------------------------------------------------------

> * Is there equivalent MIME type guessing functionality available on
> Windows,
> either through an API or via a system file?

The file extension to media/mime type mapping is available in the registry.
(I don't think there is an api, but the layout is well documented for this
case)

> Hopefully the answers to these questions will help us resurrect this
> patch, or
> decide on a reasonable fate for issue #1233.

I think this issue might need some extra documentation. (Especially since it
requires changes to the application bindings to really enable it: The file
is read from svn/main.c to be used in svn_client_add* and
svn_client_import*)

(SharpSvn delay loads this file automatically for its users right before
they use Add or Import for the first time)

        Bert

---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe_at_subversion.tigris.org
For additional commands, e-mail: dev-help_at_subversion.tigris.org
Received on 2008-08-02 01:33:24 CEST

This is an archived mail posted to the Subversion Dev mailing list.

This site is subject to the Apache Privacy Policy and the Apache Public Forum Archive Policy.