From 022b0ca4c442581a5c389d28083be25f44387d33 Mon Sep 17 00:00:00 2001 From: Gregor Kleen Date: Fri, 8 Jul 2016 14:05:41 +0200 Subject: Prevent shadowing --- ymir/mlmmj-expose.nix | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/ymir/mlmmj-expose.nix b/ymir/mlmmj-expose.nix index f7d23565..b07396aa 100644 --- a/ymir/mlmmj-expose.nix +++ b/ymir/mlmmj-expose.nix @@ -1,7 +1,7 @@ { config, pkgs, ... }: let - haskellEnv = pkgs.haskellPackages.ghcWithPackages (pkgs: with pkgs; [ filepath directory cryptonite bytestring ]); + haskellEnv = pkgs.haskellPackages.ghcWithPackages (pkgs: with pkgs; [ filepath directory cryptonite bytestring uuid ]); mlmmj-exposed = pkgs.stdenv.mkDerivation { name = "mlmmj-exposed"; src = pkgs.writeText "mlmmj-exposed.hs" '' @@ -30,6 +30,9 @@ let -- import Data.Hex + import qualified Data.UUID as UUID (toString) + import qualified Data.UUID.V4 as UUID (nextRandom) + main :: IO () main = do progName <- takeFileName <$> getProgName @@ -44,8 +47,11 @@ let let hashes = filter ((==) extension . snd) [((ident, sub), hash' (ident, sub)) | ident <- identities, sub <- subscribers] case hashes of [((_, recipient), _)] -> do - getContents >>= writeFile "queue/exposed" - callProcess "${pkgs.mlmmj}/bin/mlmmj-send" ["-L", listDir, "-l", "6", "-m", "queue/exposed", "-T", recipient] + uuid <- UUID.nextRandom + let fName = "queue" "exposed" <.> UUID.toString uuid + getContents >>= writeFile fName + callProcess "${pkgs.mlmmj}/bin/mlmmj-send" ["-L", listDir, "-l", "6", "-m", fName, "-T", recipient] + removeFile fName [] -> die "Unknown extension" _ -> die "Ambiguous extension" _ -> hPutStrLn stderr ("Called without expected arguments ( )") >> exitWith (ExitFailure 2) -- cgit v1.2.3