[OSM-talk] compressed gpx file failed import

Tom Hughes tom at compton.nu
Thu Mar 6 12:53:26 GMT 2008


In message <47CFDD79.3050203 at inuits.be>
        Johan Huysmans <johan.huysmans at inuits.be> wrote:

> I'm trying to upload my traces. It is a gziped file.
>
> But I receive a mail with the message that the import has failed.
>
> I tried to upload the same file, but uncompressed and it imported
> successfully.
>
> Is there anything wrong with the gzip support?

It's more a case of ruby, as normal, sucking exceeding large
boulders through really, really teeny straws.

The arose as a result of me moving the import daemon to a 
different machine the other day. Unfortunately the new machine
is running ruby 1.8.4 rather than 1.8.5 like the old machine
and that was enough to break import of compressed traces.

I'm quite impressed it's taken about 36 hours for anybody to
notice that it was broken... Hopefully it's fixed now as I have
now engaged it a bit more creative ruby hacking.

If anybody really cares about the gory details, the problem is
that the ruby Tempfile class does not (as might seem obvious at
first glance) derive from the File class but rather from something
called DelegateClass(File).

Now DelegateClass(File) is supposed to delegate calls which are
not handled by Tempfile methods to the File class but it does a
rather half assed job of it - in particular it does not ensure
that "kind_of? File" works, so Tempfile does not look like a File
object (or like an IO object which File derives from).

So when the XML parser asked if the source it was being asked
to import from was "kind_of? IO" the answer was no and it threw
a wobbly.

In ruby 1.8.5 the XML parser no longer does the "kind_of? IO" test
on the source - instead it uses "respond_to?" to make sure that the
source responds to the methods it needs. As DelegateClass does
handle "respond_to?" calls correctly this works.

Tom

-- 
Tom Hughes (tom at compton.nu)
http://www.compton.nu/




More information about the talk mailing list