home
·
contact
·
privacy
projects
/
ytplom
/ commitdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
| commitdiff |
tree
raw
|
patch
|
inline
| side by side (parent:
7781a04
)
For VideoFiles, renew .last_update any time .save() saves actual changes to other...
master
author
Christian Heller
<c.heller@plomlompom.de>
Tue, 3 Dec 2024 06:01:52 +0000
(07:01 +0100)
committer
Christian Heller
<c.heller@plomlompom.de>
Tue, 3 Dec 2024 06:01:52 +0000
(07:01 +0100)
src/ytplom/misc.py
patch
|
blob
|
history
diff --git
a/src/ytplom/misc.py
b/src/ytplom/misc.py
index 4b36b5a7bad2768ab3b8aac490625e15d7dceef4..d0b55e894dc7ecc9b541d0198d872826c7fd538c 100644
(file)
--- a/
src/ytplom/misc.py
+++ b/
src/ytplom/misc.py
@@
-12,6
+12,7
@@
from uuid import uuid4
from pathlib import Path
from threading import Thread
from queue import Queue
from pathlib import Path
from threading import Thread
from queue import Queue
+from sqlite3 import Cursor
# non-included libs
import googleapiclient.discovery # type: ignore
from mpv import MPV # type: ignore
# non-included libs
import googleapiclient.discovery # type: ignore
from mpv import MPV # type: ignore
@@
-270,9
+271,22
@@
class VideoFile(DbData):
self._renew_last_update()
else:
self.last_update = last_update
self._renew_last_update()
else:
self.last_update = last_update
+ self._hash_on_last_update = hash(self)
+
+ def __hash__(self) -> int:
+ return hash(f'{self.digest.b64}|{self.rel_path}|{self.flags}|'
+ f'{self.yt_id}|{self.last_update}|{self.tags_str}')
def _renew_last_update(self):
def _renew_last_update(self):
+ print("DEBUG calling_renew_last_update", self.rel_path)
self.last_update = DatetimeStr(datetime.now().strftime(TIMESTAMP_FMT))
self.last_update = DatetimeStr(datetime.now().strftime(TIMESTAMP_FMT))
+ self._hash_on_last_update = hash(self)
+
+ def save(self, conn: BaseDbConn) -> Cursor:
+ """Extend super().save by new .last_update if sufficient changes."""
+ if hash(self) != self._hash_on_last_update:
+ self._renew_last_update()
+ return super().save(conn)
@classmethod
def get_by_yt_id(cls, conn: BaseDbConn, yt_id: YoutubeId) -> Self:
@classmethod
def get_by_yt_id(cls, conn: BaseDbConn, yt_id: YoutubeId) -> Self:
@@
-324,7
+338,6
@@
class VideoFile(DbData):
self.flags = FlagsInt(0)
for flag in flags:
self.flags = FlagsInt(self.flags | flag)
self.flags = FlagsInt(0)
for flag in flags:
self.flags = FlagsInt(self.flags | flag)
- self._renew_last_update()
def is_flag_set(self, flag_name: FlagName) -> bool:
"""Return if flag of flag_name is set in flags field."""
def is_flag_set(self, flag_name: FlagName) -> bool:
"""Return if flag of flag_name is set in flags field."""