Avoid filename encoding errors when writing direct mode mappings.
This commit is contained in:
parent
bbf0e74f72
commit
5c58e9c101
2 changed files with 12 additions and 2 deletions
|
@ -41,7 +41,10 @@ associatedFiles key = do
|
||||||
associatedFilesRelative :: Key -> Annex [FilePath]
|
associatedFilesRelative :: Key -> Annex [FilePath]
|
||||||
associatedFilesRelative key = do
|
associatedFilesRelative key = do
|
||||||
mapping <- inRepo $ gitAnnexMapping key
|
mapping <- inRepo $ gitAnnexMapping key
|
||||||
liftIO $ catchDefaultIO [] $ lines <$> readFile mapping
|
liftIO $ catchDefaultIO [] $ do
|
||||||
|
h <- openFile mapping ReadMode
|
||||||
|
fileEncoding h
|
||||||
|
hClose h `after` (lines <$> hGetContents h)
|
||||||
|
|
||||||
{- Changes the associated files information for a key, applying a
|
{- Changes the associated files information for a key, applying a
|
||||||
- transformation to the list. Returns new associatedFiles value. -}
|
- transformation to the list. Returns new associatedFiles value. -}
|
||||||
|
@ -51,9 +54,15 @@ changeAssociatedFiles key transform = do
|
||||||
files <- associatedFilesRelative key
|
files <- associatedFilesRelative key
|
||||||
let files' = transform files
|
let files' = transform files
|
||||||
when (files /= files') $
|
when (files /= files') $
|
||||||
liftIO $ viaTmp writeFile mapping $ unlines files'
|
liftIO $ viaTmp write mapping $ unlines files'
|
||||||
top <- fromRepo Git.repoPath
|
top <- fromRepo Git.repoPath
|
||||||
return $ map (top </>) files'
|
return $ map (top </>) files'
|
||||||
|
where
|
||||||
|
write file content = do
|
||||||
|
h <- openFile file WriteMode
|
||||||
|
fileEncoding h
|
||||||
|
hPutStr h content
|
||||||
|
hClose h
|
||||||
|
|
||||||
{- Removes an associated file. Returns new associatedFiles value. -}
|
{- Removes an associated file. Returns new associatedFiles value. -}
|
||||||
removeAssociatedFile :: Key -> FilePath -> Annex [FilePath]
|
removeAssociatedFile :: Key -> FilePath -> Annex [FilePath]
|
||||||
|
|
1
debian/changelog
vendored
1
debian/changelog
vendored
|
@ -18,6 +18,7 @@ git-annex (3.20130115) UNRELEASED; urgency=low
|
||||||
* Fix direct mode mapping code to always store direct mode filenames
|
* Fix direct mode mapping code to always store direct mode filenames
|
||||||
relative to the top of the repository, even when operating inside a
|
relative to the top of the repository, even when operating inside a
|
||||||
subdirectory.
|
subdirectory.
|
||||||
|
* Avoid filename encoding errors when writing direct mode mappings.
|
||||||
|
|
||||||
-- Joey Hess <joeyh@debian.org> Mon, 14 Jan 2013 18:35:01 -0400
|
-- Joey Hess <joeyh@debian.org> Mon, 14 Jan 2013 18:35:01 -0400
|
||||||
|
|
||||||
|
|
Loading…
Add table
Reference in a new issue