From 3a4bce2ac854c985b65e9d971d4315cc1508f36a Mon Sep 17 00:00:00 2001
From: Christian Heller <c.heller@plomlompom.de>
Date: Wed, 25 Dec 2024 21:27:05 +0100
Subject: [PATCH] Add "do not sync" flag to keep files from syncing without
 deleting them.

---
 src/sync.py        | 9 ++++++---
 src/ytplom/misc.py | 1 +
 2 files changed, 7 insertions(+), 3 deletions(-)

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))
 }
 
-- 
2.30.2