simplify
This commit is contained in:
parent
1b041f5c51
commit
cdd512cd9f
3 changed files with 19 additions and 17 deletions
|
@ -17,6 +17,8 @@ import qualified Git
|
||||||
import qualified Types.Remote as Remote
|
import qualified Types.Remote as Remote
|
||||||
import Messages
|
import Messages
|
||||||
|
|
||||||
|
import Data.Maybe
|
||||||
|
|
||||||
-- From a sha pointing to the content of a file to the key
|
-- From a sha pointing to the content of a file to the key
|
||||||
-- to use to export it. When the file is annexed, it's the annexed key.
|
-- to use to export it. When the file is annexed, it's the annexed key.
|
||||||
-- When the file is stored in git, it's a special type of key to indicate
|
-- When the file is stored in git, it's a special type of key to indicate
|
||||||
|
@ -48,6 +50,10 @@ keyGitSha k
|
||||||
Just (Git.Ref (fromKey keyName k))
|
Just (Git.Ref (fromKey keyName k))
|
||||||
| otherwise = Nothing
|
| otherwise = Nothing
|
||||||
|
|
||||||
|
-- Is a key storing a git sha, and not used for an annexed file?
|
||||||
|
isGitShaKey :: Key -> Bool
|
||||||
|
isGitShaKey = isJust . keyGitSha
|
||||||
|
|
||||||
warnExportImportConflict :: Remote -> Annex ()
|
warnExportImportConflict :: Remote -> Annex ()
|
||||||
warnExportImportConflict r = do
|
warnExportImportConflict r = do
|
||||||
isimport <- Remote.isImportSupported r
|
isimport <- Remote.isImportSupported r
|
||||||
|
|
|
@ -180,11 +180,10 @@ recordImportTree remote importtreeconfig importable = do
|
||||||
let stillpresent db k = liftIO $ not . null
|
let stillpresent db k = liftIO $ not . null
|
||||||
<$> Export.getExportedLocation db k
|
<$> Export.getExportedLocation db k
|
||||||
let updater db moldkey _newkey _ = case moldkey of
|
let updater db moldkey _newkey _ = case moldkey of
|
||||||
Just oldkey -> case keyGitSha oldkey of
|
Just oldkey | not (isGitShaKey oldkey) ->
|
||||||
Nothing -> unlessM (stillpresent db oldkey) $
|
unlessM (stillpresent db oldkey) $
|
||||||
logChange oldkey (Remote.uuid remote) InfoMissing
|
logChange oldkey (Remote.uuid remote) InfoMissing
|
||||||
Just _ -> noop
|
_ -> noop
|
||||||
Nothing -> noop
|
|
||||||
db <- Export.openDb (Remote.uuid remote)
|
db <- Export.openDb (Remote.uuid remote)
|
||||||
forM_ (exportedTreeishes oldexport) $ \oldtree ->
|
forM_ (exportedTreeishes oldexport) $ \oldtree ->
|
||||||
Export.runExportDiffUpdater updater db oldtree finaltree
|
Export.runExportDiffUpdater updater db oldtree finaltree
|
||||||
|
|
|
@ -280,8 +280,8 @@ startExport r db cvar allfilledvar ti = do
|
||||||
performExport :: Remote -> ExportHandle -> Key -> AssociatedFile -> Sha -> ExportLocation -> MVar AllFilled -> CommandPerform
|
performExport :: Remote -> ExportHandle -> Key -> AssociatedFile -> Sha -> ExportLocation -> MVar AllFilled -> CommandPerform
|
||||||
performExport r db ek af contentsha loc allfilledvar = do
|
performExport r db ek af contentsha loc allfilledvar = do
|
||||||
let storer = storeExport (exportActions r)
|
let storer = storeExport (exportActions r)
|
||||||
sent <- tryNonAsync $ case keyGitSha ek of
|
sent <- tryNonAsync $ if not (isGitShaKey ek)
|
||||||
Nothing -> ifM (inAnnex ek)
|
then ifM (inAnnex ek)
|
||||||
( notifyTransfer Upload af $
|
( notifyTransfer Upload af $
|
||||||
-- alwaysUpload because the same key
|
-- alwaysUpload because the same key
|
||||||
-- could be used for more than one export
|
-- could be used for more than one export
|
||||||
|
@ -298,13 +298,12 @@ performExport r db ek af contentsha loc allfilledvar = do
|
||||||
return False
|
return False
|
||||||
)
|
)
|
||||||
-- Sending a non-annexed file.
|
-- Sending a non-annexed file.
|
||||||
Just _ ->
|
else withTmpFile "export" $ \tmp h -> do
|
||||||
withTmpFile "export" $ \tmp h -> do
|
b <- catObject contentsha
|
||||||
b <- catObject contentsha
|
liftIO $ L.hPut h b
|
||||||
liftIO $ L.hPut h b
|
liftIO $ hClose h
|
||||||
liftIO $ hClose h
|
Remote.action $
|
||||||
Remote.action $
|
storer tmp ek loc nullMeterUpdate
|
||||||
storer tmp ek loc nullMeterUpdate
|
|
||||||
let failedsend = liftIO $ modifyMVar_ allfilledvar (pure . const (AllFilled False))
|
let failedsend = liftIO $ modifyMVar_ allfilledvar (pure . const (AllFilled False))
|
||||||
case sent of
|
case sent of
|
||||||
Right True -> next $ cleanupExport r db ek loc True
|
Right True -> next $ cleanupExport r db ek loc True
|
||||||
|
@ -318,10 +317,8 @@ performExport r db ek af contentsha loc allfilledvar = do
|
||||||
cleanupExport :: Remote -> ExportHandle -> Key -> ExportLocation -> Bool -> CommandCleanup
|
cleanupExport :: Remote -> ExportHandle -> Key -> ExportLocation -> Bool -> CommandCleanup
|
||||||
cleanupExport r db ek loc sent = do
|
cleanupExport r db ek loc sent = do
|
||||||
liftIO $ addExportedLocation db ek loc
|
liftIO $ addExportedLocation db ek loc
|
||||||
when sent $
|
when (sent && not (isGitShaKey ek)) $
|
||||||
case keyGitSha ek of
|
logChange ek (uuid r) InfoPresent
|
||||||
Nothing -> logChange ek (uuid r) InfoPresent
|
|
||||||
Just _ -> noop
|
|
||||||
return True
|
return True
|
||||||
|
|
||||||
startUnexport :: Remote -> ExportHandle -> TopFilePath -> [Git.Sha] -> CommandStart
|
startUnexport :: Remote -> ExportHandle -> TopFilePath -> [Git.Sha] -> CommandStart
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue