webapp: Can now add a new local repository, and make it sync with the main local repository.
This commit is contained in:
parent
9b91ea425c
commit
e598b78a69
8 changed files with 58 additions and 39 deletions
|
@ -11,6 +11,7 @@ module Assistant.WebApp.Configurators.Local where
|
||||||
|
|
||||||
import Assistant.WebApp.Common
|
import Assistant.WebApp.Common
|
||||||
import Assistant.WebApp.Utility
|
import Assistant.WebApp.Utility
|
||||||
|
import Assistant.WebApp.OtherRepos
|
||||||
import Assistant.MakeRemote
|
import Assistant.MakeRemote
|
||||||
import Init
|
import Init
|
||||||
import qualified Git
|
import qualified Git
|
||||||
|
@ -135,20 +136,35 @@ getFirstRepositoryR = page "Getting started" (Just Configuration) $ do
|
||||||
startFullAssistant $ T.unpack p
|
startFullAssistant $ T.unpack p
|
||||||
_ -> $(widgetFile "configurators/newrepository/first")
|
_ -> $(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 :: Handler RepHtml
|
||||||
getNewRepositoryR = page "Add another repository" (Just Configuration) $ do
|
getNewRepositoryR = page "Add another repository" (Just Configuration) $ do
|
||||||
home <- liftIO myHomeDir
|
home <- liftIO myHomeDir
|
||||||
((res, form), enctype) <- lift $ runFormGet $ newRepositoryForm home
|
((res, form), enctype) <- lift $ runFormGet $ newRepositoryForm home
|
||||||
case res of
|
case res of
|
||||||
FormSuccess (RepositoryPath p) -> lift $ do
|
FormSuccess (RepositoryPath p) -> do
|
||||||
let path = T.unpack p
|
let path = T.unpack p
|
||||||
liftIO $ makeRepo path False
|
liftIO $ makeRepo path False
|
||||||
u <- liftIO $ initRepo True path Nothing
|
u <- liftIO $ initRepo True path Nothing
|
||||||
runAnnex () $ setStandardGroup u ClientGroup
|
lift $ runAnnex () $ setStandardGroup u ClientGroup
|
||||||
liftIO $ addAutoStart path
|
liftIO $ addAutoStart path
|
||||||
redirect $ SwitchToRepositoryR path
|
liftIO $ startAssistant path
|
||||||
|
askcombine u path
|
||||||
_ -> $(widgetFile "configurators/newrepository")
|
_ -> $(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
|
data RemovableDrive = RemovableDrive
|
||||||
{ diskFree :: Maybe Integer
|
{ diskFree :: Maybe Integer
|
||||||
|
@ -188,7 +204,7 @@ getAddDriveR = page "Add a removable drive" (Just Configuration) $ do
|
||||||
make mountpoint = do
|
make mountpoint = do
|
||||||
liftIO $ makerepo dir
|
liftIO $ makerepo dir
|
||||||
u <- liftIO $ initRepo False dir $ Just remotename
|
u <- liftIO $ initRepo False dir $ Just remotename
|
||||||
r <- addremote dir remotename
|
r <- combineRepos dir remotename
|
||||||
runAnnex () $ setStandardGroup u TransferGroup
|
runAnnex () $ setStandardGroup u TransferGroup
|
||||||
syncRemote r
|
syncRemote r
|
||||||
return u
|
return u
|
||||||
|
@ -204,8 +220,11 @@ getAddDriveR = page "Add a removable drive" (Just Configuration) $ do
|
||||||
_ -> do
|
_ -> do
|
||||||
createDirectoryIfMissing True dir
|
createDirectoryIfMissing True dir
|
||||||
makeRepo dir True
|
makeRepo dir True
|
||||||
{- Each repository is made a remote of the other. -}
|
|
||||||
addremote dir name = runAnnex undefined $ do
|
{- 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
|
hostname <- maybe "host" id <$> liftIO getHostname
|
||||||
hostlocation <- fromRepo Git.repoLocation
|
hostlocation <- fromRepo Git.repoLocation
|
||||||
liftIO $ inDir dir $ void $ makeGitRemote hostname hostlocation
|
liftIO $ inDir dir $ void $ makeGitRemote hostname hostlocation
|
||||||
|
|
|
@ -43,14 +43,9 @@ listOtherRepos = do
|
||||||
-}
|
-}
|
||||||
getSwitchToRepositoryR :: FilePath -> Handler RepHtml
|
getSwitchToRepositoryR :: FilePath -> Handler RepHtml
|
||||||
getSwitchToRepositoryR repo = do
|
getSwitchToRepositoryR repo = do
|
||||||
liftIO startassistant
|
liftIO $ startAssistant repo
|
||||||
url <- liftIO geturl
|
redirect =<< liftIO geturl
|
||||||
redirect url
|
|
||||||
where
|
where
|
||||||
startassistant = do
|
|
||||||
program <- readProgramFile
|
|
||||||
void $ forkIO $ void $ createProcess $
|
|
||||||
(proc program ["assistant"]) { cwd = Just repo }
|
|
||||||
geturl = do
|
geturl = do
|
||||||
r <- Git.Config.read =<< Git.Construct.fromPath repo
|
r <- Git.Config.read =<< Git.Construct.fromPath repo
|
||||||
waiturl $ gitAnnexUrlFile r
|
waiturl $ gitAnnexUrlFile r
|
||||||
|
@ -66,3 +61,9 @@ getSwitchToRepositoryR repo = do
|
||||||
delayed a = do
|
delayed a = do
|
||||||
threadDelay 100000 -- 1/10th of a second
|
threadDelay 100000 -- 1/10th of a second
|
||||||
a
|
a
|
||||||
|
|
||||||
|
startAssistant :: FilePath -> IO ()
|
||||||
|
startAssistant repo = do
|
||||||
|
program <- readProgramFile
|
||||||
|
void $ forkIO $ void $ createProcess $
|
||||||
|
(proc program ["assistant"]) { cwd = Just repo }
|
||||||
|
|
|
@ -20,6 +20,7 @@
|
||||||
/config/repository/new NewRepositoryR GET
|
/config/repository/new NewRepositoryR GET
|
||||||
/config/repository/switcher RepositorySwitcherR GET
|
/config/repository/switcher RepositorySwitcherR GET
|
||||||
/config/repository/switchto/#FilePath SwitchToRepositoryR GET
|
/config/repository/switchto/#FilePath SwitchToRepositoryR GET
|
||||||
|
/config/repository/combine/#FilePath/#UUID CombineRepositoryR GET
|
||||||
/config/repository/edit/#UUID EditRepositoryR GET
|
/config/repository/edit/#UUID EditRepositoryR GET
|
||||||
/config/repository/edit/new/#UUID EditNewRepositoryR GET
|
/config/repository/edit/new/#UUID EditNewRepositoryR GET
|
||||||
/config/repository/edit/new/cloud/#UUID EditNewCloudRepositoryR GET
|
/config/repository/edit/new/cloud/#UUID EditNewCloudRepositoryR GET
|
||||||
|
|
2
debian/changelog
vendored
2
debian/changelog
vendored
|
@ -4,6 +4,8 @@ git-annex (3.20130217) UNRELEASED; urgency=low
|
||||||
always using git's pseudosymlink files in such repositories.
|
always using git's pseudosymlink files in such repositories.
|
||||||
* webapp: Allow creating repositories on filesystems that lack support for
|
* webapp: Allow creating repositories on filesystems that lack support for
|
||||||
symlinks.
|
symlinks.
|
||||||
|
* webapp: Can now add a new local repository, and make it sync with
|
||||||
|
the main local repository.
|
||||||
* Android: Bundle now includes openssh.
|
* Android: Bundle now includes openssh.
|
||||||
|
|
||||||
-- Joey Hess <joeyh@debian.org> Sun, 17 Feb 2013 16:42:16 -0400
|
-- Joey Hess <joeyh@debian.org> Sun, 17 Feb 2013 16:42:16 -0400
|
||||||
|
|
BIN
doc/assistant/combinerepos.png
Normal file
BIN
doc/assistant/combinerepos.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 10 KiB |
|
@ -1,15 +1,7 @@
|
||||||
<div .span9 .hero-unit>
|
<div .span9 .hero-unit>
|
||||||
<h2>
|
<h2>
|
||||||
Add another repository
|
Add another local repository
|
||||||
<p>
|
|
||||||
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.
|
|
||||||
<p>
|
<p>
|
||||||
|
Where do you want to put this new repository?
|
||||||
<form .form-inline enctype=#{enctype}>
|
<form .form-inline enctype=#{enctype}>
|
||||||
^{form}
|
^{form}
|
||||||
<p>
|
|
||||||
<i .icon-asterisk></i> #
|
|
||||||
Do you want to add another repository that is kept in sync with #
|
|
||||||
the current one? If so, <a href="@{RepositoriesR}">go here</a>.
|
|
||||||
|
|
|
@ -2,16 +2,16 @@
|
||||||
<h2>
|
<h2>
|
||||||
Combine repositories?
|
Combine repositories?
|
||||||
<p>
|
<p>
|
||||||
You have created a new repository at #{newrepopath}. #
|
You have created a new repository at #{newrepo}.
|
||||||
Do you want to combine it with your existing repository at #{mainrepopath}?
|
<br>
|
||||||
|
Do you want to combine it with your existing repository at #{mainrepo}?
|
||||||
<p>
|
<p>
|
||||||
Combining the repositories will sync their files, so each will have #
|
<a .btn href="@{CombineRepositoryR newrepopath newrepouuid}">
|
||||||
added to it all files from the other repository.
|
<i .icon-resize-small></i> Combine the repositories #
|
||||||
|
The combined repositories will sync and share their files.
|
||||||
<p>
|
<p>
|
||||||
If you want to use the new repository to hold different sorts of files, #
|
-or-
|
||||||
you should not combine the repositories.
|
|
||||||
<p>
|
<p>
|
||||||
<a .btn .btn-primary href="@{CombineRepository newrepopath}">
|
|
||||||
<i .icon-resize-small></i> Combine the repositories
|
|
||||||
<a .btn href="@{SwitchToRepositoryR newrepopath}">
|
<a .btn href="@{SwitchToRepositoryR newrepopath}">
|
||||||
<i .icon-resize-full></i> Keep the repositories separate
|
<i .icon-resize-full></i> Keep the repositories separate #
|
||||||
|
Files placed in one will not be synced to the other.
|
||||||
|
|
|
@ -15,9 +15,7 @@
|
||||||
<p>
|
<p>
|
||||||
Pair with a computer to automatically keep files in sync #
|
Pair with a computer to automatically keep files in sync #
|
||||||
over your local network.
|
over your local network.
|
||||||
|
|
||||||
<p>
|
<p>
|
||||||
|
|
||||||
For easy sharing with friends and devices in the same location.
|
For easy sharing with friends and devices in the same location.
|
||||||
|
|
||||||
<h3>
|
<h3>
|
||||||
|
@ -31,6 +29,12 @@
|
||||||
|
|
||||||
For easy sharing with friends and devices, over the internet.
|
For easy sharing with friends and devices, over the internet.
|
||||||
|
|
||||||
|
<h3>
|
||||||
|
<a href="@{NewRepositoryR}">
|
||||||
|
<i .icon-plus-sign></i> Add a local repository
|
||||||
|
<p>
|
||||||
|
Make another repository on your computer.
|
||||||
|
|
||||||
<h3>
|
<h3>
|
||||||
<i .icon-plus-sign></i> Phone
|
<i .icon-plus-sign></i> Phone
|
||||||
<p>
|
<p>
|
||||||
|
|
Loading…
Reference in a new issue