Revert "lock journal before reading journal files"
This reverts commit 47358a6f95
.
This added overhead, and will not be needed, because appends are going
to have to be made atomic for other reasons than avoiding incomplete
reads of data being appended.
In particular, when git-annex is interrupted in the middle of an append,
it must not leave the file with a partially written line. So appending
has to somehow be made fully atomic.
This commit is contained in:
parent
ce455223df
commit
2e6e9876e3
1 changed files with 19 additions and 20 deletions
|
@ -236,7 +236,7 @@ updateTo' pairs = do
|
||||||
else return $ "merging " ++
|
else return $ "merging " ++
|
||||||
unwords (map Git.Ref.describe branches) ++
|
unwords (map Git.Ref.describe branches) ++
|
||||||
" into " ++ fromRef name
|
" into " ++ fromRef name
|
||||||
localtransitions <- getLocalTransitions jl
|
localtransitions <- getLocalTransitions
|
||||||
unless (null tomerge) $ do
|
unless (null tomerge) $ do
|
||||||
showSideAction merge_desc
|
showSideAction merge_desc
|
||||||
mapM_ checkBranchDifferences refs
|
mapM_ checkBranchDifferences refs
|
||||||
|
@ -265,7 +265,7 @@ updateTo' pairs = do
|
||||||
-- Gather any transitions that are new to either the
|
-- Gather any transitions that are new to either the
|
||||||
-- local branch or a remote ref, which will need to be
|
-- local branch or a remote ref, which will need to be
|
||||||
-- applied on the fly.
|
-- applied on the fly.
|
||||||
localts <- lockJournal getLocalTransitions
|
localts <- getLocalTransitions
|
||||||
remotets <- mapM getRefTransitions refs
|
remotets <- mapM getRefTransitions refs
|
||||||
ts <- if all (localts ==) remotets
|
ts <- if all (localts ==) remotets
|
||||||
then return []
|
then return []
|
||||||
|
@ -307,14 +307,13 @@ get file = do
|
||||||
content <- if journalIgnorable st
|
content <- if journalIgnorable st
|
||||||
then getRef fullname file
|
then getRef fullname file
|
||||||
else if null (unmergedRefs st)
|
else if null (unmergedRefs st)
|
||||||
then lockJournal $
|
then getLocal file
|
||||||
\jl -> getLocal jl file
|
|
||||||
else unmergedbranchfallback st
|
else unmergedbranchfallback st
|
||||||
setCache file content
|
setCache file content
|
||||||
return content
|
return content
|
||||||
where
|
where
|
||||||
unmergedbranchfallback st = do
|
unmergedbranchfallback st = do
|
||||||
l <- lockJournal $ \jl -> getLocal jl file
|
l <- getLocal file
|
||||||
bs <- forM (unmergedRefs st) $ \ref -> getRef ref file
|
bs <- forM (unmergedRefs st) $ \ref -> getRef ref file
|
||||||
let content = l <> mconcat bs
|
let content = l <> mconcat bs
|
||||||
return $ applytransitions (unhandledTransitions st) content
|
return $ applytransitions (unhandledTransitions st) content
|
||||||
|
@ -344,7 +343,7 @@ precache file branchcontent = do
|
||||||
st <- getState
|
st <- getState
|
||||||
content <- if journalIgnorable st
|
content <- if journalIgnorable st
|
||||||
then pure branchcontent
|
then pure branchcontent
|
||||||
else lockJournal $ \jl -> getJournalFile jl (GetPrivate True) file >>= return . \case
|
else getJournalFileStale (GetPrivate True) file >>= return . \case
|
||||||
NoJournalledContent -> branchcontent
|
NoJournalledContent -> branchcontent
|
||||||
JournalledContent journalcontent -> journalcontent
|
JournalledContent journalcontent -> journalcontent
|
||||||
PossiblyStaleJournalledContent journalcontent ->
|
PossiblyStaleJournalledContent journalcontent ->
|
||||||
|
@ -355,13 +354,13 @@ precache file branchcontent = do
|
||||||
- reflect changes in remotes.
|
- reflect changes in remotes.
|
||||||
- (Changing the value this returns, and then merging is always the
|
- (Changing the value this returns, and then merging is always the
|
||||||
- same as using get, and then changing its value.) -}
|
- same as using get, and then changing its value.) -}
|
||||||
getLocal :: JournalLocked -> RawFilePath -> Annex L.ByteString
|
getLocal :: RawFilePath -> Annex L.ByteString
|
||||||
getLocal jl = getLocal' jl (GetPrivate True)
|
getLocal = getLocal' (GetPrivate True)
|
||||||
|
|
||||||
getLocal' :: JournalLocked -> GetPrivate -> RawFilePath -> Annex L.ByteString
|
getLocal' :: GetPrivate -> RawFilePath -> Annex L.ByteString
|
||||||
getLocal' jl getprivate file = do
|
getLocal' getprivate file = do
|
||||||
fastDebug "Annex.Branch" ("read " ++ fromRawFilePath file)
|
fastDebug "Annex.Branch" ("read " ++ fromRawFilePath file)
|
||||||
go =<< getJournalFile jl getprivate file
|
go =<< getJournalFileStale getprivate file
|
||||||
where
|
where
|
||||||
go NoJournalledContent = getRef fullname file
|
go NoJournalledContent = getRef fullname file
|
||||||
go (JournalledContent journalcontent) = return journalcontent
|
go (JournalledContent journalcontent) = return journalcontent
|
||||||
|
@ -395,12 +394,12 @@ getRef ref file = withIndex $ catFile ref file
|
||||||
- modifes the current content of the file on the branch.
|
- modifes the current content of the file on the branch.
|
||||||
-}
|
-}
|
||||||
change :: Journalable content => RegardingUUID -> RawFilePath -> (L.ByteString -> content) -> Annex ()
|
change :: Journalable content => RegardingUUID -> RawFilePath -> (L.ByteString -> content) -> Annex ()
|
||||||
change ru file f = lockJournal $ \jl -> f <$> getToChange jl ru file >>= set jl ru file
|
change ru file f = lockJournal $ \jl -> f <$> getToChange ru file >>= set jl ru file
|
||||||
|
|
||||||
{- Applies a function which can modify the content of a file, or not. -}
|
{- Applies a function which can modify the content of a file, or not. -}
|
||||||
maybeChange :: Journalable content => RegardingUUID -> RawFilePath -> (L.ByteString -> Maybe content) -> Annex ()
|
maybeChange :: Journalable content => RegardingUUID -> RawFilePath -> (L.ByteString -> Maybe content) -> Annex ()
|
||||||
maybeChange ru file f = lockJournal $ \jl -> do
|
maybeChange ru file f = lockJournal $ \jl -> do
|
||||||
v <- getToChange jl ru file
|
v <- getToChange ru file
|
||||||
case f v of
|
case f v of
|
||||||
Just jv ->
|
Just jv ->
|
||||||
let b = journalableByteString jv
|
let b = journalableByteString jv
|
||||||
|
@ -421,8 +420,8 @@ changeOrAppend ru file f = lockJournal $ \jl -> do
|
||||||
Append toappend -> append jl ru file oldc toappend
|
Append toappend -> append jl ru file oldc toappend
|
||||||
|
|
||||||
{- Only get private information when the RegardingUUID is itself private. -}
|
{- Only get private information when the RegardingUUID is itself private. -}
|
||||||
getToChange :: JournalLocked -> RegardingUUID -> RawFilePath -> Annex L.ByteString
|
getToChange :: RegardingUUID -> RawFilePath -> Annex L.ByteString
|
||||||
getToChange jl ru f = flip (getLocal' jl) f . GetPrivate =<< regardingPrivateUUID ru
|
getToChange ru f = flip getLocal' f . GetPrivate =<< regardingPrivateUUID ru
|
||||||
|
|
||||||
{- Records new content of a file into the journal.
|
{- Records new content of a file into the journal.
|
||||||
-
|
-
|
||||||
|
@ -708,10 +707,10 @@ stageJournal jl commitindex = withIndex $ withOtherTmp $ \tmpdir -> do
|
||||||
removeWhenExistsWith (R.removeLink) (toRawFilePath jlogf)
|
removeWhenExistsWith (R.removeLink) (toRawFilePath jlogf)
|
||||||
openjlog tmpdir = liftIO $ openTmpFileIn tmpdir "jlog"
|
openjlog tmpdir = liftIO $ openTmpFileIn tmpdir "jlog"
|
||||||
|
|
||||||
getLocalTransitions :: JournalLocked -> Annex Transitions
|
getLocalTransitions :: Annex Transitions
|
||||||
getLocalTransitions jl =
|
getLocalTransitions =
|
||||||
parseTransitionsStrictly "local"
|
parseTransitionsStrictly "local"
|
||||||
<$> getLocal jl transitionsLog
|
<$> getLocal transitionsLog
|
||||||
|
|
||||||
{- This is run after the refs have been merged into the index,
|
{- This is run after the refs have been merged into the index,
|
||||||
- but before the result is committed to the branch.
|
- but before the result is committed to the branch.
|
||||||
|
@ -960,7 +959,7 @@ overBranchFileContents' select go st = do
|
||||||
-- Check the journal, in case it did not get committed to the branch
|
-- Check the journal, in case it did not get committed to the branch
|
||||||
checkjournal f branchcontent
|
checkjournal f branchcontent
|
||||||
| journalIgnorable st = return branchcontent
|
| journalIgnorable st = return branchcontent
|
||||||
| otherwise = lockJournal $ \jl -> getJournalFile jl (GetPrivate True) f >>= return . \case
|
| otherwise = getJournalFileStale (GetPrivate True) f >>= return . \case
|
||||||
NoJournalledContent -> branchcontent
|
NoJournalledContent -> branchcontent
|
||||||
JournalledContent journalledcontent ->
|
JournalledContent journalledcontent ->
|
||||||
Just journalledcontent
|
Just journalledcontent
|
||||||
|
@ -970,7 +969,7 @@ overBranchFileContents' select go st = do
|
||||||
drain buf fs = case getnext fs of
|
drain buf fs = case getnext fs of
|
||||||
Just (v, f, fs') -> do
|
Just (v, f, fs') -> do
|
||||||
liftIO $ putMVar buf fs'
|
liftIO $ putMVar buf fs'
|
||||||
content <- lockJournal $ \jl -> getJournalFile jl (GetPrivate True) f >>= \case
|
content <- getJournalFileStale (GetPrivate True) f >>= \case
|
||||||
NoJournalledContent -> return Nothing
|
NoJournalledContent -> return Nothing
|
||||||
JournalledContent journalledcontent ->
|
JournalledContent journalledcontent ->
|
||||||
return (Just journalledcontent)
|
return (Just journalledcontent)
|
||||||
|
|
Loading…
Add table
Reference in a new issue