mirror of
https://github.com/samschott/maestral.git
synced 2024-10-06 02:18:08 +03:00
[cli] added config-file --clean option
This commit is contained in:
parent
5e8642f615
commit
b7b379f1d3
@ -25,9 +25,10 @@
|
||||
the equivalent command from the Settings group (e.g., `maestral move-dir`).
|
||||
* Added the ability to turn off one sync direction, for instance to enable download
|
||||
syncs only. This can be useful when you want to mirror a remote folder while ignoring
|
||||
local changes. Note that conflict resolution remain unaffected. For instance, when
|
||||
an unsynced local change would be overwritten by a remote change, the local file will
|
||||
be moved to a "conflicting copy" first.
|
||||
local changes. To use this, set the respective config values for `upload` or
|
||||
`download` to False. Note that conflict resolution remain unaffected. For instance,
|
||||
when an unsynced local change would be overwritten by a remote change, the local file
|
||||
will be moved to a "conflicting copy" first.
|
||||
|
||||
#### Changed:
|
||||
|
||||
@ -50,6 +51,8 @@
|
||||
* Renamed command `file-status` to `filestatus`.
|
||||
* Added a `--yes, -Y` flag to the `unlink` to command to skip the confirmation prompt.
|
||||
* Renamed the `configs` command to list config files to `config-files`.
|
||||
* Added an option `--clean` to `config-files` to remove all stale config files without
|
||||
a linked Dropbox account.
|
||||
* Improved error message when the user is running out of inotify watches: Recommend
|
||||
default values of `max_user_watches = 524,288` and `max_user_instances = 1024` or
|
||||
double the current values, whichever is higher. Advise to apply the changes with
|
||||
|
@ -1177,7 +1177,13 @@ def ls(long: bool, dropbox_path: str, include_deleted: bool, config_name: str) -
|
||||
|
||||
|
||||
@main.command(section="Information", help="List all configured Dropbox accounts.")
|
||||
def config_files() -> None:
|
||||
@click.option(
|
||||
"--clean",
|
||||
is_flag=True,
|
||||
default=False,
|
||||
help="Remove config files without a linked account.",
|
||||
)
|
||||
def config_files(clean: bool) -> None:
|
||||
|
||||
from .daemon import is_running
|
||||
from .config import (
|
||||
@ -1187,36 +1193,43 @@ def config_files() -> None:
|
||||
remove_configuration,
|
||||
)
|
||||
|
||||
# clean up stale configs
|
||||
if clean:
|
||||
|
||||
for name in list_configs():
|
||||
dbid = MaestralConfig(name).get("account", "account_id")
|
||||
if dbid == "" and not is_running(name):
|
||||
remove_configuration(name)
|
||||
# Clean up stale config files.
|
||||
|
||||
# display remaining configs
|
||||
names = list_configs()
|
||||
emails = []
|
||||
paths = []
|
||||
for name in list_configs():
|
||||
conf = MaestralConfig(name)
|
||||
path = conf.get_config_fpath()
|
||||
dbid = conf.get("account", "account_id")
|
||||
|
||||
for name in names:
|
||||
config = MaestralConfig(name)
|
||||
state = MaestralState(name)
|
||||
if dbid == "" and not is_running(name):
|
||||
remove_configuration(name)
|
||||
cli.echo(f"Removed: {path}")
|
||||
|
||||
emails.append(state.get("account", "email"))
|
||||
paths.append(config.get_config_fpath())
|
||||
else:
|
||||
# Display config files.
|
||||
names = list_configs()
|
||||
emails = []
|
||||
paths = []
|
||||
|
||||
table = cli.Table(
|
||||
[
|
||||
cli.Column("Config name", names),
|
||||
cli.Column("Account", emails),
|
||||
cli.Column("Path", paths, elide=cli.Elide.Leading),
|
||||
]
|
||||
)
|
||||
for name in names:
|
||||
config = MaestralConfig(name)
|
||||
state = MaestralState(name)
|
||||
|
||||
cli.echo("")
|
||||
table.echo()
|
||||
cli.echo("")
|
||||
emails.append(state.get("account", "email"))
|
||||
paths.append(config.get_config_fpath())
|
||||
|
||||
table = cli.Table(
|
||||
[
|
||||
cli.Column("Config name", names),
|
||||
cli.Column("Account", emails),
|
||||
cli.Column("Path", paths, elide=cli.Elide.Leading),
|
||||
]
|
||||
)
|
||||
|
||||
cli.echo("")
|
||||
table.echo()
|
||||
cli.echo("")
|
||||
|
||||
|
||||
# ======================================================================================
|
||||
|
Loading…
Reference in New Issue
Block a user