get, copy, move: Display an error message when an identical transfer is already in progress, rather than failing with no indication why.

This commit is contained in:
Joey Hess 2013-03-19 13:56:20 -04:00
parent bb284cd980
commit e9048ecec8
4 changed files with 25 additions and 10 deletions

View file

@ -113,20 +113,25 @@ runTransfer t file shouldretry a = do
info <- liftIO $ startTransferInfo file
(meter, tfile, metervar) <- mkProgressUpdater t info
mode <- annexFileMode
fd <- liftIO $ prep tfile mode info
ok <- retry info metervar $
bracketIO (prep tfile mode info) (cleanup tfile) (a meter)
bracketIO (return fd) (cleanup tfile) (a meter)
unless ok $ recordFailedTransfer t info
return ok
where
prep tfile mode info = catchMaybeIO $ do
fd <- openFd (transferLockFile tfile) ReadWrite (Just mode)
defaultFileFlags { trunc = True }
locked <- catchMaybeIO $
setLock fd (WriteLock, AbsoluteSeek, 0, 0)
when (locked == Nothing) $
error $ "transfer already in progress"
writeTransferInfoFile info tfile
return fd
prep tfile mode info = do
mfd <- catchMaybeIO $
openFd (transferLockFile tfile) ReadWrite (Just mode)
defaultFileFlags { trunc = True }
case mfd of
Nothing -> return mfd
Just fd -> do
locked <- catchMaybeIO $
setLock fd (WriteLock, AbsoluteSeek, 0, 0)
when (locked == Nothing) $
error $ "transfer already in progress"
void $ tryIO $ writeTransferInfoFile info tfile
return mfd
cleanup _ Nothing = noop
cleanup tfile (Just fd) = do
void $ tryIO $ removeFile tfile

2
debian/changelog vendored
View file

@ -26,6 +26,8 @@ git-annex (4.20130315) UNRELEASED; urgency=low
* webapp: Force wrap long filenames in transfer display.
* assistant: The ConfigMonitor left one zombie behind each time
it checked for changes, now fixed.
* get, copy, move: Display an error message when an identical transfer
is already in progress, rather than failing with no indication why.
-- Joey Hess <joeyh@debian.org> Fri, 15 Mar 2013 00:10:07 -0400

View file

@ -9,3 +9,6 @@ I do "git copy --to storage FILE" and it says "Copying FILE... failed". That's
How do I fix things so that I can copy again? Nothing that I tried had any effect on the problem.
Thanks!
> Thanks to Jim's smart correlation of this with another bug, I've fixed
> them both. [[done]] --[[Joey]]

View file

@ -33,3 +33,8 @@ Same `git annex version` on both `pilot` and `bucket`, and I ran `git annex sync
upgrade supported from repository versions: 0 1 2
How should I debug this?
> [[done]], in c6fbed48 I had made some changes to allow transfers
> to work from readonly filesystems, but a too broad error trapping
> hid the "transfer already in progress" error it is supposed to display
> in this case. --[[Joey]]