mirror of
https://gitlab.com/KKlochko/tui-rsync.git
synced 2026-08-20 05:37:43 +00:00
(Added) path checking function.
This commit is contained in:
@@ -19,3 +19,5 @@
|
|||||||
Fixed label_prompt returning list.
|
Fixed label_prompt returning list.
|
||||||
** 0.5.3 <2023-03-05 Sun>
|
** 0.5.3 <2023-03-05 Sun>
|
||||||
Added *sync group* function.
|
Added *sync group* function.
|
||||||
|
** 0.6.0 <2023-03-09 Thu>
|
||||||
|
Added *path checking* function.
|
||||||
|
|||||||
@@ -32,6 +32,8 @@ from cli.rsync import Rsync
|
|||||||
console = Console()
|
console = Console()
|
||||||
sync = typer.Typer()
|
sync = typer.Typer()
|
||||||
|
|
||||||
|
skip_error = "[yellow b]Skippped[/] because the [red b]path was unavailable[/]."
|
||||||
|
|
||||||
@sync.command()
|
@sync.command()
|
||||||
def one(
|
def one(
|
||||||
label: str = typer.Option(
|
label: str = typer.Option(
|
||||||
@@ -42,12 +44,16 @@ def one(
|
|||||||
):
|
):
|
||||||
"""
|
"""
|
||||||
[green b]Sync[/] a [yellow]source[/] with the [yellow b]label[/] and its backups.
|
[green b]Sync[/] a [yellow]source[/] with the [yellow b]label[/] and its backups.
|
||||||
|
[yellow b]Skips[/] if not available.
|
||||||
"""
|
"""
|
||||||
if label is None:
|
if label is None:
|
||||||
label = LabelPrompt.get_label_fzf()
|
label = LabelPrompt.get_label_fzf()
|
||||||
src = Source.get_source(label)
|
src = Source.get_source(label)
|
||||||
rsync = Rsync(str(src.args))
|
rsync = Rsync(str(src.args))
|
||||||
for dest in src.destinations:
|
for dest in src.destinations:
|
||||||
|
if not dest.path.is_exists():
|
||||||
|
console.print(skip_error)
|
||||||
|
continue
|
||||||
rsync.run_one(str(src.source), str(dest))
|
rsync.run_one(str(src.source), str(dest))
|
||||||
|
|
||||||
@sync.command()
|
@sync.command()
|
||||||
|
|||||||
@@ -18,6 +18,7 @@
|
|||||||
################################################################################
|
################################################################################
|
||||||
|
|
||||||
from peewee import *
|
from peewee import *
|
||||||
|
import os
|
||||||
|
|
||||||
db = SqliteDatabase('sync.db')
|
db = SqliteDatabase('sync.db')
|
||||||
|
|
||||||
@@ -34,6 +35,9 @@ class Path(BaseModel):
|
|||||||
def __repr__(self) -> str:
|
def __repr__(self) -> str:
|
||||||
return f"Path({self.path})"
|
return f"Path({self.path})"
|
||||||
|
|
||||||
|
def is_exists(self) -> bool:
|
||||||
|
return os.path.exists(self.path)
|
||||||
|
|
||||||
class SyncCommand(BaseModel):
|
class SyncCommand(BaseModel):
|
||||||
command = CharField()
|
command = CharField()
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user