fix: Error on release path activation (#216)

* fix: Change place where validation happens

* chore: Change error message
This commit is contained in:
Cristhian Motoche 2023-02-15 16:13:53 -05:00 committed by GitHub
parent dcd59383d7
commit 05c194375e
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -120,14 +120,10 @@ activateRelease
-> Hapistrano ()
activateRelease ts deployPath release = do
rpath <- releasePath deployPath release Nothing
isRpathExist <- doesDirExist rpath
if isRpathExist then do
let tpath = tempSymlinkPath deployPath
cpath = currentSymlinkPath deployPath
exec (Ln ts rpath tpath) (Just release) -- create a symlink for the new candidate
exec (Mv ts tpath cpath) (Just release) -- atomically replace the symlink
else
failWith 1 (Just $ "The release path '" <> show rpath <> "' cannot be activated.") (Just release)
let tpath = tempSymlinkPath deployPath
cpath = currentSymlinkPath deployPath
exec (Ln ts rpath tpath) (Just release) -- create a symlink for the new candidate
exec (Mv ts tpath cpath) (Just release) -- atomically replace the symlink
-- | Creates the file @.hapistrano__state@ containing
-- @fail@ or @success@ depending on how the deployment ended.
@ -209,7 +205,12 @@ rollback ts deployPath n mbRestartCommand = do
releases <- releasesWithState Success deployPath
case genericDrop n releases of
[] -> failWith 1 (Just "Could not find the requested release to rollback to.") Nothing
(x:_) -> activateRelease ts deployPath x
(x:_) -> do
rpath <- releasePath deployPath x Nothing
isRpathExist <- doesDirExist rpath
if isRpathExist
then activateRelease ts deployPath x
else failWith 1 (Just $ "Cannot rollback to the release path '" <> show rpath <> "'.") (Just x)
forM_ mbRestartCommand (`exec` Nothing)
-- | Remove older releases to avoid filling up the target host filesystem.