apply hint suggestions

This commit is contained in:
Keagan McClelland
2022-05-23 13:23:54 -06:00
parent ae336445bd
commit bb8fe05db6
4 changed files with 19 additions and 21 deletions

View File

@@ -111,7 +111,7 @@ transitiveUpdate f = update (update @a @b f)
setWebProcessThreadId :: (ThreadId, ThreadId) -> RegistryCtx -> IO ()
setWebProcessThreadId tid a = putMVar (appWebServerThreadId a) $ tid
setWebProcessThreadId tid a = putMVar (appWebServerThreadId a) tid
-- This is where we define all of the routes in our application. For a full
-- explanation of the syntax, please see:
@@ -173,11 +173,10 @@ instance Yesod RegistryCtx where
<> str
)
)
<> (toLogStr
<> toLogStr
(wrapSGRCode [SetColor Foreground Dull White]
[i| @ #{loc_filename loc}:#{fst $ loc_start loc}\n|]
)
)
loggerPutStr logger formatted
where
renderLvl lvl = case lvl of
@@ -242,4 +241,4 @@ unsafeHandler = Unsafe.fakeHandlerGetLogger appLogger
-- https://github.com/yesodweb/yesod/wiki/i18n-messages-in-the-scaffolding
appLogFunc :: RegistryCtx -> LogFunc
appLogFunc = appLogger >>= flip messageLoggerSource
appLogFunc = appLogger <**> messageLoggerSource

View File

@@ -67,6 +67,7 @@ import Model
import Startlude ( ($)
, (&&)
, (.)
, (/=)
, (<$>)
, Bool(..)
, ByteString
@@ -140,7 +141,7 @@ import Yesod.Core.Content ( typeGif
)
import Yesod.Core.Types ( ContentType )
data ManifestParseException = ManifestParseException FilePath
newtype ManifestParseException = ManifestParseException FilePath
deriving Show
instance Exception ManifestParseException
@@ -149,7 +150,7 @@ data PkgRepo = PkgRepo
, pkgRepoAppMgrBin :: FilePath
}
data EosRepo = EosRepo
newtype EosRepo = EosRepo
{ eosRepoFileRoot :: FilePath
}
@@ -161,7 +162,7 @@ getVersionsFor pkg = do
if exists
then do
subdirs <- listDirectory pkgDir
let (failures, successes) = partitionEithers $ (Atto.parseOnly parseVersion . T.pack) <$> subdirs
let (failures, successes) = partitionEithers $ Atto.parseOnly parseVersion . T.pack <$> subdirs
for_ failures $ \f -> $logWarn [i|Emver Parse Failure for #{pkg}: #{f}|]
pure successes
else pure []
@@ -186,13 +187,11 @@ loadPkgDependencies appConnPool manifest = do
let deps' = first PkgRecordKey <$> HM.toList deps
for_
deps'
(\d ->
(runSqlPool
( insertUnique
$ PkgDependency time (PkgRecordKey pkgId) pkgVersion (fst d) (packageDependencyVersion . snd $ d)
)
appConnPool
(\d -> runSqlPool
( insertUnique
$ PkgDependency time (PkgRecordKey pkgId) pkgVersion (fst d) (packageDependencyVersion . snd $ d)
)
appConnPool
)
-- extract all package assets into their own respective files
@@ -232,7 +231,7 @@ extractPkg pool fp = handle @_ @SomeException cleanup $ do
$logError $ show e
let pkgRoot = takeDirectory fp
fs <- listDirectory pkgRoot
let toRemove = filter (not . (== ".s9pk") . takeExtension) fs
let toRemove = filter ((/=) ".s9pk" . takeExtension) fs
mapConcurrently_ (removeFile . (pkgRoot </>)) toRemove
throwIO e
@@ -295,7 +294,7 @@ getManifest pkg version = do
root <- asks pkgRepoFileRoot
let manifestPath = root </> show pkg </> show version </> "manifest.json"
n <- getFileSize manifestPath
pure $ (n, sourceFile manifestPath)
pure (n, sourceFile manifestPath)
getInstructions :: (MonadResource m, MonadReader r m, Has PkgRepo r)
=> PkgId
@@ -305,7 +304,7 @@ getInstructions pkg version = do
root <- asks pkgRepoFileRoot
let instructionsPath = root </> show pkg </> show version </> "instructions.md"
n <- getFileSize instructionsPath
pure $ (n, sourceFile instructionsPath)
pure (n, sourceFile instructionsPath)
getLicense :: (MonadResource m, MonadReader r m, Has PkgRepo r)
=> PkgId
@@ -315,7 +314,7 @@ getLicense pkg version = do
root <- asks pkgRepoFileRoot
let licensePath = root </> show pkg </> show version </> "license.md"
n <- getFileSize licensePath
pure $ (n, sourceFile licensePath)
pure (n, sourceFile licensePath)
getIcon :: (MonadResource m, MonadReader r m, Has PkgRepo r)
=> PkgId
@@ -326,7 +325,7 @@ getIcon pkg version = do
let pkgRoot = root </> show pkg </> show version
mIconFile <- find ((== "icon") . takeBaseName) <$> listDirectory pkgRoot
case mIconFile of
Nothing -> throwIO $ NotFoundE $ [i|#{pkg}: Icon|]
Nothing -> throwIO $ NotFoundE [i|#{pkg}: Icon|]
Just x -> do
let ct = case takeExtension x of
".png" -> typePng
@@ -336,7 +335,7 @@ getIcon pkg version = do
".gif" -> typeGif
_ -> typePlain
n <- getFileSize (pkgRoot </> x)
pure $ (ct, n, sourceFile (pkgRoot </> x))
pure (ct, n, sourceFile (pkgRoot </> x))
getHash :: (MonadIO m, MonadReader r m, Has PkgRepo r) => PkgId -> Version -> m ByteString
getHash pkg version = do

View File

@@ -61,7 +61,7 @@ instance ToJSONKey PkgId where
instance PersistField PkgId where
toPersistValue = PersistText . show
fromPersistValue (PersistText t) = Right . PkgId $ toS t
fromPersistValue other = Left $ [i|Invalid AppId: #{other}|]
fromPersistValue other = Left [i|Invalid AppId: #{other}|]
instance PersistFieldSql PkgId where
sqlType _ = SqlString
instance PathPiece PkgId where

View File

@@ -17,10 +17,10 @@ import Database.Persist ( PersistField(..)
import Database.Persist.Sql ( PersistFieldSql(..) )
import Startlude ( ($)
, (.)
, Bifunctor(bimap, first)
, ByteString
, Either(Left)
, Semigroup((<>))
, bimap
, decodeUtf8
, encodeUtf8
, join