]> Some of my projects - localmylist.git/commitdiff
When skipping known files, also skip files in unknown_files.
authorAPTX <marek321@gmail.com>
Tue, 19 Jun 2012 17:48:04 +0000 (19:48 +0200)
committerAPTX <marek321@gmail.com>
Tue, 19 Jun 2012 17:48:04 +0000 (19:48 +0200)
localmylist/database.cpp
localmylist/database.h
localmylist/directoryscantask.cpp

index 3f7047d0de103d0a9075f0e20553eb5595268869..277af1d3938474fd38178544be5a83ea42912759 100644 (file)
@@ -142,6 +142,7 @@ struct DatabaseInternal
 
        QSqlQuery addUnknownFileQuery;
        QSqlQuery getUnknownFileQuery;
+       QSqlQuery getUnknownFileByPathQuery;
        QSqlQuery removeUnknownFileQuery;
 
        QSqlQuery addPendingRequestQuery;
@@ -684,6 +685,27 @@ UnknownFile Database::getUnknownFile(const QByteArray &ed2k, qint64 size)
        return f;
 }
 
+UnknownFile Database::getUnknownFilebyPath(const QString &path)
+{
+       d->getUnknownFileByPathQuery.bindValue(":path", path);
+
+       if (!exec(d->getUnknownFileByPathQuery))
+               return UnknownFile();
+
+       UnknownFile f;
+
+       if (d->getUnknownFileByPathQuery.next())
+       {
+               f.ed2k = d->getUnknownFileByPathQuery.value(0).toByteArray();
+               f.size = d->getUnknownFileByPathQuery.value(1).toLongLong();
+               f.hostId = d->getUnknownFileByPathQuery.value(2).toInt();
+               f.path = d->getUnknownFileByPathQuery.value(3).toString();
+       }
+       d->getUnknownFileByPathQuery.finish();
+
+       return f;
+}
+
 bool Database::removeUnknownFile(const QByteArray &ed2k, qint64 size)
 {
        d->removeUnknownFileQuery.bindValue(":ed2k", ed2k);
@@ -1078,6 +1100,7 @@ void Database::prepareQueries()
 
        d->getUnknownFileQuery = QSqlQuery(d->db);
        d->getUnknownFileQuery.prepare("SELECT ed2k, size, host_id, path FROM unknown_file WHERE ed2k = :ed2k AND size = :size");
+       d->getUnknownFileByPathQuery.prepare("SELECT ed2k, size, host_id, path FROM unknown_file WHERE path = :path");
 
        d->removeUnknownFileQuery = QSqlQuery(d->db);
        d->removeUnknownFileQuery.prepare("DELETE FROM unknown_file WHERE ed2k = :ed2k AND size = :size");
index 780e4ddde0a0fc27145eda6e90982a3ce91793fe..c791b8f18565f1689411e09cb930b419c94144c0 100644 (file)
@@ -246,6 +246,7 @@ public:
 
        bool addUnknownFile(const UnknownFile &file);
        UnknownFile getUnknownFile(const QByteArray &ed2k, qint64 size);
+       UnknownFile getUnknownFilebyPath(const QString &path);
        bool removeUnknownFile(const QByteArray &ed2k, qint64 size);
 
        bool addRequest(const PendingRequest &request);
index d402013ef053d5355a37468b416c92c2bae946bc..d2fa177f018d504003409848901991aa8516a880 100644 (file)
@@ -90,6 +90,10 @@ void DirectoryScanTask::workUnit()
                                        File f = db->getFileByPath(entry.canonicalFilePath());
                                        if (f.fid)
                                                continue;
+
+                                       UnknownFile uf = db->getUnknownFilebyPath(entry.canonicalFilePath());
+                                       if (!uf.ed2k.isEmpty() && uf.size)
+                                               continue;
                                }
 
                                QMetaObject::invokeMethod(MyList::instance(), "addFile", Qt::QueuedConnection, Q_ARG(QFileInfo, entry));