switch from conduit responses to file responses

This commit is contained in:
Keagan McClelland
2022-02-15 17:08:34 -07:00
parent d526eda69c
commit 9da5c1e9b3
3 changed files with 18 additions and 31 deletions

View File

@@ -298,16 +298,9 @@ getHash pkg version = do
let hashPath = root </> show pkg </> show version </> "hash.bin"
liftIO $ readFile hashPath
getPackage :: (MonadResource m, MonadReader r m, Has PkgRepo r)
=> PkgId
-> Version
-> m (Maybe (Integer, ConduitT () ByteString m ()))
getPackage :: (MonadResource m, MonadReader r m, Has PkgRepo r) => PkgId -> Version -> m (Maybe FilePath)
getPackage pkg version = do
root <- asks pkgRepoFileRoot
let pkgPath = root </> show pkg </> show version </> show pkg <.> "s9pk"
found <- doesPathExist pkgPath
if found
then do
n <- getFileSize pkgPath
pure . Just $ (n, sourceFile pkgPath)
else pure Nothing
pure $ if found then Just pkgPath else Nothing