* Evaluate errors returned by guessFiletype().
authorUrban Wallasch <urban.wallasch@freenet.de>
Sat, 6 Apr 2019 11:33:18 +0000 (13:33 +0200)
committerUrban Wallasch <urban.wallasch@freenet.de>
Sat, 6 Apr 2019 11:33:18 +0000 (13:33 +0200)
gogopherd.go
util.go

index 5697fbd5edee4c697dd2cbb2ce6d036e5cd9a59f..1e6bfe7f417004389147db2fe78a0e365a298d27 100644 (file)
@@ -47,7 +47,10 @@ func createIndex(selector string) (string, error) {
                        list += "1" + fi.Name() + " | DIR | " + fts + "\t" + selector + pathSep + fi.Name() + loc
                } else if fmode.IsRegular() {
                        // create a file reference
-                       ftype, _ := guessFiletype(dirname + pathSep + fi.Name())
+                       ftype, err := guessFiletype(dirname + pathSep + fi.Name())
+                       if check(err, "guessFiletype "+dirname+pathSep+fi.Name()) != nil {
+                               continue
+                       }
                        list += ftype + fi.Name() + " | " + humanSize(fi.Size()) + " | " + fts + "\t" + selector + pathSep + fi.Name() + loc
                } else if cfg.fsymln && fmode&os.ModeSymlink != 0 {
                        // create a reference with attributes matching the link target
@@ -66,7 +69,10 @@ func createIndex(selector string) (string, error) {
                                                list += "1" + fi.Name() + " | DIR | " + fts + "\t" + selector + pathSep + fi.Name() + loc
                                        } else if fmode.IsRegular() {
                                                // link points to a regular file
-                                               ftype, _ := guessFiletype(dirname + pathSep + fi.Name())
+                                               ftype, err := guessFiletype(dirname + pathSep + fi.Name())
+                                               if check(err, "guessFiletype "+dirname+pathSep+fi.Name()) != nil {
+                                                       continue
+                                               }
                                                list += ftype + fi.Name() + " | " + humanSize(lfi.Size()) + " | " + fts + "\t" + selector + pathSep + fi.Name() + loc
                                        }
                                }
diff --git a/util.go b/util.go
index 1f229aa79a585386a8987a60955d3191a26831f4..29d453bdc8ec2eabcd73ad708cbffe1564465263 100644 (file)
--- a/util.go
+++ b/util.go
@@ -90,7 +90,6 @@ func guessFiletype(path string) (string, error) {
        }
        buffer = buffer[:n]
        contentType := http.DetectContentType(buffer)
-       //tracer.Print("Content Type " + path + " == "+ contentType)
        shortType := strings.Split(contentType, ";")[0]
        genType := strings.Split(shortType, "/")[0]
        gopherType := "9"