avoid accidentally thawing git-annex symlink
authorJoey Hess <joeyh@joeyh.name>
Thu, 24 Feb 2022 18:21:23 +0000 (14:21 -0400)
committerJoey Hess <joeyh@joeyh.name>
Thu, 24 Feb 2022 18:21:23 +0000 (14:21 -0400)
It did nothing, since at this point the link is dangling. But when there
is a thaw hook, it would probably not be happy to be asked to run on a
symlink, or might do something unexpected.

Sponsored-by: Dartmouth College's Datalad project
Annex/Content.hs
doc/bugs/can__39__t_make_annex_happy_in_freeze__47__thaw.mdwn
doc/bugs/can__39__t_make_annex_happy_in_freeze__47__thaw/comment_7_f0a3a944479e52a7789ff9a346001a6d._comment [new file with mode: 0644]

index d4dac5caeb75037d16779d03be94b8d0e65d2c58..141f8e206a229cd45749821189ecd8080d405ec6 100644 (file)
@@ -631,15 +631,16 @@ removeAnnex (ContentRemovalLock key) = withObjectLoc key $ \file ->
   where
        -- Check associated pointer file for modifications, and reset if
        -- it's unmodified.
-       resetpointer file = ifM (isUnmodified key file)
-               ( adjustedBranchRefresh (AssociatedFile (Just file)) $
-                       depopulatePointerFile key file
-               -- Modified file, so leave it alone.
-               -- If it was a hard link to the annex object,
-               -- that object might have been frozen as part of the
-               -- removal process, so thaw it.
-               , void $ tryIO $ thawContent file
-               )
+       resetpointer file = unlessM (liftIO $ isSymbolicLink <$> getSymbolicLinkStatus (fromRawFilePath file)) $
+               ifM (isUnmodified key file)
+                       ( adjustedBranchRefresh (AssociatedFile (Just file)) $
+                               depopulatePointerFile key file
+                       -- Modified file, so leave it alone.
+                       -- If it was a hard link to the annex object,
+                       -- that object might have been frozen as part of the
+                       -- removal process, so thaw it.
+                       , void $ tryIO $ thawContent file
+                       )
 
 {- Moves a key out of .git/annex/objects/ into .git/annex/bad, and
  - returns the file it was moved to. -}
index bd4461a178701667d92ad606be8e6b69034aa44a..008294071a57dcd1701dadc4969bf7a936d3c94e 100644 (file)
@@ -175,3 +175,5 @@ filing as a bug since I think I satisfied all desires of git-annex for ensuring
 
 
 edit 1:  I thought that may be "Locking down a directory only needs to do the equivilant of removing its write bit, does not need to lockdown the files within it." from [lockdown_hooks](https://git-annex.branchable.com/todo/lockdown_hooks/) does not really "work", so I added `-R` to above nfs4_facl calls, but seems the effect is the same -- annex doesn' like me :-/
+
+> [[fixed|done]] --[[Joey]]
diff --git a/doc/bugs/can__39__t_make_annex_happy_in_freeze__47__thaw/comment_7_f0a3a944479e52a7789ff9a346001a6d._comment b/doc/bugs/can__39__t_make_annex_happy_in_freeze__47__thaw/comment_7_f0a3a944479e52a7789ff9a346001a6d._comment
new file mode 100644 (file)
index 0000000..5825a1c
--- /dev/null
@@ -0,0 +1,10 @@
+[[!comment format=mdwn
+ username="joey"
+ subject="""comment 7"""
+ date="2022-02-24T18:13:20Z"
+ content="""
+       [2022-02-24 13:50:11.885644532] (Annex.Perms) thawing content ./foo
+
+This turns out to be due to removeAnnex's resetpointer.
+It was not intended to run on symlinks. I've fixed this too.
+"""]]