aboutsummaryrefslogtreecommitdiff
path: root/Assistant/Threads
diff options
context:
space:
mode:
authorGravatar Joey Hess <joeyh@joeyh.name>2016-01-05 17:22:19 -0400
committerGravatar Joey Hess <joeyh@joeyh.name>2016-01-05 17:22:19 -0400
commit903241502a6ad1a4845ac2d131ef7fc2b547400d (patch)
treefba85c9751a19aa0873e0f2bd837a1b000588508 /Assistant/Threads
parentcf911557bf4bb27768c4fc5ac482e8f827807497 (diff)
use TopFilePath for associated files
Fixes several bugs with updates of pointer files. When eg, running git annex drop --from localremote it was updating the pointer file in the local repository, not the remote. Also, fixes drop ../foo when run in a subdir, and probably lots of other problems. Test suite drops from ~30 to 11 failures now. TopFilePath is used to force thinking about what the filepath is relative to. The data stored in the sqlite db is still just a plain string, and TopFilePath is a newtype, so there's no overhead involved in using it in DataBase.Keys.
Diffstat (limited to 'Assistant/Threads')
-rw-r--r--Assistant/Threads/Watcher.hs12
1 files changed, 9 insertions, 3 deletions
diff --git a/Assistant/Threads/Watcher.hs b/Assistant/Threads/Watcher.hs
index bb9659b7c..d10f929d0 100644
--- a/Assistant/Threads/Watcher.hs
+++ b/Assistant/Threads/Watcher.hs
@@ -41,6 +41,7 @@ import Annex.ReplaceFile
import Annex.Version
import Annex.InodeSentinal
import Git.Types
+import Git.FilePath
import Config
import Utility.ThreadScheduler
import Logs.Location
@@ -225,8 +226,11 @@ shouldRestage :: DaemonStatus -> Bool
shouldRestage ds = scanComplete ds || forceRestage ds
onAddUnlocked :: Bool -> FileMatcher Annex -> Handler
-onAddUnlocked = onAddUnlocked' False contentchanged Database.Keys.addAssociatedFile samefilestatus
+onAddUnlocked = onAddUnlocked' False contentchanged addassociatedfile samefilestatus
where
+ addassociatedfile key file =
+ Database.Keys.addAssociatedFile key
+ =<< inRepo (toTopFilePath file)
samefilestatus key file status = do
cache <- Database.Keys.getInodeCaches key
curr <- withTSDelta $ \delta -> liftIO $ toInodeCache delta file status
@@ -235,7 +239,8 @@ onAddUnlocked = onAddUnlocked' False contentchanged Database.Keys.addAssociatedF
([], Nothing) -> return True
_ -> return False
contentchanged oldkey file = do
- Database.Keys.removeAssociatedFile oldkey file
+ Database.Keys.removeAssociatedFile oldkey
+ =<< inRepo (toTopFilePath file)
unlessM (inAnnex oldkey) $
logStatus oldkey InfoMissing
@@ -356,8 +361,9 @@ onDel file _ = do
onDel' :: FilePath -> Annex ()
onDel' file = do
+ topfile <- inRepo (toTopFilePath file)
ifM versionSupportsUnlockedPointers
- ( withkey $ flip Database.Keys.removeAssociatedFile file
+ ( withkey $ flip Database.Keys.removeAssociatedFile topfile
, whenM isDirect $
withkey $ \key -> void $ removeAssociatedFile key file
)