Skip to content

Commit

Permalink
Use permissions code from directory
Browse files Browse the repository at this point in the history
  • Loading branch information
snoyberg committed Aug 15, 2018
1 parent ba8895d commit 1a98bff
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 17 deletions.
8 changes: 0 additions & 8 deletions subs/pantry/package.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -45,14 +45,6 @@ dependencies:
- yaml
- zip-archive

when:
- condition: os(windows)
then:
cpp-options: -DWINDOWS
else:
dependencies:
- unix

library:
source-dirs: src/
exposed-modules:
Expand Down
13 changes: 4 additions & 9 deletions subs/pantry/src/Pantry/Tree.hs
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
{-# LANGUAGE CPP #-}
{-# LANGUAGE NoImplicitPrelude #-}
{-# LANGUAGE OverloadedStrings #-}
{-# LANGUAGE ViewPatterns #-}
Expand All @@ -18,17 +17,13 @@ import qualified RIO.ByteString as B
import Pantry.Storage
import Pantry.Types
import RIO.FilePath ((</>), takeDirectory)
import RIO.Directory (createDirectoryIfMissing)
import RIO.Directory (createDirectoryIfMissing, setPermissions, getPermissions, setOwnerExecutable)
import Path (Path, Abs, Dir, toFilePath)
import Distribution.Parsec.Common (PWarning (..))
import Distribution.PackageDescription (packageDescription, package, GenericPackageDescription)
import Distribution.PackageDescription.Parsec
import Path (File)

#if !WINDOWS
import System.Posix.Files (setFileMode)
#endif

unpackTree
:: (HasPantryConfig env, HasLogFunc env)
=> Path Abs Dir -- ^ dest dir, will be created if necessary
Expand All @@ -43,11 +38,11 @@ unpackTree (toFilePath -> dir) (TreeMap m) = do
Nothing -> error $ "Missing blob: " ++ show blobKey
Just bs -> do
B.writeFile dest bs
#if !WINDOWS
case ft of
FTNormal -> pure ()
FTExecutable -> liftIO $ setFileMode dest 0o755
#endif
FTExecutable -> liftIO $ do
perms <- getPermissions dest
setPermissions dest $ setOwnerExecutable True perms

findCabalFile
:: MonadThrow m
Expand Down

0 comments on commit 1a98bff

Please sign in to comment.