diff --git a/Assistant/WebApp/Configurators/Local.hs b/Assistant/WebApp/Configurators/Local.hs index 2cfc7dbd63..d689261087 100644 --- a/Assistant/WebApp/Configurators/Local.hs +++ b/Assistant/WebApp/Configurators/Local.hs @@ -11,6 +11,7 @@ module Assistant.WebApp.Configurators.Local where import Assistant.WebApp.Common import Assistant.WebApp.Utility +import Assistant.WebApp.OtherRepos import Assistant.MakeRemote import Init import qualified Git @@ -135,20 +136,35 @@ getFirstRepositoryR = page "Getting started" (Just Configuration) $ do startFullAssistant $ T.unpack p _ -> $(widgetFile "configurators/newrepository/first") -{- Adding a new, separate repository. -} +{- Adding a new local repository, which may be entirely separate, or may + - be connected to the current repository. -} getNewRepositoryR :: Handler RepHtml getNewRepositoryR = page "Add another repository" (Just Configuration) $ do home <- liftIO myHomeDir ((res, form), enctype) <- lift $ runFormGet $ newRepositoryForm home case res of - FormSuccess (RepositoryPath p) -> lift $ do + FormSuccess (RepositoryPath p) -> do let path = T.unpack p liftIO $ makeRepo path False u <- liftIO $ initRepo True path Nothing - runAnnex () $ setStandardGroup u ClientGroup + lift $ runAnnex () $ setStandardGroup u ClientGroup liftIO $ addAutoStart path - redirect $ SwitchToRepositoryR path + liftIO $ startAssistant path + askcombine u path _ -> $(widgetFile "configurators/newrepository") + where + askcombine newrepouuid newrepopath = do + newrepo <- liftIO $ relHome newrepopath + mainrepo <- fromJust . relDir <$> lift getYesod + $(widgetFile "configurators/newrepository/combine") + +getCombineRepositoryR :: FilePath -> UUID -> Handler RepHtml +getCombineRepositoryR newrepopath newrepouuid = do + r <- combineRepos newrepopath remotename + syncRemote r + redirect $ EditRepositoryR newrepouuid + where + remotename = takeFileName newrepopath data RemovableDrive = RemovableDrive { diskFree :: Maybe Integer @@ -188,7 +204,7 @@ getAddDriveR = page "Add a removable drive" (Just Configuration) $ do make mountpoint = do liftIO $ makerepo dir u <- liftIO $ initRepo False dir $ Just remotename - r <- addremote dir remotename + r <- combineRepos dir remotename runAnnex () $ setStandardGroup u TransferGroup syncRemote r return u @@ -204,12 +220,15 @@ getAddDriveR = page "Add a removable drive" (Just Configuration) $ do _ -> do createDirectoryIfMissing True dir makeRepo dir True - {- Each repository is made a remote of the other. -} - addremote dir name = runAnnex undefined $ do - hostname <- maybe "host" id <$> liftIO getHostname - hostlocation <- fromRepo Git.repoLocation - liftIO $ inDir dir $ void $ makeGitRemote hostname hostlocation - addRemote $ makeGitRemote name dir + +{- Each repository is made a remote of the other. + - Next call syncRemote to get them in sync. -} +combineRepos :: FilePath -> String -> Handler Remote +combineRepos dir name = runAnnex undefined $ do + hostname <- maybe "host" id <$> liftIO getHostname + hostlocation <- fromRepo Git.repoLocation + liftIO $ inDir dir $ void $ makeGitRemote hostname hostlocation + addRemote $ makeGitRemote name dir getEnableDirectoryR :: UUID -> Handler RepHtml getEnableDirectoryR uuid = page "Enable a repository" (Just Configuration) $ do diff --git a/Assistant/WebApp/OtherRepos.hs b/Assistant/WebApp/OtherRepos.hs index 06f9eef0ac..b89022c5c8 100644 --- a/Assistant/WebApp/OtherRepos.hs +++ b/Assistant/WebApp/OtherRepos.hs @@ -43,14 +43,9 @@ listOtherRepos = do -} getSwitchToRepositoryR :: FilePath -> Handler RepHtml getSwitchToRepositoryR repo = do - liftIO startassistant - url <- liftIO geturl - redirect url + liftIO $ startAssistant repo + redirect =<< liftIO geturl where - startassistant = do - program <- readProgramFile - void $ forkIO $ void $ createProcess $ - (proc program ["assistant"]) { cwd = Just repo } geturl = do r <- Git.Config.read =<< Git.Construct.fromPath repo waiturl $ gitAnnexUrlFile r @@ -66,3 +61,9 @@ getSwitchToRepositoryR repo = do delayed a = do threadDelay 100000 -- 1/10th of a second a + +startAssistant :: FilePath -> IO () +startAssistant repo = do + program <- readProgramFile + void $ forkIO $ void $ createProcess $ + (proc program ["assistant"]) { cwd = Just repo } diff --git a/Assistant/WebApp/routes b/Assistant/WebApp/routes index 1ffdac1c5f..a99237c898 100644 --- a/Assistant/WebApp/routes +++ b/Assistant/WebApp/routes @@ -20,6 +20,7 @@ /config/repository/new NewRepositoryR GET /config/repository/switcher RepositorySwitcherR GET /config/repository/switchto/#FilePath SwitchToRepositoryR GET +/config/repository/combine/#FilePath/#UUID CombineRepositoryR GET /config/repository/edit/#UUID EditRepositoryR GET /config/repository/edit/new/#UUID EditNewRepositoryR GET /config/repository/edit/new/cloud/#UUID EditNewCloudRepositoryR GET diff --git a/debian/changelog b/debian/changelog index d6b606447f..584a033125 100644 --- a/debian/changelog +++ b/debian/changelog @@ -4,6 +4,8 @@ git-annex (3.20130217) UNRELEASED; urgency=low always using git's pseudosymlink files in such repositories. * webapp: Allow creating repositories on filesystems that lack support for symlinks. + * webapp: Can now add a new local repository, and make it sync with + the main local repository. * Android: Bundle now includes openssh. -- Joey Hess Sun, 17 Feb 2013 16:42:16 -0400 diff --git a/doc/assistant/combinerepos.png b/doc/assistant/combinerepos.png new file mode 100644 index 0000000000..7beea71bc5 Binary files /dev/null and b/doc/assistant/combinerepos.png differ diff --git a/templates/configurators/newrepository.hamlet b/templates/configurators/newrepository.hamlet index d2bdad9b9f..8e38ff68ff 100644 --- a/templates/configurators/newrepository.hamlet +++ b/templates/configurators/newrepository.hamlet @@ -1,15 +1,7 @@

- Add another repository -

- The form below will make a separate repository, that is not synced # - with your existing repository. You can use the new repository for # - different sorts of files, that are synced and shared with other # - devices and users. + Add another local repository

+ Where do you want to put this new repository?

^{form} -

- # - Do you want to add another repository that is kept in sync with # - the current one? If so, go here. diff --git a/templates/configurators/newrepository/combine.hamlet b/templates/configurators/newrepository/combine.hamlet index 3ea8034822..7cdec85080 100644 --- a/templates/configurators/newrepository/combine.hamlet +++ b/templates/configurators/newrepository/combine.hamlet @@ -2,16 +2,16 @@

Combine repositories?

- You have created a new repository at #{newrepopath}. # - Do you want to combine it with your existing repository at #{mainrepopath}? + You have created a new repository at #{newrepo}. +
+ Do you want to combine it with your existing repository at #{mainrepo}?

- Combining the repositories will sync their files, so each will have # - added to it all files from the other repository. + + Combine the repositories # + The combined repositories will sync and share their files.

- If you want to use the new repository to hold different sorts of files, # - you should not combine the repositories. + -or-

- - Combine the repositories - Keep the repositories separate + Keep the repositories separate # + Files placed in one will not be synced to the other. diff --git a/templates/configurators/repositories/misc.hamlet b/templates/configurators/repositories/misc.hamlet index 5975118375..7ceae2c92f 100644 --- a/templates/configurators/repositories/misc.hamlet +++ b/templates/configurators/repositories/misc.hamlet @@ -15,9 +15,7 @@

Pair with a computer to automatically keep files in sync # over your local network. -

- For easy sharing with friends and devices in the same location.

@@ -31,6 +29,12 @@ For easy sharing with friends and devices, over the internet. +

+ + Add a local repository +

+ Make another repository on your computer. +

Phone