From d63edf53b6f62fbf553e6f4a51ded042cf86055f Mon Sep 17 00:00:00 2001 From: Alex Archambault Date: Mon, 21 Oct 2024 19:46:33 +0200 Subject: [PATCH 1/2] Clean-up indices dir before writing indices to it This ensures all indices are effectively re-generated, so that we don't mistakenly stop generating one --- src/coursier/jvmindex/GenerateIndex.scala | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/src/coursier/jvmindex/GenerateIndex.scala b/src/coursier/jvmindex/GenerateIndex.scala index a09f22a..c7c8ee2 100644 --- a/src/coursier/jvmindex/GenerateIndex.scala +++ b/src/coursier/jvmindex/GenerateIndex.scala @@ -49,8 +49,12 @@ object GenerateIndex { os.write.over(dest, json) System.err.println(s"Wrote $dest") + val indicesDir = os.pwd / "indices" + + System.err.println(s"Removed $indicesDir") + os.remove.all(indicesDir) for (((os0, arch), osArchIndex) <- index.osArchIndices.toVector.sortBy(_._1)) { - val dest0 = os.pwd / "indices" / s"$os0-$arch.json" + val dest0 = indicesDir / s"$os0-$arch.json" val json0 = osArchIndex.json os.write.over(dest0, json0, createFolders = true) System.err.println(s"Wrote $dest0") From 720fcb543a5a37fa82c7b5dd0cf0f8535969560f Mon Sep 17 00:00:00 2001 From: Alex Archambault Date: Mon, 21 Oct 2024 19:47:25 +0200 Subject: [PATCH 2/2] Log relative paths when writing indices --- src/coursier/jvmindex/GenerateIndex.scala | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/src/coursier/jvmindex/GenerateIndex.scala b/src/coursier/jvmindex/GenerateIndex.scala index c7c8ee2..f900592 100644 --- a/src/coursier/jvmindex/GenerateIndex.scala +++ b/src/coursier/jvmindex/GenerateIndex.scala @@ -19,7 +19,7 @@ object GenerateIndex { val baseName = "index" - val dest = os.pwd / s"$baseName.json" + val dest = os.sub / s"$baseName.json" val pool = Executors.newFixedThreadPool(6) @@ -46,17 +46,17 @@ object GenerateIndex { pool.shutdown() val json = index.json - os.write.over(dest, json) + os.write.over(os.pwd / dest, json) System.err.println(s"Wrote $dest") - val indicesDir = os.pwd / "indices" + val indicesDir = os.sub / "indices" System.err.println(s"Removed $indicesDir") - os.remove.all(indicesDir) + os.remove.all(os.pwd / indicesDir) for (((os0, arch), osArchIndex) <- index.osArchIndices.toVector.sortBy(_._1)) { val dest0 = indicesDir / s"$os0-$arch.json" val json0 = osArchIndex.json - os.write.over(dest0, json0, createFolders = true) + os.write.over(os.pwd / dest0, json0, createFolders = true) System.err.println(s"Wrote $dest0") } }