Clean up magnet URI parsing errors in dirwatch

This commit is contained in:
Matt Joiner 2014-09-11 14:18:59 +10:00
parent 22edc2b4f6
commit 6c1c339ae4
1 changed files with 6 additions and 1 deletions

View 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()