From 070ed4a766afcc68a246298326b639f319f3fd54 Mon Sep 17 00:00:00 2001 From: Joey Hess Date: Wed, 29 Jan 2014 15:21:02 -0400 Subject: [PATCH] change a few renameFile's to rename AFAIK, none of these ever operate on directories, but nor do I want to explicitly check if they're files and fail if not. --- Remote/Rsync.hs | 2 +- Utility/Daemon.hs | 2 +- Utility/LogFile.hs | 2 +- Utility/Tmp.hs | 5 +++-- 4 files changed, 6 insertions(+), 5 deletions(-) diff --git a/Remote/Rsync.hs b/Remote/Rsync.hs index 409b5b7601..430554ab88 100644 --- a/Remote/Rsync.hs +++ b/Remote/Rsync.hs @@ -296,7 +296,7 @@ rsyncSend o callback k canrename src = withRsyncScratchDir $ \tmp -> do liftIO $ createDirectoryIfMissing True $ parentDir dest ok <- liftIO $ if canrename then do - renameFile src dest + rename src dest return True else createLinkOrCopy src dest ps <- sendParams diff --git a/Utility/Daemon.hs b/Utility/Daemon.hs index 12beb235a4..8d402eb545 100644 --- a/Utility/Daemon.hs +++ b/Utility/Daemon.hs @@ -77,7 +77,7 @@ lockPidFile file = do #else writeFile newfile "-1" #endif - renameFile newfile file + rename newfile file where newfile = file ++ ".new" diff --git a/Utility/LogFile.hs b/Utility/LogFile.hs index 090ac60d0e..1c29b9ff4f 100644 --- a/Utility/LogFile.hs +++ b/Utility/LogFile.hs @@ -30,7 +30,7 @@ rotateLog logfile = go 0 | num > maxLogs = return () | otherwise = whenM (doesFileExist currfile) $ do go (num + 1) - renameFile currfile nextfile + rename currfile nextfile where currfile = filename num nextfile = filename (num + 1) diff --git a/Utility/Tmp.hs b/Utility/Tmp.hs index 891ce50835..f46e1a5ee5 100644 --- a/Utility/Tmp.hs +++ b/Utility/Tmp.hs @@ -13,10 +13,11 @@ import Control.Exception (bracket) import System.IO import System.Directory import Control.Monad.IfElse +import System.FilePath import Utility.Exception -import System.FilePath import Utility.FileSystemEncoding +import Utility.PosixFiles type Template = String @@ -30,7 +31,7 @@ viaTmp a file content = do (tmpfile, handle) <- openTempFile dir (base ++ ".tmp") hClose handle a tmpfile content - renameFile tmpfile file + rename tmpfile file {- Runs an action with a tmp file located in the system's tmp directory - (or in "." if there is none) then removes the file. -}