uninit: Fix crash due to trying to write to deleted keys db.
Reversion introduced by v6 mode support, affects v5 too. Also fix a similar crash when the webapp is used to delete a repository.
This commit is contained in:
parent
db6b307ef7
commit
0c713a94bd
6 changed files with 42 additions and 14 deletions
|
@ -17,17 +17,15 @@ import Assistant.Sync
|
|||
import qualified Remote
|
||||
import qualified Git
|
||||
import Config.Files
|
||||
import Utility.FileMode
|
||||
import Logs.Trust
|
||||
import Logs.Remote
|
||||
import Logs.PreferredContent
|
||||
import Types.StandardGroups
|
||||
import Annex.UUID
|
||||
import Command.Uninit (prepareRemoveAnnexDir)
|
||||
|
||||
import System.IO.HVFS (SystemFS(..))
|
||||
import qualified Data.Text as T
|
||||
import qualified Data.Map as M
|
||||
import System.Path
|
||||
|
||||
notCurrentRepo :: UUID -> Handler Html -> Handler Html
|
||||
notCurrentRepo uuid a = do
|
||||
|
@ -99,12 +97,8 @@ deleteCurrentRepository = dangerPage $ do
|
|||
rs <- syncRemotes <$> getDaemonStatus
|
||||
mapM_ (\r -> changeSyncable (Just r) False) rs
|
||||
|
||||
{- Make all directories writable and files writable
|
||||
- so all annexed content can be deleted. -}
|
||||
liftIO $ do
|
||||
recurseDir SystemFS dir
|
||||
>>= mapM_ (void . tryIO . allowWrite)
|
||||
removeDirectoryRecursive =<< absPath dir
|
||||
liftAnnex $ prepareRemoveAnnexDir dir
|
||||
liftIO $ removeDirectoryRecursive =<< absPath dir
|
||||
|
||||
redirect ShutdownConfirmedR
|
||||
_ -> $(widgetFile "configurators/delete/currentrepository")
|
||||
|
|
|
@ -15,6 +15,9 @@ git-annex (6.20160614) UNRELEASED; urgency=medium
|
|||
* fsck: Fix a reversion in direct mode fsck of a file that is
|
||||
present when the location log thinks it is not. Reversion introduced
|
||||
in version 5.20151208.
|
||||
* uninit: Fix crash due to trying to write to deleted keys db.
|
||||
Reversion introduced by v6 mode support, affects v5 too.
|
||||
* Fix a similar crash when the webapp is used to delete a repository.
|
||||
|
||||
-- Joey Hess <id@joeyh.name> Mon, 13 Jun 2016 21:52:24 -0400
|
||||
|
||||
|
|
|
@ -13,6 +13,7 @@ import qualified Git
|
|||
import qualified Git.Command
|
||||
import qualified Command.Unannex
|
||||
import qualified Annex.Branch
|
||||
import qualified Database.Keys
|
||||
import Annex.Content
|
||||
import Annex.Init
|
||||
import Utility.FileMode
|
||||
|
@ -61,7 +62,7 @@ finish = do
|
|||
annexdir <- fromRepo gitAnnexDir
|
||||
annexobjectdir <- fromRepo gitAnnexObjectDir
|
||||
leftovers <- removeUnannexed =<< getKeysPresent InAnnex
|
||||
liftIO $ prepareRemoveAnnexDir annexdir
|
||||
prepareRemoveAnnexDir annexdir
|
||||
if null leftovers
|
||||
then liftIO $ removeDirectoryRecursive annexdir
|
||||
else error $ unlines
|
||||
|
@ -89,9 +90,17 @@ finish = do
|
|||
liftIO exitSuccess
|
||||
|
||||
{- Turn on write bits in all remaining files in the annex directory, in
|
||||
- preparation for removal. -}
|
||||
prepareRemoveAnnexDir :: FilePath -> IO ()
|
||||
prepareRemoveAnnexDir annexdir =
|
||||
- preparation for removal.
|
||||
-
|
||||
- Also closes sqlite databases that might be in the directory,
|
||||
- to avoid later failure to write any cached changes to them. -}
|
||||
prepareRemoveAnnexDir :: FilePath -> Annex ()
|
||||
prepareRemoveAnnexDir annexdir = do
|
||||
Database.Keys.closeDb
|
||||
liftIO $ prepareRemoveAnnexDir' annexdir
|
||||
|
||||
prepareRemoveAnnexDir' :: FilePath -> IO ()
|
||||
prepareRemoveAnnexDir' annexdir =
|
||||
recurseDir SystemFS annexdir >>= mapM_ (void . tryIO . allowWrite)
|
||||
|
||||
{- Keys that were moved out of the annex have a hard link still in the
|
||||
|
|
2
Test.hs
2
Test.hs
|
@ -1837,7 +1837,7 @@ cleanup = cleanup' False
|
|||
|
||||
cleanup' :: Bool -> FilePath -> IO ()
|
||||
cleanup' final dir = whenM (doesDirectoryExist dir) $ do
|
||||
Command.Uninit.prepareRemoveAnnexDir dir
|
||||
Command.Uninit.prepareRemoveAnnexDir' dir
|
||||
-- This sometimes fails on Windows, due to some files
|
||||
-- being still opened by a subprocess.
|
||||
catchIO (removeDirectoryRecursive dir) $ \e ->
|
||||
|
|
|
@ -1,3 +1,5 @@
|
|||
[[!meta title="git annex uninit causes SqlLite3 error"]]
|
||||
|
||||
### Please describe the problem.
|
||||
I am basically having issues with `git annex uninit`
|
||||
|
||||
|
@ -74,3 +76,5 @@ Now if I add a local file I get a different error
|
|||
### Have you had any luck using git-annex before? (Sometimes we get tired of reading bug reports all day and a lil' positive end note does wonders)
|
||||
|
||||
I am super excited about what I can do with git-annex. I hope to setup and maintain encrypted repo(s) of some of my files, and access them by cloning a local copy of the encrypted repo and getting the files I want, using them, and then deleting the local copy.
|
||||
|
||||
> [[fixed|done]] --[[Joey]]
|
||||
|
|
|
@ -0,0 +1,18 @@
|
|||
[[!comment format=mdwn
|
||||
username="joey"
|
||||
subject="""comment 1"""
|
||||
date="2016-07-12T17:48:50Z"
|
||||
content="""
|
||||
Not OSX specific; reproduced on Linux.
|
||||
|
||||
Instrumentation shows that removeInodeCaches is being called, when it
|
||||
unannexes the annexed file. This is why a file has to have been added to
|
||||
the repo to get the crash.
|
||||
|
||||
It's actually not necessary for removeInodeCaches to be called in a v5
|
||||
repo, only in v6. If the code checked for v6 mode before writing to the
|
||||
database, such problems would be avoided except for in v6 mode.
|
||||
|
||||
But, the actual fix is to make uninit close this and all other sqlite
|
||||
db's before deleting the .git/annex directory.
|
||||
"""]]
|
Loading…
Reference in a new issue