From c61f038fc9bce4d4e7788b8149512b17b59df772 Mon Sep 17 00:00:00 2001 From: Joey Hess <joeyh@joeyh.name> Date: Mon, 16 May 2016 13:19:02 -0400 Subject: [PATCH] stage pointer file not annex link --- Assistant/Threads/Watcher.hs | 31 +++++++++++++++++++++++-------- 1 file changed, 23 insertions(+), 8 deletions(-) diff --git a/Assistant/Threads/Watcher.hs b/Assistant/Threads/Watcher.hs index f0a639984b..1a3acbbfd6 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 +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 ()) -> (Key -> FilePath -> FileStatus -> Annex Bool) -> Bool -> GetFileMatcher -> Handler -onAddUnlocked' isdirect contentchanged addassociatedfile samefilestatus symlinkssupported matcher file fs = do +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