diff --git a/bench.py b/bench.py index 3b08c08..2156f4e 100644 --- a/bench.py +++ b/bench.py @@ -14,7 +14,7 @@ async def extract_links(url): async def benchmark(url): # This will still block, because subprocess.run is not async - subprocess.run(['hey', '-n', '10000', '-c', '100', url]) + subprocess.run(['hey', '-n', '100000', '-c', '100', url]) url = 'http://localhost:9999/http/' diff --git a/go.mod b/go.mod index 690d6c1..c4128a7 100644 --- a/go.mod +++ b/go.mod @@ -11,6 +11,8 @@ require github.com/orcaman/concurrent-map/v2 v2.0.1 require github.com/panjf2000/ants/v2 v2.8.2 +require github.com/scylladb/go-set v1.0.2 // indirect + require ( github.com/cespare/xxhash/v2 v2.1.1 // indirect github.com/dgraph-io/ristretto v0.1.1 diff --git a/go.sum b/go.sum index a80ce4b..abdddfb 100644 --- a/go.sum +++ b/go.sum @@ -10,6 +10,7 @@ github.com/dgryski/go-farm v0.0.0-20190423205320-6a90982ecee2 h1:tdlZCpZ/P9DhczC github.com/dgryski/go-farm v0.0.0-20190423205320-6a90982ecee2/go.mod h1:SqUrOPUnsFjfmXRMNPybcSiG0BgUW2AuFH8PAnS2iTw= github.com/dustin/go-humanize v1.0.0 h1:VSnTsYCnlFHaM2/igO1h6X3HA71jcobQuxemgkq4zYo= github.com/dustin/go-humanize v1.0.0/go.mod h1:HtrtbFcZ19U5GC7JDqmcUSB87Iq5E25KnS6fMYU6eOk= +github.com/fatih/set v0.2.1/go.mod h1:+RKtMCH+favT2+3YecHGxcc0b4KyVWA1QWWJUs4E0CI= github.com/golang/glog v0.0.0-20160126235308-23def4e6c14b h1:VKtxabqXZkF25pY9ekfRL6a582T4P37/31XEstQ5p58= github.com/golang/glog v0.0.0-20160126235308-23def4e6c14b/go.mod h1:SBH7ygxi8pfUlaOkMMuAQtPIUF8ecWP5IEl/CR7VP2Q= github.com/inconshreveable/mousetrap v1.1.0 h1:wN+x4NVGpMsO7ErUn/mUI3vEoE6Jt13X2s0bqwp9tc8= @@ -23,6 +24,8 @@ github.com/pkg/errors v0.9.1/go.mod h1:bwawxfHBFNV+L2hUp1rHADufV3IMtnDRdf1r5NINE github.com/pmezard/go-difflib v1.0.0 h1:4DBwDE0NGyQoBHbLQYPwSUPoCMWR5BEzIk/f1lZbAQM= github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4= github.com/russross/blackfriday/v2 v2.1.0/go.mod h1:+Rmxgy9KzJVeS9/2gXHxylqXiyQDYRxCVz55jmeOWTM= +github.com/scylladb/go-set v1.0.2 h1:SkvlMCKhP0wyyct6j+0IHJkBkSZL+TDzZ4E7f7BCcRE= +github.com/scylladb/go-set v1.0.2/go.mod h1:DkpGd78rljTxKAnTDPFqXSGxvETQnJyuSOQwsHycqfs= github.com/spf13/cobra v1.8.0 h1:7aJaZx1B85qltLMc546zn58BxxfZdR/W22ej9CFoEf0= github.com/spf13/cobra v1.8.0/go.mod h1:WXLWApfZ71AjXPya3WOlMsY9yMs7YeiHhFVlvLyhcho= github.com/spf13/pflag v1.0.5 h1:iy+VFUOCP1a+8yFto/drg2CJ5u0yRoB7fZw3DKv/JXA= diff --git a/internal/torrent/manager.go b/internal/torrent/manager.go index 84db83d..0495b39 100644 --- a/internal/torrent/manager.go +++ b/internal/torrent/manager.go @@ -610,6 +610,7 @@ func (t *TorrentManager) repairAll() { unselected := 0 torrent.SelectedFiles.IterCb(func(_ string, file *File) { if file.Link == "repair" && !forRepair { + file.Link = "repairing" t.log.Debugf("Found a file to repair for torrent %s", torrent.AccessKey) forRepair = true } @@ -646,7 +647,6 @@ func (t *TorrentManager) Delete(accessKey string) { torrents.Remove(accessKey) } }) - t.updateSortedKeys() } func (t *TorrentManager) Repair(accessKey string) { @@ -698,7 +698,7 @@ func (t *TorrentManager) Repair(accessKey string) { t.DirectoryMap.IterCb(func(_ string, torrents cmap.ConcurrentMap[string, *Torrent]) { torrents.Remove(torrent.AccessKey) }) - t.updateSortedKeys() + t.SetNewLatestState(EmptyState()) // t.log.Debugf("You can try fixing it yourself magnet:?xt=urn:btih:%s", info.Hash) return } else if streamableCount == 1 { @@ -707,7 +707,7 @@ func (t *TorrentManager) Repair(accessKey string) { t.DirectoryMap.IterCb(func(_ string, torrents cmap.ConcurrentMap[string, *Torrent]) { torrents.Remove(torrent.AccessKey) }) - t.updateSortedKeys() + t.SetNewLatestState(EmptyState()) return } // t.log.Debugf("Identified the expired files of torrent id=%s", info.ID) @@ -894,9 +894,9 @@ func (t *TorrentManager) updateSortedKeys() { } davRet = "" + dav.BaseDirectory(directory, "") + dav.BaseDirectory(directory, "") + davRet + "" - t.ResponseCache.Set(directory+".dav", davRet, 0) + t.ResponseCache.Set(directory+".dav", davRet, 1) htmlRet = "
    " + htmlRet - t.ResponseCache.Set(directory+".html", "
      "+htmlRet, 0) + t.ResponseCache.Set(directory+".html", "
        "+htmlRet, 1) }) }