]> Sergey Matveev's repositories - btrtrc.git/commitdiff
Clean up magnet URI parsing errors in dirwatch
authorMatt Joiner <anacrolix@gmail.com>
Thu, 11 Sep 2014 04:18:59 +0000 (14:18 +1000)
committerMatt Joiner <anacrolix@gmail.com>
Thu, 11 Sep 2014 04:18:59 +0000 (14:18 +1000)
util/dirwatch/dirwatch.go

index 1e857e1ad6ce2510ffbc4270d2389a6af84c4187..b01e56302a53a73baaf40623f9c787593aaae0ec 100644 (file)
@@ -7,6 +7,7 @@ import (
        "log"
        "os"
        "path/filepath"
+       "strings"
 
        "bitbucket.org/anacrolix/go.torrent/util"
 
@@ -118,7 +119,7 @@ func scanDir(dirName string) (ee map[torrent.InfoHash]entity) {
                        for _, uri := range uris {
                                m, err := torrent.ParseMagnetURI(uri)
                                if err != nil {
-                                       log.Print(err)
+                                       log.Printf("error parsing %q in file %q: %s", uri, fullName, err)
                                        continue
                                }
                                addEntity(entity{
@@ -140,6 +141,10 @@ func magnetFileURIs(name string) (uris []string, err error) {
        scanner := bufio.NewScanner(f)
        scanner.Split(bufio.ScanWords)
        for scanner.Scan() {
+               // Allow magnet URIs to be "commented" out.
+               if strings.HasPrefix(scanner.Text(), "#") {
+                       continue
+               }
                uris = append(uris, scanner.Text())
        }
        err = scanner.Err()