#29 Mcomix relies on file extensions to determine file type

SVN
wont-fix
nobody
None
5
2014-01-18
2014-01-18
Tucker DiNapoli
No

I'm not sure how or why this got changed from the original code, but at some point the code to determine if a file is an image changed from using gtk.gdk.pixbuf_get_file_info(path) to testing the file extension. I tend to have image files without file extensions and so I've had a copy of comix on my system just for that. But I got tired of it and so I dug into the code and fixed it. I can't imagine how this could cause any errors, but I could be wrong. This patch really just replaces the current is_image_file(path) functon with the one from the original comix.This has been bugging me for a while so I just figured I'd try and fix it.

1 Attachments

Discussion

  • Oddegamra
    Oddegamra
    2014-01-18

    Well, it's been a pretty long time, but the commit log tells me I changed the function for performance reasons in 2011. Most likely because calling stat(), fread() and so on to determine the file type on each file in a directory is a huge I/O drain, especially if reading from a network share or the directory contains many files.

     
    • I can understand that it might be a performance issue, but at the same time it means the program doesn't work correctly. If I open an image file it shouldn't matter what the extension is. In my opinion it's a bug that mcomix doesn't work that way. Perhaps it could default to the current behavior but have an option to change to the alternate means of determining file type?

       
      • Louis Casillas
        Louis Casillas
        2014-01-18

        Oddegamra-

        If the performance impact is great enough it makes sense to look at the
        file extension for a lightweight hack.

        However, it would seem there is no issue allowing users the option to
        accept the performance hit in order that MComix performs more "correctly".
        On Jan 18, 2014 10:20 AM, "Tucker DiNapoli" hitchiker42@users.sf.net
        wrote:

        I can understand that it might be a performance issue, but at the same
        time it means the program doesn't work correctly. If I open an image file
        it shouldn't matter what the extension is. In my opinion it's a bug that
        mcomix doesn't work that way. Perhaps it could default to the current
        behavior but have an option to change to the alternate means of determining
        file type?


        Status: wont-fix
        Created: Sat Jan 18, 2014 03:16 AM UTC by Tucker DiNapoli
        Last Updated: Sat Jan 18, 2014 08:02 AM UTC
        Owner: nobody

        I'm not sure how or why this got changed from the original code, but at
        some point the code to determine if a file is an image changed from using
        gtk.gdk.pixbuf_get_file_info(path) to testing the file extension. I tend to
        have image files without file extensions and so I've had a copy of comix on
        my system just for that. But I got tired of it and so I dug into the code
        and fixed it. I can't imagine how this could cause any errors, but I could
        be wrong. This patch really just replaces the current is_image_file(path)
        functon with the one from the original comix.This has been bugging me for a
        while so I just figured I'd try and fix it.


        Sent from sourceforge.net because you indicated interest in
        https://sourceforge.net/p/mcomix/patches/29/

        To unsubscribe from further messages, please visit
        https://sourceforge.net/auth/subscriptions/

         
        Attachments
  • Oddegamra
    Oddegamra
    2014-01-18

    • status: open --> wont-fix