From e595eed57dbb22271eab33cc2bb2044bd4062d3b Mon Sep 17 00:00:00 2001 From: Klaus Schmidinger Date: Wed, 15 Jan 2025 10:50:29 +0100 Subject: [PATCH] The info files of recordings are now only re-read if they have been modified --- CONTRIBUTORS | 1 + HISTORY | 2 ++ recording.c | 10 +++++++++- recording.h | 3 ++- 4 files changed, 14 insertions(+), 2 deletions(-) diff --git a/CONTRIBUTORS b/CONTRIBUTORS index 24f2cf90..dfe3e7bf 100644 --- a/CONTRIBUTORS +++ b/CONTRIBUTORS @@ -3375,6 +3375,7 @@ Stefan Hofmann for adding 1 to Utf8BufSize() for worst case for adding a header to the backtrace for adding parameter checks to strn0cpy() + for making the info files of recordings only be re-read if they have been modified Stefan Blochberger for suggesting to automatically display the progress display whenever replay of a diff --git a/HISTORY b/HISTORY index f6430326..5dfa829d 100644 --- a/HISTORY +++ b/HISTORY @@ -10054,3 +10054,5 @@ Video Disk Recorder Revision History to Markus Ehrnsperger). - Added a header to the backtrace (thanks to Stefan Hofmann). - Added parameter checks to strn0cpy() (thanks to Stefan Hofmann). Same for Utf8Strn0Cpy(). +- The info files of recordings are now only re-read if they have been modified (thanks + to Stefan Hofmann). diff --git a/recording.c b/recording.c index 411f2947..df6eab83 100644 --- a/recording.c +++ b/recording.c @@ -4,7 +4,7 @@ * See the main source file 'vdr.c' for copyright information and * how to reach the author. * - * $Id: recording.c 5.35 2024/09/21 19:18:18 kls Exp $ + * $Id: recording.c 5.36 2025/01/15 10:50:29 kls Exp $ */ #include "recording.h" @@ -356,6 +356,7 @@ void cResumeFile::Delete(void) cRecordingInfo::cRecordingInfo(const cChannel *Channel, const cEvent *Event) { + modified = 0; channelID = Channel ? Channel->GetChannelID() : tChannelID::InvalidID; channelName = Channel ? strdup(Channel->Name()) : NULL; ownEvent = Event ? NULL : new cEvent(0); @@ -420,6 +421,7 @@ cRecordingInfo::cRecordingInfo(const cChannel *Channel, const cEvent *Event) cRecordingInfo::cRecordingInfo(const char *FileName) { + modified = 0; channelID = tChannelID::InvalidID; channelName = NULL; ownEvent = new cEvent(0); @@ -488,6 +490,12 @@ void cRecordingInfo::SetErrors(int Errors) bool cRecordingInfo::Read(FILE *f) { if (ownEvent) { + struct stat st; + if (fstat(fileno(f), &st)) + return false; + if (modified == st.st_mtime) + return true; + modified = st.st_mtime; cReadLine ReadLine; char *s; int line = 0; diff --git a/recording.h b/recording.h index 8bc0547c..22b5bf2b 100644 --- a/recording.h +++ b/recording.h @@ -4,7 +4,7 @@ * See the main source file 'vdr.c' for copyright information and * how to reach the author. * - * $Id: recording.h 5.11 2024/09/19 20:21:58 kls Exp $ + * $Id: recording.h 5.12 2025/01/15 10:50:29 kls Exp $ */ #ifndef __RECORDING_H @@ -64,6 +64,7 @@ public: class cRecordingInfo { friend class cRecording; private: + time_t modified; tChannelID channelID; char *channelName; const cEvent *event;