diff --git a/HISTORY b/HISTORY index 6a85b670..f876d104 100644 --- a/HISTORY +++ b/HISTORY @@ -350,7 +350,7 @@ Video Disk Recorder Revision History - Encrypted channels can now be selected even without knowing the PNR (however, it is still necessary for the EPG info). -2001-02-03: Version 0.71 +2001-02-04: Version 0.71 - Fixed 'Transfer Mode' in cases where a non-primary interface was switched to a channel that only the primary interface can receive (which could happen in @@ -376,3 +376,5 @@ Video Disk Recorder Revision History to 0), but once they are written back (due to some channel editing) the file will have the new format. - The EPG scanner now scans each transponder only once per cycle. +- Deleted recordings are now automatically removed from disk after a while (not + only when disk space is being needed for a new recording). diff --git a/menu.c b/menu.c index b20b89d1..1616fb45 100644 --- a/menu.c +++ b/menu.c @@ -4,7 +4,7 @@ * See the main source file 'vdr.c' for copyright information and * how to reach the author. * - * $Id: menu.c 1.62 2001/02/03 16:05:31 kls Exp $ + * $Id: menu.c 1.63 2001/02/04 11:48:01 kls Exp $ */ #include "menu.h" @@ -2019,6 +2019,15 @@ void cRecordControls::Process(void) } } +bool cRecordControls::Active(void) +{ + for (int i = 0; i < MAXDVBAPI; i++) { + if (RecordControls[i]) + return true; + } + return false; +} + // --- cProgressBar ---------------------------------------------------------- class cProgressBar : public cBitmap { diff --git a/menu.h b/menu.h index 92321111..b8ea98b3 100644 --- a/menu.h +++ b/menu.h @@ -4,7 +4,7 @@ * See the main source file 'vdr.c' for copyright information and * how to reach the author. * - * $Id: menu.h 1.16 2000/12/25 14:25:29 kls Exp $ + * $Id: menu.h 1.17 2001/02/04 11:47:21 kls Exp $ */ #ifndef _MENU_H @@ -74,6 +74,7 @@ public: static void Stop(cDvbApi *DvbApi); static const char *GetInstantId(const char *LastInstantId); static void Process(void); + static bool Active(void); }; class cReplayControl : public cOsdBase { diff --git a/recording.c b/recording.c index 064731df..dd364638 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 1.24 2001/01/13 12:17:15 kls Exp $ + * $Id: recording.c 1.25 2001/02/04 12:36:32 kls Exp $ */ #define _GNU_SOURCE @@ -32,8 +32,34 @@ #define MINDISKSPACE 1024 // MB -#define DISKCHECKDELTA 300 // seconds between checks for free disk space -#define REMOVELATENCY 10 // seconds to wait until next check after removing a file +#define DELETEDLIFETIME 1 // hours after which a deleted recording will be actually removed +#define REMOVECHECKDELTA 3600 // seconds between checks for removing deleted files +#define DISKCHECKDELTA 300 // seconds between checks for free disk space +#define REMOVELATENCY 10 // seconds to wait until next check after removing a file + +void RemoveDeletedRecordings(void) +{ + static time_t LastRemoveCheck = 0; + if (time(NULL) - LastRemoveCheck > REMOVECHECKDELTA) { + // Remove the oldest file that has been "deleted": + cRecordings Recordings; + if (Recordings.Load(true)) { + cRecording *r = Recordings.First(); + cRecording *r0 = r; + while (r) { + if (r->start < r0->start) + r0 = r; + r = Recordings.Next(r); + } + if (r0 && time(NULL) - r0->start > DELETEDLIFETIME * 60) { + r0->Remove(); + LastRemoveCheck += REMOVELATENCY; + return; + } + } + LastRemoveCheck = time(NULL); + } +} void AssertFreeDiskSpace(void) { diff --git a/recording.h b/recording.h index 454c356f..2d3ea392 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 1.11 2000/12/16 14:25:20 kls Exp $ + * $Id: recording.h 1.12 2001/02/04 11:44:37 kls Exp $ */ #ifndef __RECORDING_H @@ -14,6 +14,7 @@ #include "config.h" #include "tools.h" +void RemoveDeletedRecordings(void); void AssertFreeDiskSpace(void); class cRecording : public cListObject { diff --git a/tools.c b/tools.c index cd2c60f8..9546dd11 100644 --- a/tools.c +++ b/tools.c @@ -4,7 +4,7 @@ * See the main source file 'vdr.c' for copyright information and * how to reach the author. * - * $Id: tools.c 1.27 2001/01/13 15:35:02 kls Exp $ + * $Id: tools.c 1.28 2001/02/04 11:27:49 kls Exp $ */ #define _GNU_SOURCE @@ -237,8 +237,10 @@ bool RemoveFileOrDir(const char *FileName, bool FollowSymlinks) } } dsyslog(LOG_INFO, "removing %s", FileName); - if (remove(FileName) == 0) - return true; + if (remove(FileName) < 0) { + LOG_ERROR_STR(FileName); + return false; + } } else if (errno != ENOENT) { LOG_ERROR_STR(FileName); diff --git a/vdr.c b/vdr.c index b0bb4973..715df223 100644 --- a/vdr.c +++ b/vdr.c @@ -22,7 +22,7 @@ * * The project's page is at http://www.cadsoft.de/people/kls/vdr * - * $Id: vdr.c 1.50 2001/02/02 15:48:11 kls Exp $ + * $Id: vdr.c 1.51 2001/02/04 11:51:11 kls Exp $ */ #include @@ -324,6 +324,8 @@ int main(int argc, char *argv[]) EITScanner.Process(); cVideoCutter::Active(); } + if (!*Interact && !cRecordControls::Active()) + RemoveDeletedRecordings(); } isyslog(LOG_INFO, "caught signal %d", Interrupted); Setup.CurrentChannel = cDvbApi::CurrentChannel();