Skip to content

Commit 6dd1a8d

Browse files
committed
Restore return type of toLinkTarget to Maybe LinkTarget for the sake of backward compatibility
1 parent 0926e16 commit 6dd1a8d

File tree

3 files changed

+12
-15
lines changed

3 files changed

+12
-15
lines changed

Codec/Archive/Tar/Check/Internal.hs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,6 @@ module Codec.Archive.Tar.Check.Internal (
4040
import Codec.Archive.Tar.LongNames
4141
import Codec.Archive.Tar.Types
4242
import Control.Applicative ((<|>))
43-
import Control.Monad.Catch (MonadThrow(throwM))
4443
import qualified Data.ByteString.Lazy.Char8 as Char8
4544
import Data.Maybe (fromMaybe)
4645
import Data.Typeable (Typeable)

Codec/Archive/Tar/Types.hs

Lines changed: 9 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,6 @@ module Codec.Archive.Tar.Types (
5353

5454
LinkTarget(..),
5555
toLinkTarget,
56-
toLinkTarget',
5756
fromLinkTarget,
5857
fromLinkTargetToPosixPath,
5958
fromLinkTargetToWindowsPath,
@@ -78,7 +77,6 @@ import qualified Data.ByteString.Char8 as BS.Char8
7877
import qualified Data.ByteString.Lazy as LBS
7978
import Control.DeepSeq
8079
import Control.Exception (Exception, displayException)
81-
import Control.Monad.Catch (MonadThrow, throwM)
8280

8381
import qualified System.FilePath as FilePath.Native
8482
( joinPath, splitDirectories, addTrailingPathSeparator, hasTrailingPathSeparator, pathSeparator, isAbsolute, hasTrailingPathSeparator )
@@ -489,11 +487,12 @@ instance NFData LinkTarget where
489487
-- | Convert a native 'FilePath' to a tar 'LinkTarget'.
490488
-- string is longer than 100 characters or if it contains non-portable
491489
-- characters.
492-
toLinkTarget :: MonadThrow m => FilePath -> m LinkTarget
493-
toLinkTarget path | length path <= 100 = do
494-
target <- toLinkTarget' path
495-
pure $! LinkTarget (packAscii target)
496-
| otherwise = throwM (TooLong path)
490+
toLinkTarget :: FilePath -> Maybe LinkTarget
491+
toLinkTarget path
492+
| length path <= 100 = do
493+
target <- toLinkTarget' path
494+
Just $! LinkTarget (packAscii target)
495+
| otherwise = Nothing
497496

498497
data LinkTargetException = IsAbsolute FilePath
499498
| TooLong FilePath
@@ -505,10 +504,10 @@ instance Exception LinkTargetException where
505504

506505
-- | Convert a native 'FilePath' to a unix filepath suitable for
507506
-- using as 'LinkTarget'. Does not error if longer than 100 characters.
508-
toLinkTarget' :: MonadThrow m => FilePath -> m FilePath
507+
toLinkTarget' :: FilePath -> Maybe FilePath
509508
toLinkTarget' path
510-
| FilePath.Native.isAbsolute path = throwM (IsAbsolute path)
511-
| otherwise = pure $ adjustDirectory $ FilePath.Posix.joinPath $ FilePath.Native.splitDirectories path
509+
| FilePath.Native.isAbsolute path = Nothing
510+
| otherwise = Just $ adjustDirectory $ FilePath.Posix.joinPath $ FilePath.Native.splitDirectories path
512511
where
513512
adjustDirectory | FilePath.Native.hasTrailingPathSeparator path
514513
= FilePath.Posix.addTrailingPathSeparator

tar.cabal

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -48,13 +48,12 @@ library
4848

4949
library tar-internal
5050
default-language: Haskell2010
51-
build-depends: base >= 4.11.0.0 && < 5,
51+
build-depends: base >= 4.11 && < 5,
5252
array < 0.6,
5353
bytestring >= 0.10 && < 0.13,
5454
containers >= 0.2 && < 0.8,
5555
deepseq >= 1.1 && < 1.6,
5656
directory >= 1.3.1 && < 1.4,
57-
exceptions,
5857
filepath < 1.5,
5958
time < 1.13
6059

@@ -88,7 +87,7 @@ library tar-internal
8887
test-suite properties
8988
type: exitcode-stdio-1.0
9089
default-language: Haskell2010
91-
build-depends: base,
90+
build-depends: base < 5,
9291
array,
9392
bytestring >= 0.10,
9493
containers,
@@ -131,7 +130,7 @@ benchmark bench
131130
default-language: Haskell2010
132131
hs-source-dirs: bench
133132
main-is: Main.hs
134-
build-depends: base,
133+
build-depends: base < 5,
135134
tar,
136135
bytestring >= 0.10,
137136
filepath,

0 commit comments

Comments
 (0)