Skip to content
This repository was archived by the owner on Dec 7, 2023. It is now read-only.

Commit 1ff490e

Browse files
committed
Share version JARs (by hash)
1 parent f2a2a1e commit 1ff490e

File tree

4 files changed

+10
-7
lines changed

4 files changed

+10
-7
lines changed

src/HellSmack/Curse.hs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,6 @@ import Relude.Extra.Group
5050
import Text.Layout.Table qualified as TL
5151
import Text.Layout.Table.Cell.Formatted qualified as TL
5252
import UnliftIO.Directory qualified as FP
53-
import UnliftIO.Exception
5453
import UnliftIO.Temporary
5554

5655
data ModpackManifest = ModpackManifest

src/HellSmack/ModLoader/Forge.hs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,6 @@ import HellSmack.Util.Meta qualified as Meta
2626
import HellSmack.Vanilla qualified as V
2727
import HellSmack.Yggdrasil
2828
import System.IO.Temp
29-
import UnliftIO.Exception
3029
import UnliftIO.IO
3130

3231
-- $setup

src/HellSmack/Util/Exception.hs

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,9 @@
11
module HellSmack.Util.Exception
22
( -- * Exceptions
33
rethrow,
4+
throwString,
45
reThrow,
6+
throwStringM,
57
)
68
where
79

@@ -13,3 +15,6 @@ rethrow = either throwString pure
1315

1416
reThrow :: MonadIO m => CatchT m a -> m a
1517
reThrow = runCatchT >=> either throwIO pure
18+
19+
throwStringM :: (MonadThrow m, HasCallStack) => String -> m a
20+
throwStringM = throwM . stringException

src/HellSmack/Vanilla.hs

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -70,7 +70,6 @@ import HellSmack.Util
7070
import HellSmack.Util.Meta qualified as Meta
7171
import HellSmack.Yggdrasil
7272
import Text.Regex.Pcre2
73-
import UnliftIO.Exception
7473

7574
data AllVersionsManifest = AllVersionsManifest
7675
{ latest :: LatestVersion,
@@ -431,10 +430,11 @@ mainJarPath ::
431430
mainJarPath vm = do
432431
side <- mcSideName
433432
versionDir <- siehs @DirConfig #versionDir
434-
let mcVersion = vm ^. #id . to unMCVersion . unpacked
435-
vmid <- parseRelDir mcVersion
436-
sideJar <- parseRelFile [i|$mcVersion-$side.jar|]
437-
pure $ versionDir </> vmid </> sideJar
433+
download <- maybe (throwStringM [i|unknown MC side: $side|]) pure =<< getMainDownload vm
434+
-- the forge prefix exists due to a weird mechanic introduced in 1.17.1-37.0.29
435+
-- also see 0d38e659d5969dd89cb6452758a48688dcf99b18
436+
hashJar <- parseRelFile $ [i|forge-${}.jar|] $ download ^. #sha1 . to unSHA1
437+
pure $ versionDir </> hashJar
438438

439439
downloadMainJar ::
440440
(MonadUnliftIO m, MRHasAll r [DirConfig, MCSide, Manager] m) => VersionManifest -> m ()

0 commit comments

Comments
 (0)