diff options
author | Joey Hess <joey@kitenet.net> | 2012-10-02 17:34:22 -0400 |
---|---|---|
committer | Joey Hess <joey@kitenet.net> | 2012-10-02 17:41:23 -0400 |
commit | 8a12d8b5406aa99062470980510f6ea48a731d49 (patch) | |
tree | f827367a93f0cec6f89a7c98938f5916de2111ab /Assistant/Changes.hs | |
parent | ab39433a9523f9f8a9f8c561a46b38863c0f541d (diff) |
always check with ls-files before adding new files
Makes it safe to use git annex unlock with the watcher/assistant.
And also to mix use of the watcher/assistant with regular files stored in git.
Long ago, I had avoided doing this check, except during the startup scan,
because it would be slow to run ls-files repeatedly.
But then I added the lsof check, and to make that fast, got it to detect
batch file adds. So let's move the ls-files check to also occur when it'll
have a batch, and can check them all with one call.
This does slow down adding a single file by just a bit, but really only
a little bit. (The lsof check is probably more expensive.) It also
speeds up the startup scan, especially when there are lots of new files
found by the scan.
Also, fixed the sleep for annex.delayadd to not run while the threadstate
lock is held, so it doesn't unnecessarily freeze everything else.
Also, --force no longer makes it skip the lsof check, which was not
documented, and seems never a good idea.
Diffstat (limited to 'Assistant/Changes.hs')
-rw-r--r-- | Assistant/Changes.hs | 18 |
1 files changed, 13 insertions, 5 deletions
diff --git a/Assistant/Changes.hs b/Assistant/Changes.hs index eca922109..cccc372c1 100644 --- a/Assistant/Changes.hs +++ b/Assistant/Changes.hs @@ -27,6 +27,10 @@ data Change } | PendingAddChange { changeTime ::UTCTime + , changeFile :: FilePath + } + | InProcessAddChange + { changeTime ::UTCTime , keySource :: KeySource } deriving (Show) @@ -44,17 +48,21 @@ madeChange f t = do noChange :: Annex (Maybe Change) noChange = return Nothing -{- Indicates an add is in progress. -} -pendingAddChange :: KeySource -> Annex (Maybe Change) -pendingAddChange ks = - liftIO $ Just <$> (PendingAddChange <$> getCurrentTime <*> pure ks) +{- Indicates an add needs to be done, but has not started yet. -} +pendingAddChange :: FilePath -> Annex (Maybe Change) +pendingAddChange f = + liftIO $ Just <$> (PendingAddChange <$> getCurrentTime <*> pure f) isPendingAddChange :: Change -> Bool isPendingAddChange (PendingAddChange {}) = True isPendingAddChange _ = False +isInProcessAddChange :: Change -> Bool +isInProcessAddChange (InProcessAddChange {}) = True +isInProcessAddChange _ = False + finishedChange :: Change -> Change -finishedChange c@(PendingAddChange { keySource = ks }) = Change +finishedChange c@(InProcessAddChange { keySource = ks }) = Change { changeTime = changeTime c , changeFile = keyFilename ks , changeType = AddChange |