summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorTimo Eskola <timo@tolleri.net>2018-09-07 18:47:55 (GMT)
committerTimo Eskola <timo@tolleri.net>2018-09-07 18:47:55 (GMT)
commit1319c9dfac793756aa84fa584fbe65908dd374fa (patch)
tree692b2ee93e2a771287fac6b6a3e5633e7451813a
parentb137e467c469853d6ddd6fa5200663e113cba9ac (diff)
downloadvdr-plugin-duplicates-1319c9dfac793756aa84fa584fbe65908dd374fa.tar.gz
vdr-plugin-duplicates-1319c9dfac793756aa84fa584fbe65908dd374fa.tar.bz2
Fixed duplicate recording count after deletion and hiding.
-rw-r--r--menu.c4
-rw-r--r--recording.c24
-rw-r--r--recording.h2
3 files changed, 16 insertions, 14 deletions
diff --git a/menu.c b/menu.c
index e26ee05..ef451f5 100644
--- a/menu.c
+++ b/menu.c
@@ -293,7 +293,7 @@ eOSState cMenuDuplicates::Delete(void) {
cVideoDiskUsage::ForceCheck();
Recordings->SetModified();
recordingsStateKey.Remove();
- DuplicateRecordings.RemoveDeleted();
+ DuplicateRecordings.Remove(std::string(FileName));
Set(true);
SetHelpKeys();
} else {
@@ -360,7 +360,7 @@ eOSState cMenuDuplicates::ToggleHidden(void) {
if (Interface->Confirm(hidden ? tr("Unhide recording?") : tr("Hide recording?"))) {
if (ri->Visibility().Write(hidden)) {
if (!dc.hidden) {
- DuplicateRecordings.RemoveDeleted();
+ DuplicateRecordings.Remove(std::string(ri->FileName()));
Set(true);
}
SetHelpKeys();
diff --git a/recording.c b/recording.c
index 59aee2f..0217b1e 100644
--- a/recording.c
+++ b/recording.c
@@ -90,21 +90,18 @@ bool cDuplicateRecording::IsDuplicate(cDuplicateRecording *DuplicateRecording) {
cDuplicateRecordings::cDuplicateRecordings(void) : cList("duplicates") {}
-void cDuplicateRecordings::RemoveDeleted(void) {
- dsyslog("duplicates: Checking %d duplicate recordings while removing deleted recordings.", Count());
+void cDuplicateRecordings::Remove(std::string fileName) {
cStateKey duplicateRecordingsStateKey;
Lock(duplicateRecordingsStateKey, true);
int rr = 0, rd = 0;
for (cDuplicateRecording *dr = First(); dr;) {
- if (dr->Duplicates()) {
- cDuplicateRecording *duplicateRecording = dr;
- dr = Next(dr);
+ cDuplicateRecording *duplicateRecording = dr;
+ dr = Next(dr);
+ if (duplicateRecording->Duplicates()) {
for (cDuplicateRecording *d = duplicateRecording->Duplicates()->First(); 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) {
+ if (duplicate->FileName() == fileName) {
duplicateRecording->Duplicates()->Del(duplicate);
rr++;
}
@@ -112,11 +109,17 @@ void cDuplicateRecordings::RemoveDeleted(void) {
if (duplicateRecording->Duplicates()->Count() < 2) {
Del(duplicateRecording);
rd++;
- }
+ } else if (duplicateRecording->HasDescription()) {
+ duplicateRecording->SetText(std::string(cString::sprintf(tr("%d duplicate recordings"), duplicateRecording->Duplicates()->Count())));
+ } else
+ duplicateRecording->SetText(std::string(cString::sprintf(tr("%d recordings without description"), duplicateRecording->Duplicates()->Count())));
+ } else {
+ Del(duplicateRecording);
+ rd++;
}
}
duplicateRecordingsStateKey.Remove(rr > 0);
- dsyslog("duplicates: Removed %d deleted recordings and %d duplicate recordings.", rr, rd);
+ dsyslog("duplicates: Removed %d recordings and %d duplicate recordings.", rr, rd);
}
cDuplicateRecordings DuplicateRecordings;
@@ -156,7 +159,6 @@ void cDuplicateRecordingScannerThread::Scan(void) {
dsyslog("duplicates: Scanning of duplicate recordings started.");
struct timeval startTime, stopTime;
gettimeofday(&startTime, NULL);
- DuplicateRecordings.RemoveDeleted();
cDuplicateRecording *descriptionless = new cDuplicateRecording();
cList<cDuplicateRecording> recordings;
cRecordings *Recordings = cRecordings::GetRecordingsWrite(recordingsStateKey); // write access is necessary for sorting!
diff --git a/recording.h b/recording.h
index cb08e2e..18a666f 100644
--- a/recording.h
+++ b/recording.h
@@ -45,7 +45,7 @@ public:
class cDuplicateRecordings : public cList<cDuplicateRecording> {
public:
cDuplicateRecordings(void);
- void RemoveDeleted(void);
+ void Remove(std::string fileName);
};
extern cDuplicateRecordings DuplicateRecordings;