diff --git a/CHANGELOG.org b/CHANGELOG.org index c1ba2c1..910182c 100644 --- a/CHANGELOG.org +++ b/CHANGELOG.org @@ -19,3 +19,5 @@ Fixed label_prompt returning list. ** 0.5.3 <2023-03-05 Sun> Added *sync group* function. +** 0.6.0 <2023-03-09 Thu> + Added *path checking* function. diff --git a/tui_rsync/cli/sync.py b/tui_rsync/cli/sync.py index 2750149..f7eebd6 100644 --- a/tui_rsync/cli/sync.py +++ b/tui_rsync/cli/sync.py @@ -32,6 +32,8 @@ from cli.rsync import Rsync console = Console() sync = typer.Typer() +skip_error = "[yellow b]Skippped[/] because the [red b]path was unavailable[/]." + @sync.command() def one( label: str = typer.Option( @@ -42,12 +44,16 @@ def one( ): """ [green b]Sync[/] a [yellow]source[/] with the [yellow b]label[/] and its backups. + [yellow b]Skips[/] if not available. """ if label is None: label = LabelPrompt.get_label_fzf() src = Source.get_source(label) rsync = Rsync(str(src.args)) for dest in src.destinations: + if not dest.path.is_exists(): + console.print(skip_error) + continue rsync.run_one(str(src.source), str(dest)) @sync.command() diff --git a/tui_rsync/models/models.py b/tui_rsync/models/models.py index b98a9cf..9650476 100644 --- a/tui_rsync/models/models.py +++ b/tui_rsync/models/models.py @@ -18,6 +18,7 @@ ################################################################################ from peewee import * +import os db = SqliteDatabase('sync.db') @@ -34,6 +35,9 @@ class Path(BaseModel): def __repr__(self) -> str: return f"Path({self.path})" + def is_exists(self) -> bool: + return os.path.exists(self.path) + class SyncCommand(BaseModel): command = CharField()