add: Fix reversion when adding an annex link that has been moved to another directory

Fixes commit f259be7f39

Sponsored-by: Dartmouth College's Datalad project
This commit is contained in:
Joey Hess 2022-07-05 16:22:41 -04:00
parent 149d12f188
commit 201e41cffd
No known key found for this signature in database
GPG key ID: DB12DB0FF05F8F38
4 changed files with 18 additions and 1 deletions

View file

@ -6,6 +6,8 @@ git-annex (10.20220625) UNRELEASED; urgency=medium
commands that actually need it. commands that actually need it.
* Fix building with the Assistant build flag disabled but the Webapp * Fix building with the Assistant build flag disabled but the Webapp
build flag enabled. build flag enabled.
* add: Fix reversion when adding an annex link that has been moved to
another directory. (Introduced in version 10.20220624)
-- Joey Hess <id@joeyh.name> Tue, 28 Jun 2022 14:49:17 -0400 -- Joey Hess <id@joeyh.name> Tue, 28 Jun 2022 14:49:17 -0400

View file

@ -210,7 +210,7 @@ start si file addunlockedmatcher =
starting "add" (ActionItemTreeFile file) si $ starting "add" (ActionItemTreeFile file) si $
addingExistingLink file key $ addingExistingLink file key $
withOtherTmp $ \tmp -> do withOtherTmp $ \tmp -> do
let tmpf = tmp P.</> file let tmpf = tmp P.</> P.takeFileName file
liftIO $ moveFile file tmpf liftIO $ moveFile file tmpf
ifM (isSymbolicLink <$> liftIO (R.getSymbolicLinkStatus tmpf)) ifM (isSymbolicLink <$> liftIO (R.getSymbolicLinkStatus tmpf))
( do ( do

13
Test.hs
View file

@ -82,6 +82,7 @@ import qualified Utility.Tmp.Dir
import qualified Utility.FileSystemEncoding import qualified Utility.FileSystemEncoding
import qualified Utility.Aeson import qualified Utility.Aeson
import qualified Utility.CopyFile import qualified Utility.CopyFile
import qualified Utility.MoveFile
import qualified Types.Remote import qualified Types.Remote
#ifndef mingw32_HOST_OS #ifndef mingw32_HOST_OS
import qualified Remote.Helper.Encryptable import qualified Remote.Helper.Encryptable
@ -261,6 +262,7 @@ repoTests :: String -> Int -> [TestTree]
repoTests note numparts = map mk $ sep repoTests note numparts = map mk $ sep
[ testCase "add dup" test_add_dup [ testCase "add dup" test_add_dup
, testCase "add extras" test_add_extras , testCase "add extras" test_add_extras
, testCase "add moved link" test_add_moved
, testCase "readonly remote" test_readonly_remote , testCase "readonly remote" test_readonly_remote
, testCase "ignore deleted files" test_ignore_deleted_files , testCase "ignore deleted files" test_ignore_deleted_files
, testCase "metadata" test_metadata , testCase "metadata" test_metadata
@ -390,6 +392,17 @@ test_add_extras = intmpclonerepo $ do
annexed_present wormannexedfile annexed_present wormannexedfile
checkbackend wormannexedfile backendWORM checkbackend wormannexedfile backendWORM
test_add_moved :: Assertion
test_add_moved = intmpclonerepo $ do
git_annex "get" [annexedfile] "get failed"
annexed_present annexedfile
createDirectory subdir
Utility.MoveFile.moveFile (toRawFilePath annexedfile) (toRawFilePath subfile)
git_annex "add" [subdir] "add of moved annexed file"
where
subdir = "subdir"
subfile = subdir </> "file"
test_readonly_remote :: Assertion test_readonly_remote :: Assertion
test_readonly_remote = test_readonly_remote =
#ifndef mingw32_HOST_OS #ifndef mingw32_HOST_OS

View file

@ -44,3 +44,5 @@ As this is such a basic operation, I am still wondering how come it is not caugh
[[!meta author=yoh]] [[!meta author=yoh]]
[[!tag projects/datalad]] [[!tag projects/datalad]]
> [[fixed|done]], with a test case added for this edge case. --[[Joey]]