direct, indirect: Refuse to do anything when the assistant or git-annex watch daemon is running.
This commit is contained in:
parent
777349f0d3
commit
dc39da52f8
5 changed files with 21 additions and 6 deletions
13
Checks.hs
13
Checks.hs
|
@ -3,7 +3,7 @@
|
||||||
- Common sanity checks for commands, and an interface to selectively
|
- Common sanity checks for commands, and an interface to selectively
|
||||||
- remove them, or add others.
|
- remove them, or add others.
|
||||||
-
|
-
|
||||||
- Copyright 2011 Joey Hess <joey@kitenet.net>
|
- Copyright 2011-2013 Joey Hess <joey@kitenet.net>
|
||||||
-
|
-
|
||||||
- Licensed under the GNU GPL version 3 or higher.
|
- Licensed under the GNU GPL version 3 or higher.
|
||||||
-}
|
-}
|
||||||
|
@ -14,6 +14,7 @@ import Common.Annex
|
||||||
import Types.Command
|
import Types.Command
|
||||||
import Init
|
import Init
|
||||||
import Config
|
import Config
|
||||||
|
import Utility.Daemon
|
||||||
import qualified Git
|
import qualified Git
|
||||||
|
|
||||||
commonChecks :: [CommandCheck]
|
commonChecks :: [CommandCheck]
|
||||||
|
@ -24,11 +25,17 @@ repoExists = CommandCheck 0 ensureInitialized
|
||||||
|
|
||||||
notDirect :: Command -> Command
|
notDirect :: Command -> Command
|
||||||
notDirect = addCheck $ whenM isDirect $
|
notDirect = addCheck $ whenM isDirect $
|
||||||
error "You cannot run this subcommand in a direct mode repository."
|
error "You cannot run this command in a direct mode repository."
|
||||||
|
|
||||||
notBareRepo :: Command -> Command
|
notBareRepo :: Command -> Command
|
||||||
notBareRepo = addCheck $ whenM (fromRepo Git.repoIsLocalBare) $
|
notBareRepo = addCheck $ whenM (fromRepo Git.repoIsLocalBare) $
|
||||||
error "You cannot run this subcommand in a bare repository."
|
error "You cannot run this command in a bare repository."
|
||||||
|
|
||||||
|
noDaemonRunning :: Command -> Command
|
||||||
|
noDaemonRunning = addCheck $ whenM (isJust <$> daemonpid) $
|
||||||
|
error "You cannot run this command while git-annex watch or git-annex assistant is running."
|
||||||
|
where
|
||||||
|
daemonpid = liftIO . checkDaemon =<< fromRepo gitAnnexPidFile
|
||||||
|
|
||||||
dontCheck :: CommandCheck -> Command -> Command
|
dontCheck :: CommandCheck -> Command -> Command
|
||||||
dontCheck check cmd = mutateCheck cmd $ \c -> filter (/= check) c
|
dontCheck check cmd = mutateCheck cmd $ \c -> filter (/= check) c
|
||||||
|
|
|
@ -17,7 +17,7 @@ import Annex.Direct
|
||||||
import Annex.Version
|
import Annex.Version
|
||||||
|
|
||||||
def :: [Command]
|
def :: [Command]
|
||||||
def = [notBareRepo $
|
def = [notBareRepo $ noDaemonRunning $
|
||||||
command "direct" paramNothing seek
|
command "direct" paramNothing seek
|
||||||
SectionSetup "switch repository to direct mode"]
|
SectionSetup "switch repository to direct mode"]
|
||||||
|
|
||||||
|
|
|
@ -21,8 +21,9 @@ import Annex.Version
|
||||||
import Init
|
import Init
|
||||||
|
|
||||||
def :: [Command]
|
def :: [Command]
|
||||||
def = [notBareRepo $ command "indirect" paramNothing seek
|
def = [notBareRepo $ noDaemonRunning $
|
||||||
SectionSetup "switch repository to indirect mode"]
|
command "indirect" paramNothing seek
|
||||||
|
SectionSetup "switch repository to indirect mode"]
|
||||||
|
|
||||||
seek :: [CommandSeek]
|
seek :: [CommandSeek]
|
||||||
seek = [withNothing start]
|
seek = [withNothing start]
|
||||||
|
|
2
debian/changelog
vendored
2
debian/changelog
vendored
|
@ -16,6 +16,8 @@ git-annex (4.20130418) UNRELEASED; urgency=low
|
||||||
* webapp: When told to add a git repository on a remote server, and
|
* webapp: When told to add a git repository on a remote server, and
|
||||||
the repository already exists as a non-bare repository, use it,
|
the repository already exists as a non-bare repository, use it,
|
||||||
rather than initializing a bare repository in the same directory.
|
rather than initializing a bare repository in the same directory.
|
||||||
|
* direct, indirect: Refuse to do anything when the assistant
|
||||||
|
or git-annex watch daemon is running.
|
||||||
|
|
||||||
-- Joey Hess <joeyh@debian.org> Thu, 18 Apr 2013 16:22:48 -0400
|
-- Joey Hess <joeyh@debian.org> Thu, 18 Apr 2013 16:22:48 -0400
|
||||||
|
|
||||||
|
|
|
@ -50,3 +50,8 @@ that all three copies are stored in ~/Indirect, so the functionality I'm after s
|
||||||
|
|
||||||
**Edit: Doing a git annex sync in ~/Indirect results in the continuing behaviour to be correct, so there's some issue telling Direct that Indirect is no longer in direct-mode?**
|
**Edit: Doing a git annex sync in ~/Indirect results in the continuing behaviour to be correct, so there's some issue telling Direct that Indirect is no longer in direct-mode?**
|
||||||
This appears to fix it, but I guess shouldn't be necessary.
|
This appears to fix it, but I guess shouldn't be necessary.
|
||||||
|
|
||||||
|
> AFAICS, the entire problem is that the assistant does not notice when the
|
||||||
|
> repository it's running in is changed from direct to indirect mode. Since this
|
||||||
|
> has also been reported to cause problems with the assistant, I have added
|
||||||
|
> a check to prevent it from being done. [[done]] --[[Joey]]
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue