stage pointer file not annex link

This commit is contained in:
Joey Hess 2016-05-16 13:19:02 -04:00
parent 9f05be393e
commit c61f038fc9
Failed to extract signature

View file

@ -221,7 +221,7 @@ shouldRestage :: DaemonStatus -> Bool
shouldRestage ds = scanComplete ds || forceRestage ds shouldRestage ds = scanComplete ds || forceRestage ds
onAddUnlocked :: Bool -> GetFileMatcher -> Handler onAddUnlocked :: Bool -> GetFileMatcher -> Handler
onAddUnlocked = onAddUnlocked' False contentchanged addassociatedfile samefilestatus onAddUnlocked = onAddUnlocked' False contentchanged addassociatedfile addlink samefilestatus
where where
addassociatedfile key file = addassociatedfile key file =
Database.Keys.addAssociatedFile key Database.Keys.addAssociatedFile key
@ -238,15 +238,32 @@ onAddUnlocked = onAddUnlocked' False contentchanged addassociatedfile samefilest
=<< inRepo (toTopFilePath file) =<< inRepo (toTopFilePath file)
unlessM (inAnnex oldkey) $ unlessM (inAnnex oldkey) $
logStatus oldkey InfoMissing 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 {- In direct mode, add events are received for both new files, and
- modified existing files. - modified existing files.
-} -}
onAddDirect :: Bool -> GetFileMatcher -> Handler 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'
onAddUnlocked' isdirect contentchanged addassociatedfile samefilestatus symlinkssupported matcher file fs = do :: 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 v <- liftAnnex $ catKeyFile file
case (v, fs) of case (v, fs) of
(Just key, Just filestatus) -> (Just key, Just filestatus) ->
@ -255,11 +272,9 @@ onAddUnlocked' isdirect contentchanged addassociatedfile samefilestatus symlinks
- an existing file that is not - an existing file that is not
- really modified, but it might have - really modified, but it might have
- just been deleted and been put back, - 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) ( ifM (shouldRestage <$> getDaemonStatus)
( do ( addlink file key
link <- liftAnnex $ calcRepo $ gitAnnexLink file key
addLink file link (Just key)
, noChange , noChange
) )
, guardSymlinkStandin (Just key) $ do , guardSymlinkStandin (Just key) $ do