diff options
author | Klaus Schmidinger <vdr@tvdr.de> | 2001-02-04 12:36:32 +0100 |
---|---|---|
committer | Klaus Schmidinger <vdr@tvdr.de> | 2001-02-04 12:36:32 +0100 |
commit | 1c81b279eed647bbe938a2e89a66ce6e0d3d2121 (patch) | |
tree | c9e7bc225cc2203e32dee16a70a6986f8b580928 /recording.c | |
parent | 2adfad282320b6a6b116284507aac870d536a69a (diff) | |
download | vdr-1c81b279eed647bbe938a2e89a66ce6e0d3d2121.tar.gz vdr-1c81b279eed647bbe938a2e89a66ce6e0d3d2121.tar.bz2 |
Automatically removing deleted recordings after a while
Diffstat (limited to 'recording.c')
-rw-r--r-- | recording.c | 32 |
1 files changed, 29 insertions, 3 deletions
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) { |