]> dgit.raspbian.org Git - git-annex.git/commitdiff
fix failing readonly test case
authorJoey Hess <joeyh@joeyh.name>
Fri, 21 Jan 2022 17:49:31 +0000 (13:49 -0400)
committerJoey Hess <joeyh@joeyh.name>
Fri, 21 Jan 2022 17:49:31 +0000 (13:49 -0400)
The problem is that withContentLockFile, in a v8 repo, has to take a shared
lock of `.git/annex/content.lck`. But, in a readonly repository, if that
file does not yet exist, it cannot lock it. And while it will sometimes
work to `chmod +r .git/annex`, the repository might be readonly due to
being owned by another user, or due to being mounted readonly.

So, it seems that the only solution is to use some other file than
`.git/annex/content.lck` as the lock file. The inode sential file
was almost the only option that should always exist. (And if it somehow
does not exist, creating an empty one for locking will be ok.)

Wow, what a hack!

Sponsored-by: Dartmouth College's Datalad project
Annex/Locations.hs

index 3a3933ea4cb8fea1b7941a667ec746ddb5d61542..25dd4a5f75208311ff6c436fbe37a2ba8c3655d6 100644 (file)
@@ -241,9 +241,15 @@ gitAnnexContentLock key r config = do
        return $ loc <> ".lck"
 
 {- Lock that is held when taking the gitAnnexContentLock to support the v10
- - upgrade. -}
+ - upgrade.
+ -
+ - This uses the gitAnnexInodeSentinal file, because it needs to be a file
+ - that exists in the repository, even when it's an old v8 repository that
+ - is mounted read-only. The gitAnnexInodeSentinal is created by git-annex
+ - init, so should already exist.
+ -}
 gitAnnexContentLockLock :: Git.Repo -> RawFilePath
-gitAnnexContentLockLock r = gitAnnexDir r P.</> "content.lck"
+gitAnnexContentLockLock = gitAnnexInodeSentinal
 
 gitAnnexInodeSentinal :: Git.Repo -> RawFilePath
 gitAnnexInodeSentinal r = gitAnnexDir r P.</> "sentinal"