diff options
author | Joey Hess <joeyh@joeyh.name> | 2015-04-18 13:36:12 -0400 |
---|---|---|
committer | Joey Hess <joeyh@joeyh.name> | 2015-04-18 13:36:12 -0400 |
commit | 293903ba38209a1e574ab6a929872ac5c31dfaf4 (patch) | |
tree | 9c0d49fbb06ee2b656834ddd01c6edd8f3f5f7ec | |
parent | e770543c1010526d98730112d58ed304ab4ea341 (diff) |
Fix fsck --from a git remote in a local directory, and from a directory special remote. This was a reversion caused by the relative path changes in 5.20150113.
The directory special remote was not affected in its normal configuration,
since annex-directory is an absolute path normally. But it could fail
when a relative path was used.
The git remote was affected even when an absolute path to it was used in
.git/config, since git-annex now converts all such paths to relative.
-rw-r--r-- | Remote/Directory.hs | 10 | ||||
-rw-r--r-- | Remote/Git.hs | 13 | ||||
-rw-r--r-- | Test.hs | 5 | ||||
-rw-r--r-- | debian/changelog | 3 | ||||
-rw-r--r-- | doc/bugs/fsck_--from___36__remote__44___copies_symlinks_instead_of_content.mdwn | 2 |
5 files changed, 27 insertions, 6 deletions
diff --git a/Remote/Directory.hs b/Remote/Directory.hs index 2eeb79317..916013172 100644 --- a/Remote/Directory.hs +++ b/Remote/Directory.hs @@ -162,9 +162,13 @@ retrieveCheap _ (UnpaddedChunks _) _ _ = return False retrieveCheap _ (LegacyChunks _) _ _ = return False #ifndef mingw32_HOST_OS retrieveCheap d NoChunks k f = liftIO $ catchBoolIO $ do - file <- getLocation d k - createSymbolicLink file f - return True + file <- absPath =<< getLocation d k + ifM (doesFileExist file) + ( do + createSymbolicLink file f + return True + , return False + ) #else retrieveCheap _ _ _ _ = return False #endif diff --git a/Remote/Git.hs b/Remote/Git.hs index abefc113e..fdd0049ca 100644 --- a/Remote/Git.hs +++ b/Remote/Git.hs @@ -445,10 +445,17 @@ copyFromRemote' r key file dest copyFromRemoteCheap :: Remote -> Key -> FilePath -> Annex Bool #ifndef mingw32_HOST_OS copyFromRemoteCheap r key file - | not $ Git.repoIsUrl (repo r) = guardUsable (repo r) (return False) $ do - loc <- liftIO $ gitAnnexLocation key (repo r) $ + | not $ Git.repoIsUrl (repo r) = guardUsable (repo r) (return False) $ liftIO $ do + loc <- gitAnnexLocation key (repo r) $ fromJust $ remoteGitConfig $ gitconfig r - liftIO $ catchBoolIO $ createSymbolicLink loc file >> return True + ifM (doesFileExist loc) + ( do + absloc <- absPath loc + catchBoolIO $ do + createSymbolicLink absloc file + return True + , return False + ) | Git.repoIsSsh (repo r) = ifM (Annex.Content.preseedTmp key file) ( copyFromRemote' r key Nothing file @@ -199,6 +199,7 @@ unitTests note = testGroup ("Unit Tests " ++ note) , testCase "fsck (bare)" test_fsck_bare , testCase "fsck (local untrusted)" test_fsck_localuntrusted , testCase "fsck (remote untrusted)" test_fsck_remoteuntrusted + , testCase "fsck --from remote" test_fsck_fromremote , testCase "migrate" test_migrate , testCase "migrate (via gitattributes)" test_migrate_via_gitattributes , testCase "unused" test_unused @@ -613,6 +614,10 @@ test_fsck_remoteuntrusted = intmpclonerepo $ do git_annex "untrust" ["origin"] @? "untrust of origin failed" fsck_should_fail "content not replicated to enough non-untrusted repositories" +test_fsck_fromremote :: Assertion +test_fsck_fromremote = intmpclonerepo $ do + git_annex "fsck" ["--from", "origin"] @? "fsck --from origin failed" + fsck_should_fail :: String -> Assertion fsck_should_fail m = not <$> git_annex "fsck" [] @? "fsck failed to fail with " ++ m diff --git a/debian/changelog b/debian/changelog index 8bbadfea2..fc7c23d87 100644 --- a/debian/changelog +++ b/debian/changelog @@ -14,6 +14,9 @@ git-annex (5.20150410) UNRELEASED; urgency=medium (A reversion introduced in version 5.20150113.) * When a key's size is unknown, still check the annex.diskreserve, and avoid getting content if the disk is too full. + * Fix fsck --from a git remote in a local directory, and from + a directory special remote. + This was a reversion caused by the relative path changes in 5.20150113. -- Joey Hess <id@joeyh.name> Thu, 09 Apr 2015 20:59:43 -0400 diff --git a/doc/bugs/fsck_--from___36__remote__44___copies_symlinks_instead_of_content.mdwn b/doc/bugs/fsck_--from___36__remote__44___copies_symlinks_instead_of_content.mdwn index 593b7e9aa..732af2990 100644 --- a/doc/bugs/fsck_--from___36__remote__44___copies_symlinks_instead_of_content.mdwn +++ b/doc/bugs/fsck_--from___36__remote__44___copies_symlinks_instead_of_content.mdwn @@ -76,3 +76,5 @@ See transcript lrwxrwxrwx 1 gemma users 197 Apr 18 17:27 fsck24477.SHA256E-s2--0263829989b6fd954f72baaf2fc64bc2e2f01d692d4de72986ea808f6e99813f.txt -> ../corrupt/.git/annex/objects/x7/01/SHA256E-s2--0263829989b6fd954f72baaf2fc64bc2e2f01d692d4de72986ea808f6e99813f.txt/SHA256E-s2--0263829989b6fd954f72baaf2fc64bc2e2f01d692d4de72986ea808f6e99813f.txt lrwxrwxrwx 1 gemma users 197 Apr 18 17:27 fsck24477.SHA256E-s2--87428fc522803d31065e7bce3cf03fe475096631e5e07bbd7a0fde60c4cf25c7.txt -> ../corrupt/.git/annex/objects/41/pJ/SHA256E-s2--87428fc522803d31065e7bce3cf03fe475096631e5e07bbd7a0fde60c4cf25c7.txt/SHA256E-s2--87428fc522803d31065e7bce3cf03fe475096631e5e07bbd7a0fde60c4cf25c7.txt lrwxrwxrwx 1 gemma users 197 Apr 18 17:27 fsck24477.SHA256E-s2--a3a5e715f0cc574a73c3f9bebb6bc24f32ffd5b67b387244c2c909da779a1478.txt -> ../corrupt/.git/annex/objects/Vw/zz/SHA256E-s2--a3a5e715f0cc574a73c3f9bebb6bc24f32ffd5b67b387244c2c909da779a1478.txt/SHA256E-s2--a3a5e715f0cc574a73c3f9bebb6bc24f32ffd5b67b387244c2c909da779a1478.txt + +> reproduced, test cased, fixed, [[done]] --[[Joey]] |