home · contact · privacy
Add "do not sync" flag to keep files from syncing without deleting them. master
authorChristian Heller <c.heller@plomlompom.de>
Wed, 25 Dec 2024 20:27:05 +0000 (21:27 +0100)
committerChristian Heller <c.heller@plomlompom.de>
Wed, 25 Dec 2024 20:27:05 +0000 (21:27 +0100)
src/sync.py
src/ytplom/misc.py

index bd7a74a257e027d3597363a33526aceac0afbdbe..c3ce570e67116ce62df765f030af07ecbdf60de9 100755 (executable)
@@ -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 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
 
 
 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))
         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)
 
 
             mover(vf.full_path, vf.full_path)
 
 
index 12e7953cc712bc694f329cd61bd0c7b80bdab1dd..ddaac97b7043356a35ddf0a1caf9365ef38bd419 100644 (file)
@@ -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] = {
 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))
 }
 
   FlagName('delete'): FlagsInt(-(1 << 63))
 }