~kornellapacz/public-inbox

[gmnigit] failure on text/gemini files

Omar Polo
Details
Message ID
<87pmvfg9q5.fsf@omarpolo.com>
DKIM signature
pass
Download raw message
Hi,

I noticed that gmnigit was failing with a rather arcane message:

	remote: 2021/07/18 12:43:53 EOF

Turns out, the mimetype library[0] fails with EOF on text/gemini files

As a quick solution, I found that ignoring io.EOF doesn't produce wrong
results.  *.gmi files are still recognized as text, as you can see here:

=> gemini://git.omarpolo.com/telescope/tree/pages/about_about.gmi.txt

but I don't know if it's the proper way to solve this issue.  I'm
attaching the patch I'm using only for reference.

Thanks,

Omar Polo

[0]: https://github.com/gabriel-vasile/mimetype

--- a/files.go
+++ b/files.go
@@ -6,6 +6,7 @@ import (
        "io/ioutil"
        "log"
        "os"
+       "io"
        "path/filepath"
        "strings"

@@ -82,7 +83,10 @@ func arrangeDirectory(root, path string) {
                }

                detectedMIME, err := mimetype.DetectFile(filePath)
-               check(err)
+               if err != nil && err != io.EOF {
+                       log.Println("can't detect mime type for", filePath)
+                       panic(err)
+               }
Reply to thread Export thread (mbox)