Ticket #3842: 3842-head-dbg-2.patch

File 3842-head-dbg-2.patch, 3.8 KB (added by danielk, 18 years ago)

New dbg patch

  • libs/libmythtv/datadirect.cpp

     
    10991099
    11001100        if (ok)
    11011101        {
    1102             if (copy(out, in))
     1102            ok = copy(out, in);
     1103            in.close();
     1104            pclose(fp);
     1105
     1106            if (ok)
    11031107            {
    1104                 pclose(fp);
    11051108                fp = fopen(cache_dd_data.ascii(), "r");
     1109                VERBOSE(VB_IMPORTANT, "fp("<<cache_dd_data.ascii()<<"): "<<fp);
    11061110            }
    11071111            else
    11081112            {
     
    11101114                        LOC_ERR + "Failed to save DD cache! "
    11111115                        "redownloading data...");
    11121116                cachedata = false;
    1113                 pclose(fp);
    11141117                fp = DDPost(ddurl, GetPostFilename(), inputfile,
    11151118                            GetUserID(), GetPassword(),
    11161119                            pstartDate, pendDate, err);
     
    11181121        }
    11191122    }
    11201123
     1124    if (!fp)
     1125    {
     1126        VERBOSE(VB_IMPORTANT, LOC_ERR + "Failed to get data 2 " +
     1127                QString("(%1) -- ").arg(err) + ENO);
     1128        return false;
     1129    }
     1130
     1131    bool ok = true;
    11211132    QFile f;
    11221133    if (f.open(IO_ReadOnly, fp))
    11231134    {
     
    11311142    else
    11321143    {
    11331144        VERBOSE(VB_GENERAL, LOC_ERR + "Error opening DataDirect file");
    1134         pclose(fp);
    1135         fp = NULL;
     1145        ok = false;
    11361146    }
    11371147
    1138     return fp;
     1148    if (!cachedata && inputfile.isEmpty())
     1149        pclose(fp);
     1150    else
     1151        fclose(fp);
     1152
     1153    return ok;
    11391154}
    11401155
    11411156bool DataDirectProcessor::GrabLineupsOnly(void)
  • libs/libmyth/util.cpp

     
    605605    return false;
    606606}
    607607
    608 /** \fn  Copy(QFile&,QFile&,uint)
     608/** \fn copy(QFile&,QFile&,uint)
    609609 *  \brief Copies src file to dst file.
    610610 *
    611611 *   If the dst file is open, it must be open for writing.
     
    636636        return -1LL;
    637637
    638638    if (!dst.isWritable() && !dst.isOpen())
     639    {
    639640        odst = dst.open(IO_Raw|IO_WriteOnly|IO_Truncate);
     641        VERBOSE(VB_IMPORTANT, "copy: opening dst ("<<odst<<")");
     642    }
    640643
    641644    if (!src.isReadable() && !src.isOpen())
     645    {
    642646        osrc = src.open(IO_Raw|IO_ReadOnly);
     647        VERBOSE(VB_IMPORTANT, "copy: opened src ("<<osrc<<")");
     648    }
    643649
    644650    bool ok = dst.isWritable() && src.isReadable();
    645651    long long total_bytes = 0LL;
     
    649655        rlen = src.readBlock(buf, buflen);
    650656        if (rlen<0)
    651657        {
     658            VERBOSE(VB_IMPORTANT, "copy: read error");
    652659            ok = false;
    653660            break;
    654661        }
     
    663670            if (wlen>=0)
    664671                off+= wlen;
    665672            if (wlen<0)
     673            {
     674                VERBOSE(VB_IMPORTANT, "copy: write error");
    666675                ok = false;
     676            }
    667677        }
    668678    }
    669679    delete[] buf;
    670680
     681    VERBOSE(VB_IMPORTANT, "copy: "<<((ok)?"ok":"error"));
     682
    671683    if (odst)
     684    {
     685        VERBOSE(VB_IMPORTANT, "copy: closing dst");
    672686        dst.close();
     687    }
    673688
    674689    if (osrc)
     690    {
     691        VERBOSE(VB_IMPORTANT, "copy: closing src");
    675692        src.close();
     693    }
    676694
    677695    return (ok) ? total_bytes : -1LL;
    678696}
  • libs/libmyth/util.h

     
    7575MPUBLIC bool telnet(const QString &host, int port);
    7676
    7777MPUBLIC long long copy(QFile &dst, QFile &src, uint block_size = 0);
    78 MPUBLIC QString createTempFile(QString name_template = "/tmp/mythtv_XXXXX",
     78MPUBLIC QString createTempFile(QString name_template = "/tmp/mythtv_XXXXXX",
    7979                               bool dir = false);
    8080
    8181#endif // UTIL_H_