Ticket #9415: filemarkup-update-on-scan

File filemarkup-update-on-scan, 1.6 KB (added by Johnny Stenback <mythtv-users@…>, 9 years ago)

Update filename in filemarkup on scan...

Line 
1diff --git a/mythtv/libs/libmythmetadata/videometadata.cpp b/mythtv/libs/libmythmetadata/videometadata.cpp
2index 6c4a69a..581ae2c 100644
3--- a/mythtv/libs/libmythmetadata/videometadata.cpp
4+++ b/mythtv/libs/libmythmetadata/videometadata.cpp
5@@ -909,7 +909,7 @@ int VideoMetadata::UpdateHashedDBRecord(const QString &hash,
6 {
7     MSqlQuery query(MSqlQuery::InitCon());
8 
9-    query.prepare("SELECT intid FROM videometadata WHERE "
10+    query.prepare("SELECT intid,filename FROM videometadata WHERE "
11                   "hash = :HASH");
12     query.bindValue(":HASH", hash);
13 
14@@ -923,6 +923,7 @@ int VideoMetadata::UpdateHashedDBRecord(const QString &hash,
15         return -1;
16 
17     int intid = query.value(0).toInt();
18+    QString oldfilename = query.value(1).toString();
19 
20     query.prepare("UPDATE videometadata SET filename = :FILENAME, "
21                   "host = :HOST WHERE intid = :INTID");
22@@ -932,7 +933,18 @@ int VideoMetadata::UpdateHashedDBRecord(const QString &hash,
23 
24     if (!query.exec() || !query.isActive())
25     {
26-        MythDB::DBError("Video hashed metadata update", query);
27+        MythDB::DBError("Video hashed metadata update (videometadata)", query);
28+        return -1;
29+    }
30+
31+    query.prepare("UPDATE filemarkup SET filename = :FILENAME "
32+                  "WHERE filename = :OLDFILENAME");
33+    query.bindValue(":FILENAME", file_name);
34+    query.bindValue(":OLDFILENAME", oldfilename);
35+
36+    if (!query.exec() || !query.isActive())
37+    {
38+        MythDB::DBError("Video hashed metadata update (filemarkup)", query);
39         return -1;
40     }
41