Windows: Avoid using unix-compat's rename, which refuses to rename directories.

Opened a bug about this: https://github.com/jystic/unix-compat/issues/10
This commit is contained in:
Joey Hess 2014-01-29 15:19:03 -04:00
parent 4b37bc6493
commit 1669e80e85
17 changed files with 35 additions and 22 deletions

View file

@ -35,7 +35,6 @@ module Annex.Content (
) where ) where
import System.IO.Unsafe (unsafeInterleaveIO) import System.IO.Unsafe (unsafeInterleaveIO)
import System.PosixCompat.Files
import Common.Annex import Common.Annex
import Logs.Location import Logs.Location

View file

@ -11,8 +11,6 @@
module CmdLine.Seek where module CmdLine.Seek where
import System.PosixCompat.Files
import Common.Annex import Common.Annex
import Types.Command import Types.Command
import Types.Key import Types.Key

View file

@ -9,8 +9,6 @@
module Command.Add where module Command.Add where
import System.PosixCompat.Files
import Common.Annex import Common.Annex
import Annex.Exception import Annex.Exception
import Command import Command

View file

@ -9,8 +9,6 @@
module Command.Fix where module Command.Fix where
import System.PosixCompat.Files
import Common.Annex import Common.Annex
import Command import Command
import qualified Annex.Queue import qualified Annex.Queue

View file

@ -7,8 +7,6 @@
module Command.FromKey where module Command.FromKey where
import System.PosixCompat.Files
import Common.Annex import Common.Annex
import Command import Command
import qualified Annex.Queue import qualified Annex.Queue

View file

@ -9,8 +9,6 @@
module Command.Fsck where module Command.Fsck where
import System.PosixCompat.Files
import Common.Annex import Common.Annex
import Command import Command
import qualified Annex import qualified Annex

View file

@ -7,8 +7,6 @@
module Command.Import where module Command.Import where
import System.PosixCompat.Files
import Common.Annex import Common.Annex
import Command import Command
import qualified Annex import qualified Annex

View file

@ -7,7 +7,6 @@
module Command.Indirect where module Command.Indirect where
import System.PosixCompat.Files
import Control.Exception.Extensible import Control.Exception.Extensible
import Common.Annex import Common.Annex

View file

@ -14,7 +14,6 @@ import qualified Data.Map as M
import Text.JSON import Text.JSON
import Data.Tuple import Data.Tuple
import Data.Ord import Data.Ord
import System.PosixCompat.Files
import Common.Annex import Common.Annex
import qualified Remote import qualified Remote

View file

@ -7,8 +7,6 @@
module Command.RecvKey where module Command.RecvKey where
import System.PosixCompat.Files
import Common.Annex import Common.Annex
import Command import Command
import CmdLine import CmdLine

View file

@ -15,7 +15,6 @@ import Data.String.Utils as X hiding (join)
import System.FilePath as X import System.FilePath as X
import System.Directory as X import System.Directory as X
import System.IO as X hiding (FilePath) import System.IO as X hiding (FilePath)
import System.PosixCompat.Files as X
#ifndef mingw32_HOST_OS #ifndef mingw32_HOST_OS
import System.Posix.IO as X import System.Posix.IO as X
#endif #endif
@ -31,5 +30,6 @@ import Utility.Monad as X
import Utility.Data as X import Utility.Data as X
import Utility.Applicative as X import Utility.Applicative as X
import Utility.FileSystemEncoding as X import Utility.FileSystemEncoding as X
import Utility.PosixFiles as X
import Utility.PartialPrelude as X import Utility.PartialPrelude as X

View file

@ -13,7 +13,6 @@ import Data.Time.Clock.POSIX
import qualified Data.Set as S import qualified Data.Set as S
import qualified Data.Map as M import qualified Data.Map as M
import System.Path.WildMatch import System.Path.WildMatch
import System.PosixCompat.Files
import Common.Annex import Common.Annex
import qualified Annex import qualified Annex

View file

@ -17,7 +17,6 @@ import Test.Tasty.Ingredients.Rerun
import Data.Monoid import Data.Monoid
import Options.Applicative hiding (command) import Options.Applicative hiding (command)
import System.PosixCompat.Files
import Control.Exception.Extensible import Control.Exception.Extensible
import qualified Data.Map as M import qualified Data.Map as M
import System.IO.HVFS (SystemFS(..)) import System.IO.HVFS (SystemFS(..))

View file

@ -11,7 +11,7 @@ import Common hiding (isDirectory)
import Utility.DirWatcher.Types import Utility.DirWatcher.Types
import System.Win32.Notify import System.Win32.Notify
import qualified System.PosixCompat.Files as Files import qualified Utility.PosixFiles as Files
watchDir :: FilePath -> (FilePath -> Bool) -> WatchHooks -> IO WatchManager watchDir :: FilePath -> (FilePath -> Bool) -> WatchHooks -> IO WatchManager
watchDir dir ignored hooks = do watchDir dir ignored hooks = do

View file

@ -10,7 +10,6 @@
module Utility.Directory where module Utility.Directory where
import System.IO.Error import System.IO.Error
import System.PosixCompat.Files
import System.Directory import System.Directory
import Control.Exception (throw) import Control.Exception (throw)
import Control.Monad import Control.Monad
@ -19,6 +18,7 @@ import System.FilePath
import Control.Applicative import Control.Applicative
import System.IO.Unsafe (unsafeInterleaveIO) import System.IO.Unsafe (unsafeInterleaveIO)
import Utility.PosixFiles
import Utility.SafeCommand import Utility.SafeCommand
import Utility.Tmp import Utility.Tmp
import Utility.Exception import Utility.Exception

30
Utility/PosixFiles.hs Normal file
View file

@ -0,0 +1,30 @@
{- POSIX files (and compatablity wrappers).
-
- This is like System.PosixCompat.Files, except with a fixed rename.
-
- Copyright 2014 Joey Hess <joey@kitenet.net>
-
- Licensed under the GNU GPL version 3 or higher.
-}
{-# LANGUAGE CPP #-}
module Utility.PosixFiles (
module X,
rename
) where
import System.PosixCompat.Files as X hiding (rename)
#ifndef mingw32_HOST_OS
import System.Posix.Files (rename)
#else
import System.Win32.File (moveFile)
#endif
{- System.PosixCompat.Files.rename on Windows calls renameFile,
- so cannot rename directories. Instead, use Win32 moveFile, which can. -}
#ifdef mingw32_HOST_OS
rename :: FilePath -> FilePath -> IO ()
rename = moveFile
#endif

2
debian/changelog vendored
View file

@ -4,6 +4,8 @@ git-annex (5.20140128) UNRELEASED; urgency=medium
on Windows; the lock files have been sorted out. on Windows; the lock files have been sorted out.
* Fixed direct mode annexed content locking code, which is used to * Fixed direct mode annexed content locking code, which is used to
guard against recursive file drops. guard against recursive file drops.
* Windows: Avoid using unix-compat's rename, which refuses to rename
directories.
-- Joey Hess <joeyh@debian.org> Tue, 28 Jan 2014 13:57:19 -0400 -- Joey Hess <joeyh@debian.org> Tue, 28 Jan 2014 13:57:19 -0400