[gmnigit] failure on text/gemini files

Omar Polo
Message ID
DKIM signature
Download raw message

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.


Omar Polo

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

--- a/files.go
+++ b/files.go
@@ -6,6 +6,7 @@ import (
+       "io"

@@ -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)