]> Sergey Matveev's repositories - btrtrc.git/blobdiff - spec.go
Misc improvements
[btrtrc.git] / spec.go
diff --git a/spec.go b/spec.go
index 49a1104edec007bae6c1fc4562fdd04f30c42247..f54b325b5cee9708da43656aade5a21ffb5094dc 100644 (file)
--- a/spec.go
+++ b/spec.go
@@ -71,13 +71,13 @@ func TorrentSpecFromMetaInfoErr(mi *metainfo.MetaInfo) (*TorrentSpec, error) {
        if err != nil {
                err = fmt.Errorf("unmarshalling info: %w", err)
        }
-       v1Ih := mi.HashInfoBytes()
+       var v1Ih metainfo.Hash
+       if info.HasV1() {
+               v1Ih = mi.HashInfoBytes()
+       }
        var v2Infohash g.Option[infohash_v2.T]
        if info.HasV2() {
                v2Infohash.Set(infohash_v2.HashBytes(mi.InfoBytes))
-               if !info.HasV1() {
-                       v1Ih = *v2Infohash.Value.ToShort()
-               }
        }
 
        return &TorrentSpec{