migrate: Copy url logs for keys when migrating.
This commit is contained in:
parent
b4015064e1
commit
ec169f84b1
5 changed files with 19 additions and 8 deletions
|
@ -13,12 +13,11 @@ import Common.Annex
|
||||||
import Command
|
import Command
|
||||||
import qualified Backend
|
import qualified Backend
|
||||||
import qualified Utility.Url as Url
|
import qualified Utility.Url as Url
|
||||||
import qualified Remote.Web
|
|
||||||
import qualified Command.Add
|
import qualified Command.Add
|
||||||
import qualified Annex
|
import qualified Annex
|
||||||
import qualified Backend.URL
|
import qualified Backend.URL
|
||||||
import Annex.Content
|
import Annex.Content
|
||||||
import Logs.Presence
|
import Logs.Web
|
||||||
|
|
||||||
command :: [Command]
|
command :: [Command]
|
||||||
command = [repoCommand "addurl" (paramRepeating paramUrl) seek
|
command = [repoCommand "addurl" (paramRepeating paramUrl) seek
|
||||||
|
@ -58,14 +57,14 @@ download url file = do
|
||||||
Nothing -> stop
|
Nothing -> stop
|
||||||
Just (key, _) -> do
|
Just (key, _) -> do
|
||||||
moveAnnex key tmp
|
moveAnnex key tmp
|
||||||
Remote.Web.setUrl key url InfoPresent
|
setUrlPresent key url
|
||||||
next $ Command.Add.cleanup file key True
|
next $ Command.Add.cleanup file key True
|
||||||
else stop
|
else stop
|
||||||
|
|
||||||
nodownload :: String -> FilePath -> CommandPerform
|
nodownload :: String -> FilePath -> CommandPerform
|
||||||
nodownload url file = do
|
nodownload url file = do
|
||||||
let key = Backend.URL.fromUrl url
|
let key = Backend.URL.fromUrl url
|
||||||
Remote.Web.setUrl key url InfoPresent
|
setUrlPresent key url
|
||||||
|
|
||||||
next $ Command.Add.cleanup file key False
|
next $ Command.Add.cleanup file key False
|
||||||
|
|
||||||
|
|
|
@ -14,6 +14,7 @@ import qualified Types.Key
|
||||||
import Annex.Content
|
import Annex.Content
|
||||||
import qualified Command.Add
|
import qualified Command.Add
|
||||||
import Backend
|
import Backend
|
||||||
|
import Logs.Web
|
||||||
|
|
||||||
command :: [Command]
|
command :: [Command]
|
||||||
command = [repoCommand "migrate" paramPaths seek
|
command = [repoCommand "migrate" paramPaths seek
|
||||||
|
@ -65,6 +66,14 @@ perform file oldkey newbackend = do
|
||||||
then do
|
then do
|
||||||
-- Update symlink to use the new key.
|
-- Update symlink to use the new key.
|
||||||
liftIO $ removeFile file
|
liftIO $ removeFile file
|
||||||
|
|
||||||
|
-- If the old key had some
|
||||||
|
-- associated urls, record them for
|
||||||
|
-- the new key as well.
|
||||||
|
urls <- getUrls oldkey
|
||||||
|
when (not $ null urls) $
|
||||||
|
mapM_ (setUrlPresent newkey) urls
|
||||||
|
|
||||||
next $ Command.Add.cleanup file newkey True
|
next $ Command.Add.cleanup file newkey True
|
||||||
else stop
|
else stop
|
||||||
where
|
where
|
||||||
|
|
|
@ -9,6 +9,7 @@ module Logs.Web (
|
||||||
URLString,
|
URLString,
|
||||||
webUUID,
|
webUUID,
|
||||||
setUrl,
|
setUrl,
|
||||||
|
setUrlPresent,
|
||||||
getUrls
|
getUrls
|
||||||
) where
|
) where
|
||||||
|
|
||||||
|
@ -31,6 +32,7 @@ oldurlLog :: Key -> FilePath
|
||||||
{- A bug used to store the urls elsewhere. -}
|
{- A bug used to store the urls elsewhere. -}
|
||||||
oldurlLog key = "remote/web" </> hashDirLower key </> show key ++ ".log"
|
oldurlLog key = "remote/web" </> hashDirLower key </> show key ++ ".log"
|
||||||
|
|
||||||
|
{- Gets all urls that a key might be available from. -}
|
||||||
getUrls :: Key -> Annex [URLString]
|
getUrls :: Key -> Annex [URLString]
|
||||||
getUrls key = do
|
getUrls key = do
|
||||||
us <- currentLog (urlLog key)
|
us <- currentLog (urlLog key)
|
||||||
|
@ -47,3 +49,6 @@ setUrl key url status = do
|
||||||
-- update location log to indicate that the web has the key, or not
|
-- update location log to indicate that the web has the key, or not
|
||||||
us <- getUrls key
|
us <- getUrls key
|
||||||
logChange g key webUUID (if null us then InfoMissing else InfoPresent)
|
logChange g key webUUID (if null us then InfoMissing else InfoPresent)
|
||||||
|
|
||||||
|
setUrlPresent :: Key -> URLString -> Annex ()
|
||||||
|
setUrlPresent key url = setUrl key url InfoPresent
|
||||||
|
|
|
@ -5,10 +5,7 @@
|
||||||
- Licensed under the GNU GPL version 3 or higher.
|
- Licensed under the GNU GPL version 3 or higher.
|
||||||
-}
|
-}
|
||||||
|
|
||||||
module Remote.Web (
|
module Remote.Web (remote) where
|
||||||
remote,
|
|
||||||
setUrl
|
|
||||||
) where
|
|
||||||
|
|
||||||
import Common.Annex
|
import Common.Annex
|
||||||
import Types.Remote
|
import Types.Remote
|
||||||
|
|
1
debian/changelog
vendored
1
debian/changelog
vendored
|
@ -2,6 +2,7 @@ git-annex (3.20111012) UNRELEASED; urgency=low
|
||||||
|
|
||||||
* A remote can have a annexUrl configured, that is used by git-annex
|
* A remote can have a annexUrl configured, that is used by git-annex
|
||||||
instead of its usual url. (Similar to pushUrl.)
|
instead of its usual url. (Similar to pushUrl.)
|
||||||
|
* migrate: Copy url logs for keys when migrating.
|
||||||
|
|
||||||
-- Joey Hess <joeyh@debian.org> Fri, 14 Oct 2011 18:15:20 -0400
|
-- Joey Hess <joeyh@debian.org> Fri, 14 Oct 2011 18:15:20 -0400
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue