summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorTimo Eskola <timo@tolleri.net>2018-09-06 19:03:03 (GMT)
committerTimo Eskola <timo@tolleri.net>2018-09-06 19:03:03 (GMT)
commit3f0ea3e26158e52cb8e6306cca6301bd18e3f687 (patch)
tree9c135b7392334f3cbfb66adf8e46d86cefca8987
parentcb2d73192b0c50f7b8f832f95e03fe9da430dec5 (diff)
downloadvdr-plugin-duplicates-3f0ea3e26158e52cb8e6306cca6301bd18e3f687.tar.gz
vdr-plugin-duplicates-3f0ea3e26158e52cb8e6306cca6301bd18e3f687.tar.bz2
Fixed deleted recording removal.
-rw-r--r--menu.c8
-rw-r--r--recording.c41
-rw-r--r--recording.h2
3 files changed, 27 insertions, 24 deletions
diff --git a/menu.c b/menu.c
index a5ec3d3..ca3ad71 100644
--- a/menu.c
+++ b/menu.c
@@ -297,9 +297,7 @@ eOSState cMenuDuplicates::Delete(void) {
cVideoDiskUsage::ForceCheck();
Recordings->SetModified();
recordingsStateKey.Remove();
- cStateKey stateKey;
- DuplicateRecordings.Lock(stateKey, true);
- stateKey.Remove(DuplicateRecordings.RemoveDeleted());
+ DuplicateRecordings.RemoveDeleted();
Set(true);
SetHelpKeys();
} else {
@@ -366,9 +364,7 @@ eOSState cMenuDuplicates::ToggleHidden(void) {
if (Interface->Confirm(hidden ? tr("Unhide recording?") : tr("Hide recording?"))) {
if (ri->Visibility().Write(hidden)) {
if (!dc.hidden) {
- cStateKey stateKey;
- DuplicateRecordings.Lock(stateKey, true);
- stateKey.Remove(DuplicateRecordings.RemoveDeleted());
+ DuplicateRecordings.RemoveDeleted();
Set(true);
}
SetHelpKeys();
diff --git a/recording.c b/recording.c
index c3a6ae9..1490494 100644
--- a/recording.c
+++ b/recording.c
@@ -53,7 +53,7 @@ cDuplicateRecording::cDuplicateRecording(const cDuplicateRecording &DuplicateRec
text(DuplicateRecording.text),
title(DuplicateRecording.title),
description(DuplicateRecording.description) {
- if (DuplicateRecording.duplicates != NULL) {
+ if (DuplicateRecording.duplicates != NULL && DuplicateRecording.duplicates->Count() > 0) {
duplicates = new cList<cDuplicateRecording>;
for (const cDuplicateRecording *duplicate = DuplicateRecording.duplicates->First(); duplicate; duplicate = DuplicateRecording.duplicates->Next(duplicate)) {
if (duplicate)
@@ -91,27 +91,35 @@ bool cDuplicateRecording::IsDuplicate(cDuplicateRecording *DuplicateRecording) {
cDuplicateRecordings::cDuplicateRecordings(void) : cList("duplicates") {}
-bool cDuplicateRecordings::RemoveDeleted(void) {
- dsyslog("duplicates: Removing deleted recordings.");
- int removed = 0;
- for (cDuplicateRecording *duplicates = First(); duplicates; duplicates = Next(duplicates)) {
- if (duplicates) {
- for (cDuplicateRecording *duplicate = duplicates->Duplicates()->First(); duplicate; duplicate = duplicates->Duplicates()->Next(duplicate)) {
- if (duplicate) {
+void cDuplicateRecordings::RemoveDeleted(void) {
+ dsyslog("duplicates: Checking %d duplicate recordings while removing deleted recordings.", Count());
+ cStateKey duplicateRecordingsStateKey;
+ Lock(duplicateRecordingsStateKey, true);
+ int rr = 0, rd = 0;
+ for (cDuplicateRecording *dr = First(); dr;) {
+ if (dr && dr->Duplicates()) {
+ cDuplicateRecording *duplicateRecording = dr;
+ dr = Next(dr);
+ for (cDuplicateRecording *d = duplicateRecording->Duplicates()->First(); d;) {
+ if (d) {
+ cDuplicateRecording *duplicate = d;
+ d = duplicateRecording->Duplicates()->Next(d);
LOCK_RECORDINGS_READ
const cRecording *recording = Recordings->GetByName(duplicate->FileName().c_str());
if (!recording || !dc.hidden && duplicate->Visibility().Read() == HIDDEN) {
- duplicates->Duplicates()->Del(duplicate);
- removed++;
+ duplicateRecording->Duplicates()->Del(duplicate);
+ rr++;
}
}
}
- if (duplicates->Duplicates()->Count() < 2)
- Del(duplicates);
+ if (duplicateRecording->Duplicates()->Count() < 2) {
+ Del(duplicateRecording);
+ rd++;
+ }
}
}
- dsyslog("duplicates: Removed %d deleted recordings.", removed);
- return removed > 0;
+ duplicateRecordingsStateKey.Remove(rr > 0);
+ dsyslog("duplicates: Removed %d deleted recordings and %d duplicate recordings.", rr, rd);
}
cDuplicateRecordings DuplicateRecordings;
@@ -151,9 +159,7 @@ void cDuplicateRecordingScannerThread::Scan(void) {
dsyslog("duplicates: Scanning of duplicate recordings started.");
struct timeval startTime, stopTime;
gettimeofday(&startTime, NULL);
- cStateKey duplicateRecordingsStateKey;
- DuplicateRecordings.Lock(duplicateRecordingsStateKey, true);
- duplicateRecordingsStateKey.Remove(DuplicateRecordings.RemoveDeleted());
+ DuplicateRecordings.RemoveDeleted();
cDuplicateRecording *descriptionless = new cDuplicateRecording();
cList<cDuplicateRecording> recordings;
cRecordings *Recordings = cRecordings::GetRecordingsWrite(recordingsStateKey); // write access is necessary for sorting!
@@ -202,6 +208,7 @@ void cDuplicateRecordingScannerThread::Scan(void) {
delete descriptionless;
if (RecordingsStateChanged())
return;
+ cStateKey duplicateRecordingsStateKey;
DuplicateRecordings.Lock(duplicateRecordingsStateKey, true);
DuplicateRecordings.Clear();
for (cDuplicateRecording *duplicate = duplicates.First(); duplicate; duplicate = duplicates.Next(duplicate)) {
diff --git a/recording.h b/recording.h
index 37ec660..cb08e2e 100644
--- a/recording.h
+++ b/recording.h
@@ -45,7 +45,7 @@ public:
class cDuplicateRecordings : public cList<cDuplicateRecording> {
public:
cDuplicateRecordings(void);
- bool RemoveDeleted(void);
+ void RemoveDeleted(void);
};
extern cDuplicateRecordings DuplicateRecordings;