v6: Close pointer file handles more quickly, to avoid problems on Windows.
Was using L.readFile, so the Handle would remain open until the garbage collector got around to it. Changed to explicit open and close, so we know it's always closed when the function returns.
This commit is contained in:
parent
cfe274e6f7
commit
2046502407
4 changed files with 30 additions and 3 deletions
|
@ -157,10 +157,14 @@ formatPointer k =
|
|||
-
|
||||
- Unlocked files whose content is present are not detected by this. -}
|
||||
isPointerFile :: FilePath -> IO (Maybe Key)
|
||||
isPointerFile f = catchDefaultIO Nothing $ do
|
||||
b <- L.take maxPointerSz <$> L.readFile f
|
||||
let !mk = parseLinkOrPointer' (decodeBS b)
|
||||
isPointerFile f = catchDefaultIO Nothing $ bracket open close $ \h -> do
|
||||
b <- take (fromIntegral maxPointerSz) <$> hGetContents h
|
||||
-- strict so it reads before the file handle is closed
|
||||
let !mk = parseLinkOrPointer' b
|
||||
return mk
|
||||
where
|
||||
open = openBinaryFile f ReadMode
|
||||
close = hClose
|
||||
|
||||
{- Checks a symlink target or pointer file first line to see if it
|
||||
- appears to point to annexed content.
|
||||
|
|
1
debian/changelog
vendored
1
debian/changelog
vendored
|
@ -12,6 +12,7 @@ git-annex (6.20160319) UNRELEASED; urgency=medium
|
|||
Thanks, Robie Basak
|
||||
* log: Display time with time zone.
|
||||
* log --raw-date: Use to display seconds from unix epoch.
|
||||
* v6: Close pointer file handles more quickly, to avoid problems on Windows.
|
||||
|
||||
-- Joey Hess <id@joeyh.name> Wed, 23 Mar 2016 11:42:36 -0400
|
||||
|
||||
|
|
|
@ -3,6 +3,8 @@ I'm using git-annex v6 in windows and seems `git annex get` fails.
|
|||
Deleting the pointer files and doing a hard reset seems to fix the problem.
|
||||
Another bug report named "v6 repo can not restore files with executable permission" seems to point to the same problem but a little different.
|
||||
|
||||
[[!retitle "git annex get fails sometimes in v6 repository on Windows"]]
|
||||
|
||||
### What steps will reproduce the problem?
|
||||
I have a repo in D:\annex with a file `test`
|
||||
Now I create another repo:
|
||||
|
|
|
@ -0,0 +1,20 @@
|
|||
[[!comment format=mdwn
|
||||
username="joey"
|
||||
subject="""comment 2"""
|
||||
date="2016-04-04T19:24:08Z"
|
||||
content="""
|
||||
Note that v6 mode is still considered experimental.
|
||||
|
||||
I know that I saw a problem like this, where git-annex was reading the
|
||||
pointer file and didn't always get around to closing it before it tried to
|
||||
replace it. I thought I fixed it back in February though -- but that fix
|
||||
may have bit rotted; looking at the current code, I think it could leave
|
||||
the file open until a GC pass, so if the GC doesn't always
|
||||
run in time, that could explain the reported indeterminacy.
|
||||
|
||||
Please paste the actual version of git-annex you're using,
|
||||
"latest build from source" is a little bit vague.
|
||||
|
||||
Since you are building from source, you might try pulling;
|
||||
I've made a change that may fix it again.
|
||||
"""]]
|
Loading…
Add table
Reference in a new issue