diff options
author | Joey Hess <joeyh@joeyh.name> | 2016-02-12 14:11:25 -0400 |
---|---|---|
committer | Joey Hess <joeyh@joeyh.name> | 2016-02-12 14:11:25 -0400 |
commit | 265cbb0f66881102aa11f73d0cff41c773ddb3a9 (patch) | |
tree | 91d31302227d58819c45ed262dad822be5ca1ef4 /Annex/Transfer.hs | |
parent | f7ab2860e6cb99b49a9f737b47571fb15c61df58 (diff) |
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.
Diffstat (limited to 'Annex/Transfer.hs')
-rw-r--r-- | Annex/Transfer.hs | 8 |
1 files changed, 6 insertions, 2 deletions
diff --git a/Annex/Transfer.hs b/Annex/Transfer.hs index 805446b75..af9d89f4d 100644 --- a/Annex/Transfer.hs +++ b/Annex/Transfer.hs @@ -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 |