-
Notifications
You must be signed in to change notification settings - Fork 11
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Good direction, several comments to take a look at.
#endif | ||
|
||
-- | Updater path, args, windows runner path, archive path | ||
data UpdaterData = UpdaterData |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Maybe you can have UpdaterData
for each platform?
Not sure why you have udWindowsPath
.
src/Cardano/Shell/Update/Lib.hs
Outdated
|
||
updaterData :: UpdaterData | ||
updaterData = case buildOS of | ||
Windows -> UpdaterData "WindowsPath" ["Windows", "Args"] (Just "Window path") Nothing |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Here you can use actual executables for the installers found here - #216 (comment)
src/Cardano/Shell/Update/Lib.hs
Outdated
removeFile updateArchivePath | ||
return . Right $ () | ||
ExitFailure code -> return . Left $ UpdateFailed code | ||
else return . Left $ UpdaterDoesNotExist |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Newline after else
.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Also, is it possible to do return . Left . UpdaterDoesNotExist
?
Just wondering.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Tried, but compiler complained so its not possible.
src/Cardano/Shell/Update/Lib.hs
Outdated
updaterExists <- doesFileExist path | ||
if updaterExists | ||
then do | ||
exitCode <- case mWindowPath of |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't think it should be optional.
An actual path should be there so it shouldn't be Maybe FilePath
but an actual FilePath
for an executable for each platform.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think this is optional since this field is not required when you're on Mac/Linux. You can have it mempty
but that's kind of awkward.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You know whether you are on Max/Linux
or Windows
so you don't need another check for that.
src/Cardano/Shell/Update/Lib.hs
Outdated
ExitFailure code -> return . Left $ UpdateFailed code | ||
else return . Left $ UpdaterDoesNotExist | ||
where | ||
runCmd path args archive = |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please add the types to an anonymous (or where/let) function when you are writing it to make it more clear.
whenJust (Just a) f = f a | ||
whenJust Nothing _ = return () | ||
|
||
writeWindowsUpdaterRunner :: FilePath -> IO () |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please add a comment where you copied this from and why.
@@ -3,8 +3,7 @@ module Cardano.Shell.Update.Types where | |||
import Cardano.Prelude | |||
|
|||
import qualified Data.Map as M | |||
|
|||
import Test.QuickCheck | |||
import Test.QuickCheck (Gen, choose, frequency, listOf1) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks, better.
@@ -36,6 +36,5 @@ extra-deps: | |||
- containers-0.5.11.0 | |||
- libsystemd-journal-1.4.4 | |||
|
|||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
👍
src/Cardano/Shell/Update/Lib.hs
Outdated
updaterData :: UpdaterData | ||
updaterData = case buildOS of | ||
Windows -> UpdaterData | ||
"Installer.exe" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please indent these after the constructor.
UpdaterData
"Installer.exe"
...
This is hard to read.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
A couple of smaller fixes.
app/Launcher/Main.hs
Outdated
@@ -38,6 +39,8 @@ import Data.X509.Extra (failIfReasons, genRSA256KeyPair, | |||
main :: IO () | |||
main = do | |||
|
|||
-- _ <- runUpdater updaterData |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Remove this.
We need a simple FilePath
when somebody wants to call the runUpdater
- then it will try to run the installer on the FilePath
.
src/Cardano/Shell/Update/Lib.hs
Outdated
{ udPath :: !FilePath | ||
, udArgs :: ![Text] | ||
, udWindowsPath :: Maybe FilePath | ||
, udArchivePath :: Maybe FilePath |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You don't need this since you know whether it's a Windows platform or not.
You just need one of these.
src/Cardano/Shell/Update/Lib.hs
Outdated
withCreateProcess (proc path (args <> [archive])) | ||
$ \_in _out _err ph -> waitForProcess ph | ||
|
||
type RunCmdFunc = FilePath -> [String] -> FilePath -> IO ExitCode |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please inline this in the function type.
src/Cardano/Shell/Update/Lib.hs
Outdated
updaterExists <- doesFileExist path | ||
if updaterExists | ||
then do | ||
exitCode <- case mWindowPath of |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You know whether you are on Max/Linux
or Windows
so you don't need another check for that.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM.
#216
WIP