Index: libs/libmythtv/datadirect.cpp
===================================================================
--- libs/libmythtv/datadirect.cpp	(revision 14240)
+++ libs/libmythtv/datadirect.cpp	(working copy)
@@ -1099,10 +1099,14 @@
 
         if (ok)
         {
-            if (copy(out, in))
+            ok = copy(out, in);
+            in.close();
+            pclose(fp);
+
+            if (ok)
             {
-                pclose(fp);
                 fp = fopen(cache_dd_data.ascii(), "r");
+                VERBOSE(VB_IMPORTANT, "fp("<<cache_dd_data.ascii()<<"): "<<fp);
             }
             else
             {
@@ -1110,7 +1114,6 @@
                         LOC_ERR + "Failed to save DD cache! "
                         "redownloading data...");
                 cachedata = false;
-                pclose(fp);
                 fp = DDPost(ddurl, GetPostFilename(), inputfile,
                             GetUserID(), GetPassword(),
                             pstartDate, pendDate, err);
@@ -1118,6 +1121,14 @@
         }
     }
 
+    if (!fp)
+    {
+        VERBOSE(VB_IMPORTANT, LOC_ERR + "Failed to get data 2 " +
+                QString("(%1) -- ").arg(err) + ENO);
+        return false;
+    }
+
+    bool ok = true;
     QFile f;
     if (f.open(IO_ReadOnly, fp)) 
     {
@@ -1131,11 +1142,15 @@
     else
     {
         VERBOSE(VB_GENERAL, LOC_ERR + "Error opening DataDirect file");
-        pclose(fp);
-        fp = NULL;
+        ok = false;
     }
 
-    return fp;
+    if (!cachedata && inputfile.isEmpty())
+        pclose(fp);
+    else
+        fclose(fp);
+
+    return ok;
 }
 
 bool DataDirectProcessor::GrabLineupsOnly(void)
Index: libs/libmyth/util.cpp
===================================================================
--- libs/libmyth/util.cpp	(revision 14240)
+++ libs/libmyth/util.cpp	(working copy)
@@ -605,7 +605,7 @@
     return false;
 }
 
-/** \fn  Copy(QFile&,QFile&,uint)
+/** \fn copy(QFile&,QFile&,uint)
  *  \brief Copies src file to dst file.
  *
  *   If the dst file is open, it must be open for writing.
@@ -636,10 +636,16 @@
         return -1LL;
 
     if (!dst.isWritable() && !dst.isOpen())
+    {
         odst = dst.open(IO_Raw|IO_WriteOnly|IO_Truncate);
+        VERBOSE(VB_IMPORTANT, "copy: opening dst ("<<odst<<")");
+    }
 
     if (!src.isReadable() && !src.isOpen())
+    {
         osrc = src.open(IO_Raw|IO_ReadOnly);
+        VERBOSE(VB_IMPORTANT, "copy: opened src ("<<osrc<<")");
+    }
 
     bool ok = dst.isWritable() && src.isReadable();
     long long total_bytes = 0LL;
@@ -649,6 +655,7 @@
         rlen = src.readBlock(buf, buflen);
         if (rlen<0)
         {
+            VERBOSE(VB_IMPORTANT, "copy: read error");
             ok = false;
             break;
         }
@@ -663,16 +670,27 @@
             if (wlen>=0)
                 off+= wlen;
             if (wlen<0)
+            {
+                VERBOSE(VB_IMPORTANT, "copy: write error");
                 ok = false;
+            }
         }
     }
     delete[] buf;
 
+    VERBOSE(VB_IMPORTANT, "copy: "<<((ok)?"ok":"error"));
+
     if (odst)
+    {
+        VERBOSE(VB_IMPORTANT, "copy: closing dst");
         dst.close();
+    }
 
     if (osrc)
+    {
+        VERBOSE(VB_IMPORTANT, "copy: closing src");
         src.close();
+    }
 
     return (ok) ? total_bytes : -1LL;
 }
Index: libs/libmyth/util.h
===================================================================
--- libs/libmyth/util.h	(revision 14240)
+++ libs/libmyth/util.h	(working copy)
@@ -75,7 +75,7 @@
 MPUBLIC bool telnet(const QString &host, int port);
 
 MPUBLIC long long copy(QFile &dst, QFile &src, uint block_size = 0);
-MPUBLIC QString createTempFile(QString name_template = "/tmp/mythtv_XXXXX",
+MPUBLIC QString createTempFile(QString name_template = "/tmp/mythtv_XXXXXX",
                                bool dir = false);
 
 #endif // UTIL_H_
