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
|
-> M.Map UUID RepoSize
|
||||||
-> Sha
|
-> Sha
|
||||||
-> Annex (M.Map UUID (RepoSize, SizeOffset))
|
-> Annex (M.Map UUID (RepoSize, SizeOffset))
|
||||||
calcJournalledRepoSizes h startmap branchsha =
|
calcJournalledRepoSizes h startmap branchsha
|
||||||
-- Lock the journal to prevent updates to the size offsets
|
-- Lock the journal to prevent updates to the size offsets
|
||||||
-- in the repository size database while this is processing
|
-- in the repository size database while this is processing
|
||||||
-- the journal files.
|
-- 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
|
sizemap <- overLocationLogsJournal startmap branchsha
|
||||||
(\k v m' -> pure (accumRepoSizes k v m'))
|
(\k v m' -> pure (accumRepoSizes k v m'))
|
||||||
Nothing
|
Nothing
|
||||||
|
|
|
@ -23,6 +23,7 @@ module Database.RepoSize (
|
||||||
getRepoSizeHandle,
|
getRepoSizeHandle,
|
||||||
openDb,
|
openDb,
|
||||||
closeDb,
|
closeDb,
|
||||||
|
isOpenDb,
|
||||||
lockDbWhile,
|
lockDbWhile,
|
||||||
getRepoSizes,
|
getRepoSizes,
|
||||||
setRepoSizes,
|
setRepoSizes,
|
||||||
|
@ -126,6 +127,13 @@ openDb = lockDbWhile permerr $ do
|
||||||
-- efficiently.
|
-- efficiently.
|
||||||
permerr _e = mkhandle Nothing
|
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 -> Annex ()
|
||||||
closeDb (RepoSizeHandle (Just h) _) = liftIO $ H.closeDb h
|
closeDb (RepoSizeHandle (Just h) _) = liftIO $ H.closeDb h
|
||||||
closeDb (RepoSizeHandle Nothing _) = noop
|
closeDb (RepoSizeHandle Nothing _) = noop
|
||||||
|
|
Loading…
Reference in a new issue