Skip to content

Commit

Permalink
Handler.TorrentFile: don't includeOtherWebseeds for getTorrentFileFor…
Browse files Browse the repository at this point in the history
…WebtorrentR

this usually causes a full download by webtorrent which gets rejected by
browsers due to Same Origin Policy only when finished.
  • Loading branch information
astro committed Jan 1, 2018
1 parent ffa14f8 commit d30a73c
Showing 1 changed file with 9 additions and 3 deletions.
12 changes: 9 additions & 3 deletions Handler/TorrentFile.hs
Expand Up @@ -30,10 +30,13 @@ instance ToTypedContent RepTorrent where

-- |Does the same but is on different routes for stats.
getTorrentFileForWebtorrentR :: UserName -> Text -> TorrentName -> Handler RepTorrent
getTorrentFileForWebtorrentR = getTorrentFileR
getTorrentFileForWebtorrentR = getTorrentFile False

getTorrentFileR :: UserName -> Text -> TorrentName -> Handler RepTorrent
getTorrentFileR user slug (TorrentName name) = do
getTorrentFileR = getTorrentFile True

getTorrentFile :: Bool -> UserName -> Text -> TorrentName -> Handler RepTorrent
getTorrentFile includeOtherWebseeds user slug (TorrentName name) = do
mInfo <- withDB $ \db -> do
torrents <- Model.torrentByName user slug name db
case torrents of
Expand All @@ -51,7 +54,10 @@ getTorrentFileR user slug (TorrentName name) = do
seedUrl <- T.append "https://bitlove.org" <$>
($ WebSeedR (HexInfoHash infoHash) name) <$>
getUrlRender
let mBuf = updateTorrent [seedUrl] guids buf
let seedUrls
| includeOtherWebseeds = [seedUrl]
| otherwise = []
mBuf = updateTorrent seedUrls buf
case mBuf of
Just buf' ->
return $ RepTorrent $ toContent buf'
Expand Down

0 comments on commit d30a73c

Please sign in to comment.