@@ -131,25 +131,29 @@ verifyFetchedTarball verbosity repoCtxt repo pkgid =
131
131
case res of
132
132
Left e -> warn verbosity (" Error verifying fetched tarball " ++ file ++ " , will redownload: " ++ show (e :: SomeException )) >> pure False
133
133
Right b -> pure b
134
- in handleError $ case repo of
135
- -- a secure repo has hashes we can compare against to confirm this is the correct file.
136
- RepoSecure {} ->
137
- repoContextWithSecureRepo repoCtxt repo $ \ repoSecure ->
138
- Sec. withIndex repoSecure $ \ callbacks ->
139
- let warnAndFail s = warn verbosity (" Fetched tarball " ++ file ++ " does not match server, will redownload: " ++ s) >> return False
140
- -- the do block in parens is due to dealing with the checked exceptions mechanism.
141
- in (do fileInfo <- Sec. indexLookupFileInfo callbacks pkgid
142
- sz <- Sec. FileLength . fromInteger <$> getFileSize file
143
- if sz /= Sec. fileInfoLength (Sec. trusted fileInfo)
144
- then warnAndFail " file length mismatch"
145
- else do
146
- res <- Sec. compareTrustedFileInfo (Sec. trusted fileInfo) <$> Sec. computeFileInfo (Sec. Path file :: Sec. Path Sec. Absolute )
147
- if res
148
- then pure True
149
- else warnAndFail " file hash mismatch" )
134
+ in handleError $ do
135
+ exists <- doesFileExist file
136
+ if not exists
137
+ then return False
138
+ else case repo of
139
+ -- a secure repo has hashes we can compare against to confirm this is the correct file.
140
+ RepoSecure {} ->
141
+ repoContextWithSecureRepo repoCtxt repo $ \ repoSecure ->
142
+ Sec. withIndex repoSecure $ \ callbacks ->
143
+ let warnAndFail s = warn verbosity (" Fetched tarball " ++ file ++ " does not match server, will redownload: " ++ s) >> return False
144
+ -- the do block in parens is due to dealing with the checked exceptions mechanism.
145
+ in (do fileInfo <- Sec. indexLookupFileInfo callbacks pkgid
146
+ sz <- Sec. FileLength . fromInteger <$> getFileSize file
147
+ if sz /= Sec. fileInfoLength (Sec. trusted fileInfo)
148
+ then warnAndFail " file length mismatch"
149
+ else do
150
+ res <- Sec. compareTrustedFileInfo (Sec. trusted fileInfo) <$> Sec. computeFileInfo (Sec. Path file :: Sec. Path Sec. Absolute )
151
+ if res
152
+ then pure True
153
+ else warnAndFail " file hash mismatch" )
150
154
`Sec.catchChecked` (\ (e :: Sec. InvalidPackageException ) -> warnAndFail (show e))
151
155
`Sec.catchChecked` (\ (e :: Sec. VerificationError ) -> warnAndFail (show e))
152
- _ -> pure True
156
+ _ -> pure True
153
157
154
158
-- | Fetch a package if we don't have it already.
155
159
--
0 commit comments