This commit is contained in:
Aaron Greenspan
2019-12-24 22:23:07 -07:00
parent 840acbcac6
commit 2188208ce0
2 changed files with 8 additions and 3 deletions

View File

@@ -52,7 +52,10 @@ getAppR (S9PK appId) = getApp appResourceDir appId
getApp :: FilePath -> FilePath -> Handler TypedContent
getApp rootDir appId = do
spec <- querySpecD mostRecentVersion <$> lookupGetParam "spec"
appVersions <- registeredAppVersions appId <$> loadRegistry rootDir
reg <- loadRegistry rootDir
putStrLn ("got registry" :: String)
let appVersions = registeredAppVersions appId reg
putStrLn $ "valid appversion for " <> appId <> ": " <> show (fmap version appVersions)
case getSpecifiedAppVersion spec appVersions of
Nothing -> respondSource typePlain sendFlush
Just (RegisteredAppVersion (_, filePath)) -> do

View File

@@ -38,10 +38,10 @@ sysResourceDir :: FilePath
sysResourceDir = resourcesPath </> "sys"
appManifestPath :: FilePath
appManifestPath = appResourceDir </> "apps.yaml"
appManifestPath = appResourceDir </> appManifestFile
appManifestFile :: FilePath
appManifestFile = "apps.yml"
appManifestFile = "apps.yaml"
s9pkExt :: String -> FilePath
s9pkExt = show . S9PK
@@ -61,9 +61,11 @@ loadSysRegistry = loadRegistry sysResourceDir
loadRegistry :: MonadIO m => FilePath -> m Registry
loadRegistry rootDirectory = liftIO $ do
appDirectories <- getSubDirectories rootDirectory
putStrLn $ "got appDirectories for " <> rootDirectory <> ": " <> show appDirectories
foldM
( \registry appId -> do
subdirs <- getSubDirectories (rootDirectory </> appId)
putStrLn $ "got appDirectories for " <> (rootDirectory </> appId) <> ": " <> show subdirs
let validVersions = mapMaybe readMaybe subdirs
versionApps <- for validVersions $ \v ->
getAppFileFromDir rootDirectory appId v