summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGravatar Joey Hess <joeyh@joeyh.name>2016-07-12 14:18:35 -0400
committerGravatar Joey Hess <joeyh@joeyh.name>2016-07-12 14:18:35 -0400
commit8a7b972e55fa6eaa4c754303b3ee8fd214a51468 (patch)
treecb41dbe7b3bb265a22b6d61631e5e27ab3e187fa
parent50c57ea1c0ec659e565578e9011e3111e6b11898 (diff)
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.
-rw-r--r--CHANGELOG3
-rw-r--r--Command/Uninit.hs17
-rw-r--r--Test.hs2
-rw-r--r--doc/bugs/git_uninit_on_OS_X_causes_SqlLite3_error.mdwn4
-rw-r--r--doc/bugs/git_uninit_on_OS_X_causes_SqlLite3_error/comment_1_be3aaa58fd3adfa5eeb893c205aa871c._comment18
5 files changed, 39 insertions, 5 deletions
diff --git a/CHANGELOG b/CHANGELOG
index c7f6c4d35..f1548c711 100644
--- a/CHANGELOG
+++ b/CHANGELOG
@@ -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
diff --git a/Command/Uninit.hs b/Command/Uninit.hs
index 44f4b0ded..fa7e13013 100644
--- a/Command/Uninit.hs
+++ b/Command/Uninit.hs
@@ -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
diff --git a/Test.hs b/Test.hs
index f92d825d0..35d9ddace 100644
--- a/Test.hs
+++ b/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 ->
diff --git a/doc/bugs/git_uninit_on_OS_X_causes_SqlLite3_error.mdwn b/doc/bugs/git_uninit_on_OS_X_causes_SqlLite3_error.mdwn
index 1250061d6..cf779ab3d 100644
--- a/doc/bugs/git_uninit_on_OS_X_causes_SqlLite3_error.mdwn
+++ b/doc/bugs/git_uninit_on_OS_X_causes_SqlLite3_error.mdwn
@@ -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]]
diff --git a/doc/bugs/git_uninit_on_OS_X_causes_SqlLite3_error/comment_1_be3aaa58fd3adfa5eeb893c205aa871c._comment b/doc/bugs/git_uninit_on_OS_X_causes_SqlLite3_error/comment_1_be3aaa58fd3adfa5eeb893c205aa871c._comment
new file mode 100644
index 000000000..fed1699ac
--- /dev/null
+++ b/doc/bugs/git_uninit_on_OS_X_causes_SqlLite3_error/comment_1_be3aaa58fd3adfa5eeb893c205aa871c._comment
@@ -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.
+"""]]