[mythtv] Read Only backend

Yan-Fa Li yanfali at gmail.com
Mon Aug 15 02:07:57 UTC 2005


Hello,

I have a backend slave that I use for long term archival storage of
video that has more disk space than my recording backend and I want to
designate it as read-only as it doesn't have any capture devices and
only streams video to frontends.  This works out of the box by
adjusting the host location of the video to the new host in the DB.  I
do have to modify the job queue settings to ignore this backend
otherwise it gets scheduled for jobs which fail as the archival host
doesn't share disk space with the other backend.

However, one minor irritation is that it reports the free disk space
on this "archival" system, which means I can't really tell how much
free space is actually available for recording.
I came up with a patch that fixes this for me, but I'm not a CPP
programmer and am not sure this is the right way to do this or even
something anyone but me wants.

Here's the patch anyhow, and somebody who knows how to do this
properly might want to use the idea.  I simply piggyback off the
settings table and add another key called ReadOnly.  If it's not set,
I just ignore it and do the normal behavior.  Context diff against
0.18.1 follows:

--- mainserver.cpp      2005-04-13 14:04:28.000000000 -0700
+++ /root/mythtv-0.18.1/programs/mythbackend/mainserver.cpp     2005-08-14 18:46
:39.000000000 -0700
@@ -1660,12 +1660,29 @@
 
 void MainServer::HandleQueryFreeSpace(PlaybackSock *pbs)
 {
+    QString slave = gContext->GetHostName();
+    bool readonly = false;
+    MSqlQuery query(MSqlQuery::InitCon());
+    query.prepare("SELECT data FROM settings "
+                 "WHERE hostname = :HOSTNAME AND value = 'ReadOnly';");
+    query.bindValue(":HOSTNAME", slave);
+
+    if (query.exec() && query.isActive() && query.size())
+    {
+        query.next();
+        readonly = query.value(0).toString() == "true";
+    }
+
     QSocket *pbssock = pbs->getSocket();
 
     int totalspace = -1, usedspace = -1;
 
     getFreeSpace(totalspace, usedspace);
 
+    if (readonly) {
+       totalspace = usedspace;
+    }
+
     QStringList strlist;
     strlist << QString::number(totalspace) << QString::number(usedspace);
     SendResponse(pbssock, strlist);


More information about the mythtv-dev mailing list