diff --git a/src/Pantry/Archive.hs b/src/Pantry/Archive.hs index bb8fbd51..43918700 100644 --- a/src/Pantry/Archive.hs +++ b/src/Pantry/Archive.hs @@ -345,7 +345,7 @@ foldTar loc accum0 f = do _ -> throwIO exc pure $ (\met -> MetaEntry - { mePath = Tar.getFileInfoPath fi + { mePath = removeInitialDotSlash . Tar.getFileInfoPath $ fi , meType = met }) <$> mmet @@ -356,6 +356,10 @@ data SimpleEntry = SimpleEntry } deriving Show +removeInitialDotSlash :: FilePath -> FilePath +removeInitialDotSlash filename = + maybe filename T.unpack (T.stripPrefix "./" $ T.pack filename) + -- | Attempt to parse the contents of the given archive in the given subdir into -- a 'Tree'. This will not consult any caches. It will ensure that: -- @@ -380,7 +384,7 @@ parseArchive rpli archive fp = do logDebug $ "parseArchive of " <> display at <> ": " <> displayShow e getFiles ats Right files -> pure (at, Map.fromList $ map (mePath &&& id) $ files []) - (at :: ArchiveType, files :: Map FilePath MetaEntry) <- getFiles [minBound..maxBound] + (at :: ArchiveType, files :: Map FilePath MetaEntry) <- second (Map.mapKeys removeInitialDotSlash) <$> getFiles [minBound..maxBound] let toSimple :: FilePath -> MetaEntry -> Either String (Map FilePath SimpleEntry) toSimple key me = case meType me of @@ -475,10 +479,10 @@ parseArchive rpli archive fp = do pure $ Map.insert (mePath me) (blobKey, blobId) m else pure m tree :: CachedTree <- fmap (CachedTreeMap . Map.fromList) $ for safeFiles $ \(sfp, se) -> - case Map.lookup (seSource se) blobs of - Nothing -> + case Map.lookup (removeInitialDotSlash . seSource $ se) blobs of + Nothing -> error $ "Impossible: blob not found for: " ++ seSource se - Just (blobKey, blobId) -> + Just (blobKey, blobId) -> pure (sfp, (TreeEntry blobKey (seType se), blobId)) -- parse the cabal file and ensure it has the right name buildFile <- findCabalOrHpackFile rpli $ unCachedTree tree