Skip to content

Commit b3dbd89

Browse files
committed
Adapt code to tar-0.6
1 parent 2528053 commit b3dbd89

File tree

1 file changed

+12
-12
lines changed

1 file changed

+12
-12
lines changed

booster/tools/rpc-client/RpcClient.hs

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ module RpcClient (
1515
) where
1616

1717
import Codec.Archive.Tar qualified as Tar
18-
import Codec.Archive.Tar.Check qualified as Tar
18+
import Codec.Archive.Tar.Entry qualified as Tar
1919
import Codec.Compression.BZip qualified as BZ2
2020
import Codec.Compression.GZip qualified as GZip
2121
import Control.Exception
@@ -505,20 +505,24 @@ runTarball common (Just sock) tarFile keepGoing runOnly compareDetails = do
505505
| ".tar.bz2" `isSuffixOf` takeExtensions tarFile = Tar.read . BZ2.decompress
506506
| otherwise = Tar.read
507507

508-
containedFiles <- unpackTar <$> BS.readFile tarFile
509-
let checked = Tar.checkSecurity containedFiles
508+
entries <- Tar.decodeLongNames . unpackTar <$> BS.readFile tarFile
510509
-- probe server connection before doing anything, display
511510
-- instructions unless server was found.
512-
runAllRequests checked sock
511+
runAllRequests entries sock
513512
where
514513
runAllRequests ::
515-
Tar.Entries (Either Tar.FormatError Tar.FileNameError) -> Socket -> IO ()
514+
Tar.GenEntries
515+
FilePath
516+
a
517+
(Either Tar.FormatError Tar.DecodeLongNamesError) ->
518+
Socket ->
519+
IO ()
516520
runAllRequests checked skt = cancelIfInterrupted skt $ do
517521
withTempDir $ \tmp -> withLogLevel common.logLevel $ do
518522
-- unpack relevant tar files (rpc_* directories only)
519523
logInfo_ $ unwords ["unpacking json files from tarball", tarFile, "into", tmp]
520524
(jsonFiles, sequenceMap) <-
521-
liftIO $ Tar.foldEntries (unpackIfRpc tmp) (pure mempty) throwAnyError checked
525+
liftIO $ Tar.foldEntries (unpackIfRpc tmp) (pure mempty) (error . show) checked
522526
logInfo_ $ "RPC data:" <> show jsonFiles
523527
logInfo_ $ "Sequence data:" <> show sequenceMap
524528

@@ -543,10 +547,6 @@ runTarball common (Just sock) tarFile keepGoing runOnly compareDetails = do
543547
liftIO $ shutdown skt ShutdownReceive
544548
liftIO $ exitWith (if all isNothing results then ExitSuccess else ExitFailure 2)
545549

546-
-- complain on any errors in the tarball
547-
throwAnyError :: Either Tar.FormatError Tar.FileNameError -> IO a
548-
throwAnyError = either throwIO throwIO
549-
550550
compareSequence :: Ord a => Ord b => Map.Map a b -> a -> a -> Ordering
551551
compareSequence seqMap a b = case (Map.lookup a seqMap, Map.lookup b seqMap) of
552552
(Nothing, Nothing) -> compare a b
@@ -557,11 +557,11 @@ runTarball common (Just sock) tarFile keepGoing runOnly compareDetails = do
557557
-- unpack all */*.json files into dir and return their names
558558
unpackIfRpc ::
559559
FilePath ->
560-
Tar.Entry ->
560+
Tar.GenEntry FilePath a ->
561561
IO ([FilePath], Map.Map FilePath Int) ->
562562
IO ([FilePath], Map.Map FilePath Int)
563563
unpackIfRpc tmpDir entry acc = do
564-
case splitFileName (Tar.entryPath entry) of
564+
case splitFileName (Tar.entryTarPath entry) of
565565
-- unpack all directories "<something>" containing "*.json" files
566566
(dir, "") -- directory
567567
| Tar.Directory <- Tar.entryContent entry -> do

0 commit comments

Comments
 (0)