From: Christian Heller Date: Wed, 25 Dec 2024 20:27:05 +0000 (+0100) Subject: Add "do not sync" flag to keep files from syncing without deleting them. X-Git-Url: https://plomlompom.com/repos/%7B%7B%20web_path%20%7D%7D/decks/%7B%7B%20deck_id%20%7D%7D/processes?a=commitdiff_plain;h=3a4bce2ac854c985b65e9d971d4315cc1508f36a;p=ytplom Add "do not sync" flag to keep files from syncing without deleting them. --- diff --git a/src/sync.py b/src/sync.py index bd7a74a..c3ce570 100755 --- a/src/sync.py +++ b/src/sync.py @@ -9,8 +9,8 @@ from urllib.request import urlopen from paramiko import SSHClient # type: ignore from scp import SCPClient # type: ignore from ytplom.db import DbConn, Hash, PATH_DB -from ytplom.misc import ( - PATH_TEMP, Config, QuotaLog, VideoFile, YoutubeQuery, YoutubeVideo) +from ytplom.misc import (PATH_TEMP, Config, FlagName, QuotaLog, VideoFile, + YoutubeQuery, YoutubeVideo) from ytplom.http import PAGE_NAMES @@ -102,7 +102,10 @@ def fill_missing(scp: SCPClient, config: Config) -> None: for digest in (d for d in missings[i] if d not in missings[int(not bool(i))]): vf = VideoFile.get_one(conn, Hash.from_b64(digest)) - print(f'SYNC: sending {direction} file {vf.full_path}') + if vf.is_flag_set(FlagName('do not sync')): + print(f'SYNC: not sending ("do not sync" set): {vf.full_path}') + return + print(f'SYNC: sending {direction}: {vf.full_path}') mover(vf.full_path, vf.full_path) diff --git a/src/ytplom/misc.py b/src/ytplom/misc.py index 12e7953..ddaac97 100644 --- a/src/ytplom/misc.py +++ b/src/ytplom/misc.py @@ -71,6 +71,7 @@ ENVIRON_PREFIX = 'YTPLOM_' TIMESTAMP_FMT = '%Y-%m-%d %H:%M:%S.%f' LEGAL_EXTENSIONS = {'webm', 'mp4', 'mkv'} FILE_FLAGS: dict[FlagName, FlagsInt] = { + FlagName('do not sync'): FlagsInt(1 << 62), FlagName('delete'): FlagsInt(-(1 << 63)) }