Commits

Colin Woodbury  committed a13ada4

`-C` bonus package bug fixed - fixes #147

  • Participants
  • Parent commits d093478

Comments (0)

Files changed (2)

File Aura/Cache.hs

     , cacheContents
     , cacheFilter
     , cacheMatches
+    , pkgsInCache
     , alterable
     , getFilename
     , allFilenames
 cacheContents :: FilePath -> Aura Cache
 cacheContents c = cache <$> rawCacheContents c
 
+pkgsInCache :: [String] -> Aura [String]
+pkgsInCache ps =
+    filter (`elem` ps) . allNames <$> (asks cachePathOf >>= cacheContents)
+
 cacheMatches :: [String] -> Aura [String]
-cacheMatches input = ask >>= cacheContents . cachePathOf >>=
-  return . searchLines (unwords input) . allFilenames
+cacheMatches input = asks cachePathOf >>= cacheContents >>=
+                     return . searchLines (unwords input) . allFilenames
 
 alterable :: Cache -> SimplePkg -> Bool
 alterable c p = M.member p c
 getFilename :: Cache -> SimplePkg -> Maybe FilePath
 getFilename c p = M.lookup p c
 
+allNames :: Cache -> [String]
+allNames = map fst . M.keys
+
 allFilenames :: Cache -> [FilePath]
 allFilenames = M.elems
 

File Aura/Commands/C.hs

 import System.Posix.Files (fileExist)
 import System.FilePath    ((</>))
 import Text.Regex.PCRE    ((=~))
-import Control.Monad      (filterM, unless)
+import Control.Monad      (unless)
 import Data.List          ((\\), sort, groupBy)
 import Data.Char          (isDigit)
 
 downgradePackages :: [String] -> Aura ()
 downgradePackages []   = return ()
 downgradePackages pkgs = asks cachePathOf >>= \cachePath -> do
-  reals <- filterM inCache pkgs -- This.
+  reals <- pkgsInCache pkgs
   reportBadDowngradePkgs (pkgs \\ reals)
   unless (null reals) $ do
     cache   <- cacheContents cachePath
     choices <- mapM (getDowngradeChoice cache) reals
     pacman $ "-U" : map (cachePath </>) choices
-        where inCache p = notNull <$> cacheMatches [p]
                
 getDowngradeChoice :: Cache -> String -> Aura String
 getDowngradeChoice cache pkg = do