Skip to content

Commit

Permalink
Tidy up a bit
Browse files Browse the repository at this point in the history
  • Loading branch information
tchoutri committed May 31, 2024
1 parent 5236493 commit 01cbd64
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 13 deletions.
4 changes: 2 additions & 2 deletions confer.cabal
Original file line number Diff line number Diff line change
Expand Up @@ -116,10 +116,10 @@ executable confer
build-depends:
, base
, confer
, filepath
, containers
, effectful
, effectful-core
, filepath
, optparse-applicative

if flag(development)
Expand All @@ -138,9 +138,9 @@ test-suite confer-test
build-depends:
, base
, confer
, containers
, directory
, effectful-core
, filepath
, tasty
, tasty-hunit
, containers
21 changes: 10 additions & 11 deletions src/Confer/Effect/Symlink.hs
Original file line number Diff line number Diff line change
Expand Up @@ -70,19 +70,18 @@ runSymlinkIO = interpret $ \_ -> \case
Directory ->
createDirectoryLink sourcePath destinationPath
DeleteSymlink _ -> todo
TestSymlink target' -> do
target <- liftIO $ OsPath.decodeFS target'
liftIO $ catch (do
result <- Directory.pathIsSymbolicLink target
if result
then pure $ Right ()
else pure $ Left (IsNotSymlink target')
)
(\exception -> do
TestSymlink target -> do
filepath <- liftIO $ OsPath.decodeFS $ target
isSymbolic <- FileSystem.pathIsSymbolicLink filepath
liftIO $ catch (testPath isSymbolic) $ \exception -> do
if isDoesNotExistError exception
then pure $ Left (DoesNotExist target')
then pure $ Left (DoesNotExist target)
else pure $ Right ()
)
where
testPath pathIsSymbolic = do
if pathIsSymbolic
then pure $ Right ()
else pure $ Left (IsNotSymlink target)

runSymlinkPure
:: Map OsPath OsPath
Expand Down

0 comments on commit 01cbd64

Please sign in to comment.