avoid locking the journal in readonly repository
The test suite flagged that git-annex info in a readonly repository was no longer working. .git/annex/journal.lck: openFd: permission denied This fixes it, however, in a case where .git/annex/reposize/ is writable, but .git/annex/journal/ is not, there will still be a permission denied error. The solution would just be to use consistent permissions I suppose.
This commit is contained in:
parent
53b7375cc6
commit
133584a83a
2 changed files with 17 additions and 2 deletions
|
@ -138,11 +138,18 @@ calcJournalledRepoSizes
|
|||
-> M.Map UUID RepoSize
|
||||
-> Sha
|
||||
-> Annex (M.Map UUID (RepoSize, SizeOffset))
|
||||
calcJournalledRepoSizes h startmap branchsha =
|
||||
calcJournalledRepoSizes h startmap branchsha
|
||||
-- Lock the journal to prevent updates to the size offsets
|
||||
-- in the repository size database while this is processing
|
||||
-- the journal files.
|
||||
lockJournal $ \_jl -> do
|
||||
| Db.isOpenDb h = lockJournal $ \_jl -> go
|
||||
-- When the repository is not writable, the database won't have
|
||||
-- been opened, and locking the journal would also not succeed.
|
||||
-- But there is no need to lock the journal in this case,
|
||||
-- since no offsets will be read from the database.
|
||||
| otherwise = go
|
||||
where
|
||||
go = do
|
||||
sizemap <- overLocationLogsJournal startmap branchsha
|
||||
(\k v m' -> pure (accumRepoSizes k v m'))
|
||||
Nothing
|
||||
|
|
|
@ -23,6 +23,7 @@ module Database.RepoSize (
|
|||
getRepoSizeHandle,
|
||||
openDb,
|
||||
closeDb,
|
||||
isOpenDb,
|
||||
lockDbWhile,
|
||||
getRepoSizes,
|
||||
setRepoSizes,
|
||||
|
@ -126,6 +127,13 @@ openDb = lockDbWhile permerr $ do
|
|||
-- efficiently.
|
||||
permerr _e = mkhandle Nothing
|
||||
|
||||
-- When the repository cannot be written to, openDb returns a
|
||||
-- RepoSizeHandle that is not actually open, all operations on it will do
|
||||
-- nothing.
|
||||
isOpenDb :: RepoSizeHandle -> Bool
|
||||
isOpenDb (RepoSizeHandle (Just _) _) = True
|
||||
isOpenDb (RepoSizeHandle Nothing _) = False
|
||||
|
||||
closeDb :: RepoSizeHandle -> Annex ()
|
||||
closeDb (RepoSizeHandle (Just h) _) = liftIO $ H.closeDb h
|
||||
closeDb (RepoSizeHandle Nothing _) = noop
|
||||
|
|
Loading…
Reference in a new issue