create directory for transfer lock file, and catch perm error
Before, the call to mkProgressUpdater created the directory as a side-effect, but since that ignored failure to create it, this led to a "does not exist" exception when the transfer lock file was created, rather than a permissions error. So, make sure the directory exists before trying to lock the file in it. When a PermissionDenied exception is caught, skip making the transfer lock. This lets downloads from readonly remotes happen. If an upload is being tried, and the lock file can't be written due to permissions, then probably the actual transfer will fail for the same reason, so I think it's ok that it continues w/o taking the lock in that case.
This commit is contained in:
parent
1ec91f0c44
commit
0983f136b8
1 changed files with 6 additions and 2 deletions
|
@ -91,8 +91,9 @@ runTransfer' ignorelock t file shouldretry transferobserver transferaction = do
|
|||
return v
|
||||
where
|
||||
#ifndef mingw32_HOST_OS
|
||||
prep tfile mode info = do
|
||||
prep tfile mode info = catchPermissionDenied (const prepfailed) $ do
|
||||
let lck = transferLockFile tfile
|
||||
createAnnexDirectory $ takeDirectory lck
|
||||
r <- tryLockExclusive (Just mode) lck
|
||||
case r of
|
||||
Nothing -> return (Nothing, True)
|
||||
|
@ -104,8 +105,9 @@ runTransfer' ignorelock t file shouldretry transferobserver transferaction = do
|
|||
, return (Nothing, True)
|
||||
)
|
||||
#else
|
||||
prep tfile _mode info = liftIO $ do
|
||||
prep tfile _mode info = catchPermissionDenied (const prepfailed) liftIO $ do
|
||||
let lck = transferLockFile tfile
|
||||
createAnnexDirectory $ takeDirectory lck
|
||||
v <- catchMaybeIO $ lockExclusive lck
|
||||
case v of
|
||||
Nothing -> return (Nothing, False)
|
||||
|
@ -115,6 +117,8 @@ runTransfer' ignorelock t file shouldretry transferobserver transferaction = do
|
|||
writeTransferInfoFile info tfile
|
||||
return (Just lockhandle, False)
|
||||
#endif
|
||||
prepfailed = return (Nothing, False)
|
||||
|
||||
cleanup _ Nothing = noop
|
||||
cleanup tfile (Just lockhandle) = do
|
||||
let lck = transferLockFile tfile
|
||||
|
|
Loading…
Add table
Reference in a new issue