QSqlQuery addUnknownFileQuery;
QSqlQuery getUnknownFileQuery;
+ QSqlQuery getUnknownFileByPathQuery;
QSqlQuery removeUnknownFileQuery;
QSqlQuery addPendingRequestQuery;
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);
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");
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);
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));