Skip to content

Commit

Permalink
Remove unused repositoryURL parameter
Browse files Browse the repository at this point in the history
  • Loading branch information
tchoutri committed Nov 2, 2024
1 parent 578cae5 commit 5b670b6
Show file tree
Hide file tree
Showing 5 changed files with 15 additions and 13 deletions.
4 changes: 2 additions & 2 deletions app/cli/Main.hs
Original file line number Diff line number Diff line change
Expand Up @@ -232,8 +232,8 @@ importIndex path repository = do
mPackageIndex <- Query.getPackageIndexByName repository
case mPackageIndex of
Nothing -> error $ Text.unpack $ "Package index " <> repository <> " not found in the database!"
Just packageIndex ->
importFromIndex (user ^. #userId) (repository, packageIndex.url) path
Just _ ->
importFromIndex (user ^. #userId) repository path

importPackageTarball
:: ( Log :> es
Expand Down
12 changes: 6 additions & 6 deletions src/core/Flora/Import/Package/Bulk.hs
Original file line number Diff line number Diff line change
Expand Up @@ -79,10 +79,10 @@ importAllFilesInRelativeDirectory user (repositoryName, repositoryURL) dir = do
importFromIndex
:: (Time :> es, Log :> es, Poolboy :> es, DB :> es, IOE :> es)
=> UserId
-> (Text, Text)
-> Text
-> FilePath
-> Eff es ()
importFromIndex user (repositoryName, repositoryURL) index = do
importFromIndex user repositoryName index = do
entries <- Tar.read . GZip.decompress <$> liftIO (BL.readFile index)
let Right repositoryPackages = buildPackageListFromArchive entries

Check warning on line 87 in src/core/Flora/Import/Package/Bulk.hs

View workflow job for this annotation

GitHub Actions / Backend_tests (9.6.6, ubuntu-latest)

Pattern match(es) are non-exhaustive
Log.logInfo "packages" $
Expand All @@ -102,7 +102,7 @@ importFromIndex user (repositoryName, repositoryURL) index = do
Right stream ->
importFromStream
user
(repositoryName, repositoryURL, repositoryPackages)
(repositoryName, repositoryPackages)
stream
Left (err, _) ->
Log.logAttention_ $
Expand Down Expand Up @@ -135,16 +135,16 @@ importAllFilesInDirectory user (repositoryName, repositoryURL) dir = do
liftIO $ System.createDirectoryIfMissing True dir
packages <- buildPackageListFromDirectory dir
liftIO . putStrLn $ "🔎 Searching cabal files in " <> dir
importFromStream user (repositoryName, repositoryURL, packages) (findAllCabalFilesInDirectory dir)
importFromStream user (repositoryName, packages) (findAllCabalFilesInDirectory dir)

importFromStream
:: forall es
. (Time :> es, Log :> es, Poolboy :> es, DB :> es, IOE :> es)
=> UserId
-> (Text, Text, Set PackageName)
-> (Text, Set PackageName)
-> Stream (Eff es) (ImportFileType, UTCTime, StrictByteString)
-> Eff es ()
importFromStream user (repositoryName, _repositoryURL, repositoryPackages) stream = do
importFromStream user (repositoryName, repositoryPackages) stream = do
tarballHashIORef <- liftIO $ IORef.newIORef Map.empty
let cfg = maxThreads numCapabilities . ordered True
processedPackageCount <-
Expand Down
5 changes: 2 additions & 3 deletions src/jobs-worker/FloraJobs/Runner.hs
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,6 @@ import Flora.Model.Job
import Flora.Model.Package.Types
import Flora.Model.Package.Update qualified as Update
import Flora.Model.PackageIndex.Query qualified as Query
import Flora.Model.PackageIndex.Types (PackageIndex (..))
import Flora.Model.Release.Query qualified as Query
import Flora.Model.Release.Types
import Flora.Model.Release.Update qualified as Update
Expand Down Expand Up @@ -245,5 +244,5 @@ refreshIndexes = do
case mPackageIndex of
Nothing ->
error $ Text.unpack $ "Package index " <> indexName <> " not found in the database!"
Just packageIndex ->
Import.importFromIndex user.userId (indexName, packageIndex.url) path
Just _ ->
Import.importFromIndex user.userId indexName path
4 changes: 2 additions & 2 deletions test/Flora/ImportSpec.hs
Original file line number Diff line number Diff line change
Expand Up @@ -46,8 +46,8 @@ testImportIndex fixture = withStdOutLogger $
Nothing -> Update.createPackageIndex defaultRepo defaultRepoURL defaultDescription Nothing
Just _ -> pure ()
importFromIndex
(fixture.hackageUser.userId)
(defaultRepo, defaultRepoURL)
fixture.hackageUser.userId
defaultRepo
testIndex
-- check the packages have been imported
tars <- traverse (Query.getPackageByNamespaceAndName (Namespace defaultRepo) . PackageName) ["tar-a", "tar-b"]
Expand Down
3 changes: 3 additions & 0 deletions test/Main.hs
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,9 @@ cleanUp = dbtToEff $ do
void $ execute Delete "DELETE FROM downloads" ()
void $ execute Delete "DELETE FROM requirements" ()
void $ execute Delete "DELETE FROM package_components" ()
void $ execute Delete "DELETE FROM affected_packages" ()
void $ execute Delete "DELETE FROM affected_version_ranges" ()
void $ execute Delete "DELETE FROM security_advisories" ()
void $ execute Delete "DELETE FROM releases" ()
void $ execute Delete "DELETE FROM packages" ()
void $ execute Delete "DELETE FROM package_indexes" ()
Expand Down

0 comments on commit 5b670b6

Please sign in to comment.