[Pkg-owncloud-commits] [owncloud-client] 217/470: Remove SocketApi::dbFileRecord_capi in favor of JournalDB::getFileRecord
Sandro Knauß
hefee-guest at moszumanska.debian.org
Thu May 12 16:25:05 UTC 2016
This is an automated email from the git hooks/post-receive script.
hefee-guest pushed a commit to branch master
in repository owncloud-client.
commit 6e16e34799d45fad4790d7bb5534322337fc8fb0
Author: Jocelyn Turcotte <jturcotte at woboq.com>
Date: Thu Mar 17 20:58:51 2016 +0100
Remove SocketApi::dbFileRecord_capi in favor of JournalDB::getFileRecord
---
src/gui/socketapi.cpp | 103 +++-----------------------------------------------
src/gui/socketapi.h | 5 ---
2 files changed, 5 insertions(+), 103 deletions(-)
diff --git a/src/gui/socketapi.cpp b/src/gui/socketapi.cpp
index 83c04b4..39dc40f 100644
--- a/src/gui/socketapi.cpp
+++ b/src/gui/socketapi.cpp
@@ -195,24 +195,8 @@ void SocketApi::slotRegisterPath( const QString& alias )
void SocketApi::slotUnregisterPath( const QString& alias )
{
Folder *f = FolderMan::instance()->folder(alias);
- if (f) {
+ if (f)
broadcastMessage(QLatin1String("UNREGISTER_PATH"), f->path(), QString::null, true );
-
- if( _dbQueries.contains(f)) {
- auto h = _dbQueries[f];
- if( h ) {
- h->finish();
- }
- _dbQueries.remove(f);
- }
- if( _openDbs.contains(f) ) {
- auto db = _openDbs[f];
- if( db ) {
- db->close();
- }
- _openDbs.remove(f);
- }
- }
}
void SocketApi::slotUpdateFolderView(Folder *f)
@@ -402,7 +386,7 @@ void SocketApi::command_SHARE(const QString& localFile, QIODevice* socket)
return;
}
- SyncJournalFileRecord rec = dbFileRecord_capi(shareFolder, localFileClean);
+ SyncJournalFileRecord rec = shareFolder->journalDb()->getFileRecord(localFileClean);
bool allowReshare = true; // lets assume the good
if( rec.isValid() ) {
@@ -494,83 +478,6 @@ QString SocketApi::buildRegisterPathMessage(const QString& path)
return message;
}
-SqlQuery* SocketApi::getSqlQuery( Folder *folder )
-{
- if( !folder ) {
- return 0;
- }
-
- if( _dbQueries.contains(folder) ) {
- return _dbQueries[folder].data();
- }
-
- /* No valid sql query object yet for this folder */
- int rc;
- const QString sql("SELECT inode, modtime, type, md5, fileid, remotePerm FROM "
- "metadata WHERE phash=?1");
- QString dbFileName = folder->journalDb()->databaseFilePath();
-
- QFileInfo fi(dbFileName);
- if( fi.exists() ) {
- auto db = QSharedPointer<SqlDatabase>::create();
-
- if( db && db->openReadOnly(dbFileName) ) {
- _openDbs.insert(folder, db);
-
- QSharedPointer<SqlQuery> query(new SqlQuery(*db));
- rc = query->prepare(sql);
-
- if( rc != SQLITE_OK ) {
- qDebug() << "Unable to prepare the query statement:" << rc;
- return 0; // do not insert into hash
- }
- _dbQueries.insert( folder, query);
- return query.data();
- } else {
- qDebug() << "Unable to open db" << dbFileName;
- }
- } else {
- qDebug() << Q_FUNC_INFO << "Journal to query does not yet exist.";
- }
- return 0;
-}
-
-SyncJournalFileRecord SocketApi::dbFileRecord_capi( Folder *folder, QString fileName )
-{
- if( !(folder && folder->journalDb()) ) {
- return SyncJournalFileRecord();
- }
-
- if( fileName.startsWith( folder->path() )) {
- fileName.remove(0, folder->path().length());
- }
-
- // remove trailing slash
- if( fileName.endsWith( QLatin1Char('/') ) ) {
- fileName.truncate(fileName.length()-1);
- }
- SqlQuery *query = getSqlQuery(folder);
- SyncJournalFileRecord rec;
-
- if( query ) {
- qlonglong phash = SyncJournalDb::getPHash( fileName );
- query->bindValue(1, phash);
- // int column_count = sqlite3_column_count(stmt);
-
- if (query->next()) {
- rec._path = fileName;
- rec._inode = query->int64Value(0);
- rec._modtime = Utility::qDateTimeFromTime_t( query->int64Value(1));
- rec._type = query->intValue(2);
- rec._etag = query->baValue(3);
- rec._fileId = query->baValue(4);
- rec._remotePerm = query->baValue(5);
- }
- query->reset_and_clear_bindings();
- }
- return rec;
-}
-
/**
* Get status about a single file.
*/
@@ -626,7 +533,7 @@ SyncFileStatus SocketApi::fileStatus(Folder *folder, const QString& systemFileNa
}
SyncFileStatus status(SyncFileStatus::STATUS_NONE);
- SyncJournalFileRecord rec = dbFileRecord_capi(folder, fileName );
+ SyncJournalFileRecord rec = folder->journalDb()->getFileRecord(fileName);
if (folder->estimateState(fileName, type, &status)) {
qDebug() << "Folder estimated status for" << fileName << "to" << status.toSocketAPIString();
@@ -686,14 +593,14 @@ SyncFileStatus SocketApi::fileStatus(Folder *folder, const QString& systemFileNa
// check the parent folder if it is shared and if it is allowed to create a file/dir within
QDir d( fi.path() );
auto parentPath = d.path();
- auto dirRec = dbFileRecord_capi(folder, parentPath);
+ auto dirRec = folder->journalDb()->getFileRecord(parentPath);
bool isDir = type == CSYNC_FTW_TYPE_DIR;
while( !d.isRoot() && !(d.exists() && dirRec.isValid()) ) {
d.cdUp(); // returns true if the dir exists.
parentPath = d.path();
// cut the folder path
- dirRec = dbFileRecord_capi(folder, parentPath);
+ dirRec = folder->journalDb()->getFileRecord(parentPath);
isDir = true;
}
diff --git a/src/gui/socketapi.h b/src/gui/socketapi.h
index f17660e..6e69c2e 100644
--- a/src/gui/socketapi.h
+++ b/src/gui/socketapi.h
@@ -17,7 +17,6 @@
#define SOCKETAPI_H
#include "syncfileitem.h"
-#include "syncjournalfilerecord.h"
#include "ownsql.h"
#if defined(Q_OS_MAC)
@@ -66,8 +65,6 @@ private slots:
private:
SyncFileStatus fileStatus(Folder *folder, const QString& systemFileName);
- SyncJournalFileRecord dbFileRecord_capi( Folder *folder, QString fileName );
- SqlQuery *getSqlQuery( Folder *folder );
void sendMessage(QIODevice* socket, const QString& message, bool doWait = false);
void broadcastMessage(const QString& verb, const QString &path, const QString &status = QString::null, bool doWait = false);
@@ -84,8 +81,6 @@ private:
QList<QIODevice*> _listeners;
SocketApiServer _localServer;
- QHash<Folder*, QSharedPointer<SqlQuery>> _dbQueries;
- QHash<Folder*, QSharedPointer<SqlDatabase>> _openDbs;
};
}
--
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/pkg-owncloud/owncloud-client.git
More information about the Pkg-owncloud-commits
mailing list