From: Matt Joiner Date: Wed, 27 Aug 2014 22:05:06 +0000 (+1000) Subject: Some fixes and improvements to dirwatch X-Git-Tag: v1.0.0~1590 X-Git-Url: http://www.git.stargrave.org/?a=commitdiff_plain;h=01a9c73428ebc7ee13647368c3214f20b7d97130;p=btrtrc.git Some fixes and improvements to dirwatch --- diff --git a/util/dirwatch/dirwatch.go b/util/dirwatch/dirwatch.go index afc7653d..1e857e1a 100644 --- a/util/dirwatch/dirwatch.go +++ b/util/dirwatch/dirwatch.go @@ -90,7 +90,7 @@ func scanDir(dirName string) (ee map[torrent.InfoHash]entity) { addEntity := func(e entity) { e0, ok := ee[e.InfoHash] if ok { - if e0.MagnetURI != "" && len(e.MagnetURI) < len(e0.MagnetURI) { + if e0.MagnetURI == "" || len(e.MagnetURI) < len(e0.MagnetURI) { return } } @@ -107,7 +107,7 @@ func scanDir(dirName string) (ee map[torrent.InfoHash]entity) { e := entity{ TorrentFilePath: fullName, } - util.CopyExact(e.InfoHash, ih) + util.CopyExact(&e.InfoHash, ih) addEntity(e) case ".magnet": uris, err := magnetFileURIs(fullName) @@ -138,6 +138,7 @@ func magnetFileURIs(name string) (uris []string, err error) { } defer f.Close() scanner := bufio.NewScanner(f) + scanner.Split(bufio.ScanWords) for scanner.Scan() { uris = append(uris, scanner.Text()) }