packages feed

cachix 0.7.0 → 0.7.1

raw patch · 6 files changed

+30/−28 lines, 6 files

Files

CHANGELOG.md view
@@ -7,6 +7,12 @@  ## Unreleased +## [0.7.1] - 2022-06-27++### Fixed++- Previous release didn't filter out all invalid paths as intended+ ## [0.7.0] - 2022-01-12  ### Added 
cachix.cabal view
@@ -1,6 +1,6 @@ cabal-version:      2.2 name:               cachix-version:            0.7.0+version: 0.7.1 license:            Apache-2.0 license-file:       LICENSE copyright:          2018 Domen Kožar@@ -157,7 +157,6 @@     NetRcSpec     NixConfSpec     NixVersionSpec-    Paths_cachix     Spec    build-depends:
src/Cachix/Client/CNix.hs view
@@ -1,22 +1,19 @@ module Cachix.Client.CNix where -import qualified Data.Text as T-import qualified Language.C.Inline.Cpp.Exceptions as C+import Hercules.CNix.Store (Store, StorePath, isValidPath, storePathToPath) import Protolude import System.Console.Pretty (Color (..), color) -predicateInvalidPath :: SomeException -> Maybe Text-predicateInvalidPath e-  | Just (C.CppStdException msg) <- fromException e =-    if "nix::InvalidPath" `T.isSuffixOf` toS msg-      then Just $ toS msg-      else Nothing-predicateInvalidPath _ = Nothing+filterInvalidStorePaths :: Store -> [StorePath] -> IO [Maybe StorePath]+filterInvalidStorePaths store =+  traverse (filterInvalidStorePath store) -handleInvalidPath :: IO (Maybe a) -> IO (Maybe a)-handleInvalidPath = handleJust predicateInvalidPath handle_-  where-    handle_ :: Text -> IO (Maybe a)-    handle_ msg = do-      hPutStrLn stderr $ color Yellow $ "Warning: " <> msg+filterInvalidStorePath :: Store -> StorePath -> IO (Maybe StorePath)+filterInvalidStorePath store storePath = do+  isValid <- isValidPath store storePath+  if isValid+    then return $ Just storePath+    else do+      path <- storePathToPath store storePath+      hPutStrLn stderr $ color Yellow $ "Warning: " <> decodeUtf8With lenientDecode path <> " is not valid, skipping"       return Nothing
src/Cachix/Client/Commands.hs view
@@ -15,7 +15,7 @@  import qualified Cachix.API as API import Cachix.API.Error-import Cachix.Client.CNix (handleInvalidPath)+import Cachix.Client.CNix (filterInvalidStorePath) import Cachix.Client.Config   ( BinaryCacheConfig (BinaryCacheConfig),     Config (..),@@ -51,7 +51,7 @@ import qualified Data.Text as T import qualified Data.Text.IO as T.IO import GHC.IO.Handle (hDuplicate, hDuplicateTo)-import Hercules.CNix.Store (Store, StorePath, followLinksToStorePath, storePathToPath)+import Hercules.CNix.Store (Store, StorePath, followLinksToStorePath, isValidPath, storePathToPath) import Network.HTTP.Types (status401, status404) import Protolude hiding (toS) import Protolude.Conv@@ -163,9 +163,10 @@   pushParams <- getPushParams env opts name   normalized <-     liftIO $-      for inputStorePaths $ \path ->-        handleInvalidPath $-          Just <$> followLinksToStorePath (pushParamsStore pushParams) (encodeUtf8 path)+      for inputStorePaths $ \path -> do+        storePath <- followLinksToStorePath (pushParamsStore pushParams) (encodeUtf8 path)+        filterInvalidStorePath (pushParamsStore pushParams) storePath+   pushedPaths <-     pushClosure       (mapConcurrentlyBounded (numJobs opts))
src/Cachix/Client/PushQueue.hs view
@@ -12,7 +12,7 @@   ) where -import Cachix.Client.CNix (handleInvalidPath)+import Cachix.Client.CNix (filterInvalidStorePath) import qualified Cachix.Client.Push as Push import Cachix.Client.Retry (retryAll) import Control.Concurrent.Async@@ -43,10 +43,9 @@   storePath <- atomically $ TBQueue.readTBQueue $ pushQueue workerState   bracket_ (inProgresModify (+ 1)) (inProgresModify (\x -> x - 1)) $     retryAll $ \retrystatus ->-      void $-        handleInvalidPath $-          Just-            <$> Push.uploadStorePath pushParams storePath retrystatus+      void $ do+        maybeStorePath <- filterInvalidStorePath (Push.pushParamsStore pushParams) storePath+        for maybeStorePath $ \validatedStorePath -> Push.uploadStorePath pushParams validatedStorePath retrystatus   where     inProgresModify f =       atomically $ modifyTVar' (inProgress workerState) f
test/NetRcSpec.hs view
@@ -46,7 +46,7 @@ spec =   describe "add" $ do     -- TODO: not easy to test this with temp files as they are *created*-    --it "populates non-existent netrc file" $ test [bc1, bc2] "fresh"+    -- it "populates non-existent netrc file" $ test [bc1, bc2] "fresh"     it "populates empty netrc file" $ test [bc1, bc2] "empty"     it "populates netrc file with one additional entry" $ test [bc2] "add"     it "populates netrc file with one overriden entry" $ test [bc2] "override"