(Added) path checking function.

This commit is contained in:
2023-03-09 17:29:00 +02:00
parent bb9851057f
commit e440cc24ac
3 changed files with 12 additions and 0 deletions
+6
View File
@@ -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()
+4
View File
@@ -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()