Skip to content

Commit

Permalink
Delete Framework and dSYM before unzipping cached version
Browse files Browse the repository at this point in the history
  • Loading branch information
tmspzz committed May 8, 2017
1 parent c4619a5 commit f527fd2
Showing 1 changed file with 55 additions and 0 deletions.
55 changes: 55 additions & 0 deletions src/Lib.hs
Original file line number Diff line number Diff line change
Expand Up @@ -774,6 +774,7 @@ downloadFrameworkAndDsymFromCaches s3BucketName
e2 <- runExceptT $ do
frameworkBinary <- getFrameworkFromS3 s3BucketName reverseRomeMap fVersion platform
saveBinaryToLocalCache lCacheDir frameworkBinary remoteFrameworkUploadPath fwn verbose
deleteFrameworkDirectory fVersion platform verbose
unzipBinary frameworkBinary fwn frameworkZipName verbose <* makeExecutable platform f
whenLeft sayFunc2 e2
) (env, verbose)
Expand All @@ -791,6 +792,7 @@ downloadFrameworkAndDsymFromCaches s3BucketName
e2 <- runExceptT $ do
dSYMBinary <- getDSYMFromS3 s3BucketName reverseRomeMap fVersion platform
saveBinaryToLocalCache lCacheDir dSYMBinary remotedSYMUploadPath dSYMName verbose
deleteDSYMDirectory fVersion platform verbose
unzipBinary dSYMBinary dSYMName dSYMZipName verbose
whenLeft sayFunc2 e2
) (env, verbose)
Expand Down Expand Up @@ -840,6 +842,55 @@ makeExecutable p fname = Turtle.chmod Turtle.executable



-- | Delete a directory an all it's contents
deleteDirectory :: MonadIO m
=> FilePath -- ^ The path to the directory to delete
-> Bool -- ^ A flag controlling verbosity
-> m ()
deleteDirectory path
verbose = do
directoryExists <- liftIO $ doesDirectoryExist path
let sayFunc = if verbose then sayLnWithTime else sayLn
when directoryExists $ do
Turtle.rmtree . Turtle.fromString $ path
when verbose $
sayFunc $ "Deleted: " <> path



-- | Deletes a Framework from the Carthage Build folder
deleteFrameworkDirectory :: MonadIO m
=> FrameworkVersion -- ^ The `FrameworkVersion` identifying the Framework to delete
-> TargetPlatform -- ^ The `TargetPlatform` to restrict this operation to
-> Bool -- ^ A flag controlling verbosity
-> m ()
deleteFrameworkDirectory (FrameworkVersion f@(FrameworkName fwn) version)
platform
verbose =
deleteDirectory frameworkDirectory verbose
where
frameworkNameWithFrameworkExtension = appendFrameworkExtensionTo f
platformBuildDirectory = carthageBuildDirectoryForPlatform platform
frameworkDirectory = platformBuildDirectory </> frameworkNameWithFrameworkExtension



-- | Deletes a dSYM from the Carthage Build folder
deleteDSYMDirectory :: MonadIO m
=> FrameworkVersion -- ^ The `FrameworkVersion` identifying the dSYM to delete
-> TargetPlatform -- ^ The `TargetPlatform` to restrict this operation to
-> Bool -- ^ A flag controlling verbosity
-> m ()
deleteDSYMDirectory (FrameworkVersion f@(FrameworkName fwn) version)
platform
verbose =
deleteDirectory dSYMDirectory verbose
where
frameworkNameWithFrameworkExtension = appendFrameworkExtensionTo f
platformBuildDirectory = carthageBuildDirectoryForPlatform platform
dSYMDirectory = platformBuildDirectory </> frameworkNameWithFrameworkExtension <> ".dSYM"



-- | Retrieves a Framework from a local cache
getFrameworkFromLocalCache :: MonadIO m
Expand Down Expand Up @@ -936,6 +987,7 @@ getAndUnzipFrameworkFromLocalCache lCacheDir
let sayFunc = if verbose then sayLnWithTime else sayLn
binary <- getFrameworkFromLocalCache lCacheDir reverseRomeMap fVersion platform
sayFunc $ "Found " <> fwn <> " in local cache at: " <> frameworkLocalCachePath
deleteFrameworkDirectory fVersion platform verbose
unzipBinary binary fwn frameworkZipName verbose <* makeExecutable platform f
where
frameworkLocalCachePath = lCacheDir </> remoteFrameworkUploadPath
Expand All @@ -960,6 +1012,7 @@ getAndUnzipDSYMFromLocalCache lCacheDir
let sayFunc = if verbose then sayLnWithTime else sayLn
binary <- getDSYMFromLocalCache lCacheDir reverseRomeMap fVersion platform
sayFunc $ "Found " <> fwn <> " in local cache at: " <> dSYMLocalCachePath
deleteDSYMDirectory fVersion platform verbose
unzipBinary binary fwn dSYMZipName verbose <* makeExecutable platform f
where
dSYMLocalCachePath = lCacheDir </> remotedSYMUploadPath
Expand All @@ -980,6 +1033,7 @@ getAndUnzipFrameworkFromS3 s3BucketName
platform = do
(_, verbose) <- ask
frameworkBinary <- getFrameworkFromS3 s3BucketName reverseRomeMap fVersion platform
deleteFrameworkDirectory fVersion platform verbose
unzipBinary frameworkBinary fwn frameworkZipName verbose
<* makeExecutable platform f
where
Expand Down Expand Up @@ -1015,6 +1069,7 @@ getAndUnzipDSYMFromS3 s3BucketName
platform = do
(_, verbose) <- ask
dSYMBinary <- getDSYMFromS3 s3BucketName reverseRomeMap fVersion platform
deleteDSYMDirectory fVersion platform verbose
unzipBinary dSYMBinary fwn dSYMZipName verbose
where
dSYMZipName = dSYMArchiveName f version
Expand Down

0 comments on commit f527fd2

Please sign in to comment.