From 3337f7c2728e6b6f35976217c084edaa5cb01243 Mon Sep 17 00:00:00 2001 From: Joey Hess Date: Tue, 16 Mar 2021 14:17:29 -0400 Subject: [PATCH] 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. --- Remote/WebDAV/DavLocation.hs | 14 ++++++++++++-- ...ent_6_e1051429a09bf5d7e5887d0eb378d72f._comment | 8 ++++++++ 2 files changed, 20 insertions(+), 2 deletions(-) create mode 100644 doc/bugs/WEBDAV_export_has_wrong_subdirectory_content/comment_6_e1051429a09bf5d7e5887d0eb378d72f._comment diff --git a/Remote/WebDAV/DavLocation.hs b/Remote/WebDAV/DavLocation.hs index 99c2c61ea7..c8b8435589 100644 --- a/Remote/WebDAV/DavLocation.hs +++ b/Remote/WebDAV/DavLocation.hs @@ -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 diff --git a/doc/bugs/WEBDAV_export_has_wrong_subdirectory_content/comment_6_e1051429a09bf5d7e5887d0eb378d72f._comment b/doc/bugs/WEBDAV_export_has_wrong_subdirectory_content/comment_6_e1051429a09bf5d7e5887d0eb378d72f._comment new file mode 100644 index 0000000000..93550ca079 --- /dev/null +++ b/doc/bugs/WEBDAV_export_has_wrong_subdirectory_content/comment_6_e1051429a09bf5d7e5887d0eb378d72f._comment @@ -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. +"""]]