diff options
author | Joey Hess <joeyh@joeyh.name> | 2016-05-16 13:19:02 -0400 |
---|---|---|
committer | Joey Hess <joeyh@joeyh.name> | 2016-05-16 13:19:02 -0400 |
commit | bf36bf5afdbaca9431dbb2b867f5f92a8ecdfc48 (patch) | |
tree | 9f75c6a73be2cdb30f3b4e9a8e8ea4593350b002 /Assistant | |
parent | 527853c9d039a7fb60a0acd6057923cb610a116d (diff) |
stage pointer file not annex link
Diffstat (limited to 'Assistant')
-rw-r--r-- | Assistant/Threads/Watcher.hs | 33 |
1 files changed, 24 insertions, 9 deletions
diff --git a/Assistant/Threads/Watcher.hs b/Assistant/Threads/Watcher.hs index f0a639984..1a3acbbfd 100644 --- a/Assistant/Threads/Watcher.hs +++ b/Assistant/Threads/Watcher.hs @@ -221,7 +221,7 @@ shouldRestage :: DaemonStatus -> Bool shouldRestage ds = scanComplete ds || forceRestage ds onAddUnlocked :: Bool -> GetFileMatcher -> Handler -onAddUnlocked = onAddUnlocked' False contentchanged addassociatedfile samefilestatus +onAddUnlocked = onAddUnlocked' False contentchanged addassociatedfile addlink samefilestatus where addassociatedfile key file = Database.Keys.addAssociatedFile key @@ -238,15 +238,32 @@ onAddUnlocked = onAddUnlocked' False contentchanged addassociatedfile samefilest =<< inRepo (toTopFilePath file) unlessM (inAnnex oldkey) $ logStatus oldkey InfoMissing + addlink file key = do + mode <- liftIO $ catchMaybeIO $ fileMode <$> getFileStatus file + liftAnnex $ stagePointerFile file mode =<< hashPointerFile key + madeChange file $ LinkChange (Just key) {- In direct mode, add events are received for both new files, and - modified existing files. -} onAddDirect :: Bool -> GetFileMatcher -> Handler -onAddDirect = onAddUnlocked' True changedDirect (\k f -> void $ addAssociatedFile k f) sameFileStatus - -onAddUnlocked' :: Bool -> (Key -> FilePath -> Annex ()) -> (Key -> FilePath -> Annex ()) -> (Key -> FilePath -> FileStatus -> Annex Bool) -> Bool -> GetFileMatcher -> Handler -onAddUnlocked' isdirect contentchanged addassociatedfile samefilestatus symlinkssupported matcher file fs = do +onAddDirect = onAddUnlocked' True changedDirect addassociatedfile addlink sameFileStatus + where + addassociatedfile key file = void $ addAssociatedFile key file + addlink file key = do + link <- liftAnnex $ calcRepo $ gitAnnexLink file key + addLink file link (Just key) + +onAddUnlocked' + :: Bool + -> (Key -> FilePath -> Annex ()) + -> (Key -> FilePath -> Annex ()) + -> (FilePath -> Key -> Assistant (Maybe Change)) + -> (Key -> FilePath -> FileStatus -> Annex Bool) + -> Bool + -> GetFileMatcher + -> Handler +onAddUnlocked' isdirect contentchanged addassociatedfile addlink samefilestatus symlinkssupported matcher file fs = do v <- liftAnnex $ catKeyFile file case (v, fs) of (Just key, Just filestatus) -> @@ -255,11 +272,9 @@ onAddUnlocked' isdirect contentchanged addassociatedfile samefilestatus symlinks - an existing file that is not - really modified, but it might have - just been deleted and been put back, - - so it symlink is restaged to make sure. -} + - so its annex link is restaged to make sure. -} ( ifM (shouldRestage <$> getDaemonStatus) - ( do - link <- liftAnnex $ calcRepo $ gitAnnexLink file key - addLink file link (Just key) + ( addlink file key , noChange ) , guardSymlinkStandin (Just key) $ do |