better limiting of start actions to only run whenAnnexed

Mostly only refactoring, but this does remove one redundant stat of the
symlink by copy.
This commit is contained in:
Joey Hess 2011-11-10 23:35:08 -04:00
parent 4389782628
commit b327227ba5
16 changed files with 67 additions and 63 deletions

View file

@ -13,17 +13,16 @@ import qualified Backend
import qualified Types.Key
import Annex.Content
import qualified Command.Add
import Backend
import Logs.Web
def :: [Command]
def = [command "migrate" paramPaths seek "switch data to different backend"]
seek :: [CommandSeek]
seek = [withBackendFilesInGit start]
seek = [withBackendFilesInGit $ \(b, f) -> whenAnnexed (start b) f]
start :: BackendFile -> CommandStart
start (b, file) = isAnnexed file $ \(key, oldbackend) -> do
start :: Maybe (Backend Annex) -> FilePath -> (Key, Backend Annex) -> CommandStart
start b file (key, oldbackend) = do
exists <- inAnnex key
newbackend <- choosebackend b
if (newbackend /= oldbackend || upgradableKey key) && exists