fix exporting when the file is in the top of the repo

takeDirectory "foo" is ".", and that will confuse webdav, so only
use that code path when there is a subdirectory.
This commit is contained in:
Joey Hess 2021-03-16 14:17:29 -04:00
parent 4a2d148599
commit 3337f7c272
No known key found for this signature in database
GPG key ID: DB12DB0FF05F8F38
2 changed files with 20 additions and 2 deletions

View file

@ -62,10 +62,20 @@ exportLocation l =
keyTmpLocation :: Key -> DavLocation
keyTmpLocation = tmpLocation . fromRawFilePath . keyFile
{- Where we store temporary data for a file as it's being exported.
-
- This could be just the keyTmpLocation, but when the file is in a
- subdirectory, the temp file is put in there. Partly this is to keep
- it close to the final destination; also certian webdav servers
- seem to be buggy when renaming files from the root into a subdir,
- and so writing to the subdir avoids such problems.
-}
exportTmpLocation :: ExportLocation -> Key -> DavLocation
exportTmpLocation l k = d </> keyTmpLocation k
exportTmpLocation l k
| length (splitDirectories p) > 1 = takeDirectory p </> keyTmpLocation k
| otherwise = keyTmpLocation k
where
d = takeDirectory (fromRawFilePath (fromExportLocation l))
p = fromRawFilePath (fromExportLocation l)
tmpLocation :: FilePath -> DavLocation
tmpLocation f = "git-annex-webdav-tmp-" ++ f

View file

@ -0,0 +1,8 @@
[[!comment format=mdwn
username="joey"
subject="""comment 6"""
date="2021-03-16T18:13:45Z"
content="""
I think I see how my change broke exporting to the top directory of the
repo. I've committed a fix for that.
"""]]