RawFilePath conversion of System.Directory
By using System.Directory.OsPath, which takes and returns OsString, which is a ShortByteString. So, things like dirContents currently have the overhead of copying that to a ByteString, but that should be less than the overhead of using Strings which often in turn were converted to RawFilePaths. Added Utility.OsString and the OsString build flag. That flag is turned on in the stack.yaml, and will be turned on automatically by cabal when built with new enough libraries. The stack.yaml change is a bit ugly, and that could be reverted for now if it causes any problems. Note that Utility.OsString.toOsString on windows is avoiding only a check of encoding that is documented as being unlikely to fail. I don't think it can fail in git-annex; if it could, git-annex didn't contain such an encoding check before, so at worst that should be a wash.
This commit is contained in:
parent
e5be81f8d4
commit
1ceece3108
34 changed files with 222 additions and 138 deletions
|
@ -41,6 +41,7 @@ import qualified Utility.Url as Url
|
|||
import qualified Annex.Url as Url hiding (download)
|
||||
import Utility.Tuple
|
||||
import qualified Utility.RawFilePath as R
|
||||
import qualified System.FilePath.ByteString as P
|
||||
|
||||
import Data.Either
|
||||
import qualified Data.Map as M
|
||||
|
@ -212,8 +213,8 @@ upgradeToDistribution newdir cleanup distributionfile = do
|
|||
makeorigsymlink olddir
|
||||
return (newdir </> "git-annex", deleteold)
|
||||
installby a dstdir srcdir =
|
||||
mapM_ (\x -> a (toRawFilePath x) (toRawFilePath (dstdir </> takeFileName x)))
|
||||
=<< dirContents srcdir
|
||||
mapM_ (\x -> a x (toRawFilePath dstdir P.</> P.takeFileName x))
|
||||
=<< dirContents (toRawFilePath srcdir)
|
||||
#endif
|
||||
sanitycheck dir =
|
||||
unlessM (doesDirectoryExist dir) $
|
||||
|
@ -280,14 +281,14 @@ deleteFromManifest dir = do
|
|||
fs <- map (dir </>) . lines <$> catchDefaultIO "" (readFile manifest)
|
||||
mapM_ (removeWhenExistsWith R.removeLink . toRawFilePath) fs
|
||||
removeWhenExistsWith R.removeLink (toRawFilePath manifest)
|
||||
removeEmptyRecursive dir
|
||||
removeEmptyRecursive (toRawFilePath dir)
|
||||
where
|
||||
manifest = dir </> "git-annex.MANIFEST"
|
||||
|
||||
removeEmptyRecursive :: FilePath -> IO ()
|
||||
removeEmptyRecursive :: RawFilePath -> IO ()
|
||||
removeEmptyRecursive dir = do
|
||||
mapM_ removeEmptyRecursive =<< dirContents dir
|
||||
void $ tryIO $ removeDirectory dir
|
||||
void $ tryIO $ removeDirectory (fromRawFilePath dir)
|
||||
|
||||
{- This is a file that the UpgradeWatcher can watch for modifications to
|
||||
- detect when git-annex has been upgraded.
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue