diff options
author | Joey Hess <joey@kitenet.net> | 2011-07-01 18:46:07 -0400 |
---|---|---|
committer | Joey Hess <joey@kitenet.net> | 2011-07-01 18:59:40 -0400 |
commit | ace9de37e8db9c99db4b121392ca63091e48bfac (patch) | |
tree | b3f790ea9bd184094aaf1561cbc7309391f5d1ba /Command/AddUrl.hs | |
parent | 5d154b84365770ff27c09137ad039f930505ebfd (diff) |
download urls via tmp file, and support resuming
Diffstat (limited to 'Command/AddUrl.hs')
-rw-r--r-- | Command/AddUrl.hs | 16 |
1 files changed, 12 insertions, 4 deletions
diff --git a/Command/AddUrl.hs b/Command/AddUrl.hs index 713a486a5..ebf0810ba 100644 --- a/Command/AddUrl.hs +++ b/Command/AddUrl.hs @@ -16,9 +16,13 @@ import Command import qualified Backend import qualified Remote.Web import qualified Command.Add +import qualified Annex import Messages import Content import PresenceLog +import Types.Key +import Locations +import Utility command :: [Command] command = [repoCommand "addurl" paramPath seek "add urls to annex"] @@ -38,16 +42,20 @@ start s = do perform :: String -> FilePath -> CommandPerform perform url file = do - [(_, backend)] <- Backend.chooseBackends [file] + g <- Annex.gitRepo showNote $ "downloading " ++ url - ok <- Remote.Web.download file [url] + let dummykey = stubKey { keyName = url, keyBackendName = "URL" } + let tmp = gitAnnexTmpLocation g dummykey + liftIO $ createDirectoryIfMissing True (parentDir tmp) + ok <- Remote.Web.download [url] tmp if ok then do - stored <- Backend.storeFileKey file backend + [(_, backend)] <- Backend.chooseBackends [file] + stored <- Backend.storeFileKey tmp backend case stored of Nothing -> stop Just (key, _) -> do - moveAnnex key file + moveAnnex key tmp Remote.Web.setUrl key url InfoPresent next $ Command.Add.cleanup file key else stop |