diff options
Diffstat (limited to 'iserv/src')
-rw-r--r-- | iserv/src/Remote/Message.hs | 16 | ||||
-rw-r--r-- | iserv/src/Remote/Slave.hs | 7 |
2 files changed, 7 insertions, 16 deletions
diff --git a/iserv/src/Remote/Message.hs b/iserv/src/Remote/Message.hs index faef45dcab..f1745301ba 100644 --- a/iserv/src/Remote/Message.hs +++ b/iserv/src/Remote/Message.hs @@ -3,29 +3,19 @@ module Remote.Message ( SlaveMessage(..) , SlaveMsg(..) - , sha256sum , putSlaveMessage , getSlaveMessage ) where +import GHC.Fingerprint (Fingerprint) import Data.Binary -import Data.ByteString as BS (ByteString, readFile) - -import Crypto.Hash - -type Sha256Hash = String - -sha256 :: ByteString -> Digest SHA256 -sha256 = hash - -sha256sum :: FilePath -> IO Sha256Hash -sha256sum path = (show . sha256) <$> BS.readFile path +import Data.ByteString (ByteString) -- | A @SlaveMessage a@ is message from the iserv process on the -- target, requesting something from the Proxy of with result type @a@. data SlaveMessage a where -- sends either a new file, or nothing if the file is acceptable. - Have :: FilePath -> Sha256Hash -> SlaveMessage (Maybe ByteString) + Have :: FilePath -> Fingerprint -> SlaveMessage (Maybe ByteString) Missing :: FilePath -> SlaveMessage ByteString Done :: SlaveMessage () diff --git a/iserv/src/Remote/Slave.hs b/iserv/src/Remote/Slave.hs index 2d47a346c6..e7ff3f2874 100644 --- a/iserv/src/Remote/Slave.hs +++ b/iserv/src/Remote/Slave.hs @@ -19,6 +19,7 @@ import GHCi.Message (Pipe(..), Msg(..), Message(..), readPipe, writePipe) import Foreign.C.String import Data.Binary +import GHC.Fingerprint (getFileHash) import qualified Data.ByteString as BS @@ -59,16 +60,16 @@ startSlave' verbose base_path port = do -- -- If we however already have the requested file we need to make -- sure that this file is the same one ghc sees. Hence we --- calculate the sha256sum of the file and send it back to the +-- calculate the Fingerprint of the file and send it back to the -- host for comparison. The proxy will then send back either @Nothing@ --- indicating that the file on the host has the same sha256sum, or +-- indicating that the file on the host has the same Fingerprint, or -- Maybe ByteString containing the payload to replace the existing -- file with. handleLoad :: Pipe -> FilePath -> FilePath -> IO () handleLoad pipe path localPath = do exists <- doesFileExist localPath if exists - then sha256sum localPath >>= \hash -> proxyCall (Have path hash) >>= \case + then getFileHash localPath >>= \hash -> proxyCall (Have path hash) >>= \case Nothing -> return () Just bs -> BS.writeFile localPath bs else do |