summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--CONTRIBUTORS2
-rw-r--r--HISTORY5
-rw-r--r--recording.c53
-rw-r--r--recording.h3
4 files changed, 30 insertions, 33 deletions
diff --git a/CONTRIBUTORS b/CONTRIBUTORS
index 4ba1ac57..869e12ee 100644
--- a/CONTRIBUTORS
+++ b/CONTRIBUTORS
@@ -16,6 +16,8 @@ Carsten Koch <Carsten.Koch@icem.de>
for fixing converting summary.vdr files that would result in a very long 'short text'
for his help in testing and debugging reading the list of recordings in a
separate thread
+ for reporting some unnecessary disk access when checking if there are deleted
+ recordings that need to be removed
Plamen Ganev <pganev@com-it.net>
for fixing the frequency offset for Hotbird channels
diff --git a/HISTORY b/HISTORY
index b89584f8..79b8e848 100644
--- a/HISTORY
+++ b/HISTORY
@@ -3979,3 +3979,8 @@ Video Disk Recorder Revision History
- When displaying the amount of free disk space, the space consumed by
recordings that have been "deleted" but not yet actually "removed" is now
taken into account (suggested by Christian Vogt).
+- Now avoiding unnecessary disk access when checking if there are deleted
+ recordings that need to be removed (reported by Carsten Koch).
+- Fixed handling the DELETEDLIFETIME when removing deleted recordings. Now
+ a deleted recording is retained at least DELETEDLIFETIME seconds before
+ actually removing it (unless a new recording requires the disk space).
diff --git a/recording.c b/recording.c
index bf66fcfe..73625498 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.125 2005/12/17 13:30:50 kls Exp $
+ * $Id: recording.c 1.126 2005/12/18 12:06:36 kls Exp $
*/
#include "recording.h"
@@ -48,8 +48,8 @@
#define MINDISKSPACE 1024 // MB
-#define DELETEDLIFETIME 1 // hours after which a deleted recording will be actually removed
-#define REMOVECHECKDELTA 3600 // seconds between checks for removing deleted files
+#define REMOVECHECKDELTA 60 // seconds between checks for removing deleted files
+#define DELETEDLIFETIME 3600 // seconds after which a deleted recording will be actually removed
#define DISKCHECKDELTA 100 // seconds between checks for free disk space
#define REMOVELATENCY 10 // seconds to wait until next check after removing a file
@@ -65,35 +65,19 @@ cRecordings DeletedRecordings(true);
void RemoveDeletedRecordings(void)
{
static time_t LastRemoveCheck = 0;
- if (LastRemoveCheck == 0) {
- DeletedRecordings.Update();
- LastRemoveCheck = time(NULL) - REMOVECHECKDELTA * 9 / 10;
- }
- else if (time(NULL) - LastRemoveCheck > REMOVECHECKDELTA) {
- // Make sure only one instance of VDR does this:
- cLockFile LockFile(VideoDirectory);
- if (!LockFile.Lock())
- return;
- // Remove the oldest file that has been "deleted":
+ if (time(NULL) - LastRemoveCheck > REMOVECHECKDELTA) {
cThreadLock DeletedRecordingsLock(&DeletedRecordings);
- if (DeletedRecordings.Count()) {
- cRecording *r = DeletedRecordings.First();
- cRecording *r0 = r;
- while (r) {
- if (r->start < r0->start)
- r0 = r;
- r = DeletedRecordings.Next(r);
- }
- if (r0 && time(NULL) - r0->start > DELETEDLIFETIME * 3600) {
- r0->Remove();
- DeletedRecordings.Del(r0);
- RemoveEmptyVideoDirectories();
- LastRemoveCheck += REMOVELATENCY;
- return;
- }
- }
- else
- DeletedRecordings.Update();
+ for (cRecording *r = DeletedRecordings.First(); r; r = DeletedRecordings.Next(r)) {
+ if (r->deleted && time(NULL) - r->deleted > DELETEDLIFETIME) {
+ // Make sure only one instance of VDR does this:
+ cLockFile LockFile(VideoDirectory);
+ if (LockFile.Lock()) {
+ r->Remove();
+ DeletedRecordings.Del(r);
+ RemoveEmptyVideoDirectories();
+ }
+ }
+ }
LastRemoveCheck = time(NULL);
}
}
@@ -401,6 +385,7 @@ cRecording::cRecording(cTimer *Timer, const cEvent *Event)
fileName = NULL;
name = NULL;
fileSizeMB = -1; // unknown
+ deleted = 0;
// set up the actual name:
const char *Title = Event ? Event->Title() : NULL;
const char *Subtitle = Event ? Event->ShortText() : NULL;
@@ -455,6 +440,7 @@ cRecording::cRecording(const char *FileName)
{
resume = RESUME_NOT_INITIALIZED;
fileSizeMB = -1; // unknown
+ deleted = 0;
titleBuffer = NULL;
sortBuffer = NULL;
fileName = strdup(FileName);
@@ -816,8 +802,10 @@ void cRecordings::ScanVideoDir(const char *DirName, bool Foreground)
Add(r);
ChangeState();
Unlock();
- if (deleted)
+ if (deleted) {
r->fileSizeMB = DirSizeMB(buffer);
+ r->deleted = time(NULL);
+ }
}
else
delete r;
@@ -893,6 +881,7 @@ void cRecordings::DelByName(const char *FileName)
if (ext) {
strncpy(ext, DELEXT, strlen(ext));
recording->fileSizeMB = DirSizeMB(recording->FileName());
+ recording->deleted = time(NULL);
DeletedRecordings.Add(recording);
}
else
diff --git a/recording.h b/recording.h
index 80ee8112..d79b6b4d 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.47 2005/12/17 13:30:50 kls Exp $
+ * $Id: recording.h 1.48 2005/12/18 11:26:51 kls Exp $
*/
#ifndef __RECORDING_H
@@ -71,6 +71,7 @@ public:
time_t start;
int priority;
int lifetime;
+ time_t deleted;
cRecording(cTimer *Timer, const cEvent *Event);
cRecording(const char *FileName);
virtual ~cRecording();