From 5b670b637b69bccf3de52bbab743ddaaad6e9787 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Th=C3=A9ophile=20Choutri?= Date: Sat, 2 Nov 2024 13:11:23 +0100 Subject: [PATCH] Remove unused repositoryURL parameter --- app/cli/Main.hs | 4 ++-- src/core/Flora/Import/Package/Bulk.hs | 12 ++++++------ src/jobs-worker/FloraJobs/Runner.hs | 5 ++--- test/Flora/ImportSpec.hs | 4 ++-- test/Main.hs | 3 +++ 5 files changed, 15 insertions(+), 13 deletions(-) diff --git a/app/cli/Main.hs b/app/cli/Main.hs index f6c411af..d631905d 100644 --- a/app/cli/Main.hs +++ b/app/cli/Main.hs @@ -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 diff --git a/src/core/Flora/Import/Package/Bulk.hs b/src/core/Flora/Import/Package/Bulk.hs index 343c25a7..4ebb3386 100644 --- a/src/core/Flora/Import/Package/Bulk.hs +++ b/src/core/Flora/Import/Package/Bulk.hs @@ -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 Log.logInfo "packages" $ @@ -102,7 +102,7 @@ importFromIndex user (repositoryName, repositoryURL) index = do Right stream -> importFromStream user - (repositoryName, repositoryURL, repositoryPackages) + (repositoryName, repositoryPackages) stream Left (err, _) -> Log.logAttention_ $ @@ -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 <- diff --git a/src/jobs-worker/FloraJobs/Runner.hs b/src/jobs-worker/FloraJobs/Runner.hs index ef4cdd00..d481a411 100644 --- a/src/jobs-worker/FloraJobs/Runner.hs +++ b/src/jobs-worker/FloraJobs/Runner.hs @@ -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 @@ -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 diff --git a/test/Flora/ImportSpec.hs b/test/Flora/ImportSpec.hs index 79bdf9d6..f32278f8 100644 --- a/test/Flora/ImportSpec.hs +++ b/test/Flora/ImportSpec.hs @@ -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"] diff --git a/test/Main.hs b/test/Main.hs index 2a6a3838..36b1f7d0 100644 --- a/test/Main.hs +++ b/test/Main.hs @@ -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" ()