1
0
mirror of https://github.com/VDR4Arch/vdr.git synced 2023-10-10 13:36:52 +02:00

Automatically removing deleted recordings after a while

This commit is contained in:
Klaus Schmidinger 2001-02-04 12:36:32 +01:00
parent 2adfad2823
commit 1c81b279ee
7 changed files with 54 additions and 11 deletions

View File

@ -350,7 +350,7 @@ Video Disk Recorder Revision History
- Encrypted channels can now be selected even without knowing the PNR (however, it - Encrypted channels can now be selected even without knowing the PNR (however, it
is still necessary for the EPG info). 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 - 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 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 to 0), but once they are written back (due to some channel editing) the file
will have the new format. will have the new format.
- The EPG scanner now scans each transponder only once per cycle. - 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).

11
menu.c
View File

@ -4,7 +4,7 @@
* See the main source file 'vdr.c' for copyright information and * See the main source file 'vdr.c' for copyright information and
* how to reach the author. * 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" #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 ---------------------------------------------------------- // --- cProgressBar ----------------------------------------------------------
class cProgressBar : public cBitmap { class cProgressBar : public cBitmap {

3
menu.h
View File

@ -4,7 +4,7 @@
* See the main source file 'vdr.c' for copyright information and * See the main source file 'vdr.c' for copyright information and
* how to reach the author. * 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 #ifndef _MENU_H
@ -74,6 +74,7 @@ public:
static void Stop(cDvbApi *DvbApi); static void Stop(cDvbApi *DvbApi);
static const char *GetInstantId(const char *LastInstantId); static const char *GetInstantId(const char *LastInstantId);
static void Process(void); static void Process(void);
static bool Active(void);
}; };
class cReplayControl : public cOsdBase { class cReplayControl : public cOsdBase {

View File

@ -4,7 +4,7 @@
* See the main source file 'vdr.c' for copyright information and * See the main source file 'vdr.c' for copyright information and
* how to reach the author. * 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 #define _GNU_SOURCE
@ -32,8 +32,34 @@
#define MINDISKSPACE 1024 // MB #define MINDISKSPACE 1024 // MB
#define DISKCHECKDELTA 300 // seconds between checks for free disk space #define DELETEDLIFETIME 1 // hours after which a deleted recording will be actually removed
#define REMOVELATENCY 10 // seconds to wait until next check after removing a file #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) void AssertFreeDiskSpace(void)
{ {

View File

@ -4,7 +4,7 @@
* See the main source file 'vdr.c' for copyright information and * See the main source file 'vdr.c' for copyright information and
* how to reach the author. * 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 #ifndef __RECORDING_H
@ -14,6 +14,7 @@
#include "config.h" #include "config.h"
#include "tools.h" #include "tools.h"
void RemoveDeletedRecordings(void);
void AssertFreeDiskSpace(void); void AssertFreeDiskSpace(void);
class cRecording : public cListObject { class cRecording : public cListObject {

View File

@ -4,7 +4,7 @@
* See the main source file 'vdr.c' for copyright information and * See the main source file 'vdr.c' for copyright information and
* how to reach the author. * 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 #define _GNU_SOURCE
@ -237,8 +237,10 @@ bool RemoveFileOrDir(const char *FileName, bool FollowSymlinks)
} }
} }
dsyslog(LOG_INFO, "removing %s", FileName); dsyslog(LOG_INFO, "removing %s", FileName);
if (remove(FileName) == 0) if (remove(FileName) < 0) {
return true; LOG_ERROR_STR(FileName);
return false;
}
} }
else if (errno != ENOENT) { else if (errno != ENOENT) {
LOG_ERROR_STR(FileName); LOG_ERROR_STR(FileName);

4
vdr.c
View File

@ -22,7 +22,7 @@
* *
* The project's page is at http://www.cadsoft.de/people/kls/vdr * 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 <getopt.h> #include <getopt.h>
@ -324,6 +324,8 @@ int main(int argc, char *argv[])
EITScanner.Process(); EITScanner.Process();
cVideoCutter::Active(); cVideoCutter::Active();
} }
if (!*Interact && !cRecordControls::Active())
RemoveDeletedRecordings();
} }
isyslog(LOG_INFO, "caught signal %d", Interrupted); isyslog(LOG_INFO, "caught signal %d", Interrupted);
Setup.CurrentChannel = cDvbApi::CurrentChannel(); Setup.CurrentChannel = cDvbApi::CurrentChannel();