~jan0sch/smederee

Showing details for patch f915b8874c2ba49e48b06e17d379b0c830f7e470.
2024-02-08 (Thu), 9:11 AM - Jens Grassel - f915b8874c2ba49e48b06e17d379b0c830f7e470

Hub: Fix broken source tarball downloads.

- create directory structure properly _before_ packaging files

Fixes: https://tickets.smeder.ee/~jan0sch/smederee/tickets/7
Summary of changes
1 files modified with 8 lines added and 6 lines removed
  • modules/hub/src/main/scala/de/smederee/hub/VcsRepositoryRoutes.scala with 8 added and 6 removed lines
diff -rN -u old-smederee/modules/hub/src/main/scala/de/smederee/hub/VcsRepositoryRoutes.scala new-smederee/modules/hub/src/main/scala/de/smederee/hub/VcsRepositoryRoutes.scala
--- old-smederee/modules/hub/src/main/scala/de/smederee/hub/VcsRepositoryRoutes.scala	2025-01-12 22:01:36.969734088 +0000
+++ new-smederee/modules/hub/src/main/scala/de/smederee/hub/VcsRepositoryRoutes.scala	2025-01-12 22:01:36.969734088 +0000
@@ -215,13 +215,15 @@
             repositoryName: String,
             targetDirectory: os.Path
         ): F[(Int, Chain[String], Chain[String])] = {
-            val targetFile     = targetDirectory / s"${repositoryName}.tar.gz"
-            val tempTargetFile = Files.createTempFile(targetDirectory.toNIO, "download", s"${repositoryName}.tar.gz")
-            log.debug(s"Packaging repository $repositoryName into $targetFile.")
-            val tarOptions      = List("-czf", tempTargetFile.toString, "--exclude=_darcs", repositoryName.toString)
-            val externalCommand = os.proc("tar", tarOptions)
+            val targetFile = targetDirectory / s"${repositoryName}.tar.gz"
             for {
-                _       <- Sync[F].delay(Files.createDirectories(targetDirectory.toNIO))
+                _ <- Sync[F].delay(Files.createDirectories(targetDirectory.toNIO))
+                tempTargetFile <- Sync[F].delay(
+                    Files.createTempFile(targetDirectory.toNIO, "download", s"${repositoryName}.tar.gz")
+                )
+                _ <- Sync[F].delay(log.debug(s"Packaging repository $repositoryName into $targetFile."))
+                tarOptions      = List("-czf", tempTargetFile.toString, "--exclude=_darcs", repositoryName.toString)
+                externalCommand = os.proc("tar", tarOptions)
                 process <- Sync[F].delay(externalCommand.call(cwd = basePath, check = false))
                 _       <- Sync[F].delay(os.remove(targetFile))
                 _       <- Sync[F].delay(os.move(os.Path(tempTargetFile), targetFile))