mirror of
https://github.com/nextcloud/desktop.git
synced 2025-10-26 11:17:43 +00:00
OwncloudCmd: Print update phase duration values
This commit is contained in:
parent
fcc0e89044
commit
63083a558b
@ -439,6 +439,7 @@ endif()
|
||||
|
||||
set(owncloudcmd_NAME ${APPLICATION_EXECUTABLE}cmd)
|
||||
set(OWNCLOUDCMD_SRC owncloudcmd/owncloudcmd.cpp)
|
||||
qt_wrap_cpp(OWNCLOUDCMD_MOCS owncloudcmd/owncloudcmd.cpp)
|
||||
add_executable(${owncloudcmd_NAME} ${OWNCLOUDCMD_SRC})
|
||||
qt5_use_modules(${owncloudcmd_NAME} Network Sql)
|
||||
set_target_properties(${owncloudcmd_NAME} PROPERTIES
|
||||
|
||||
@ -411,19 +411,21 @@ void CSyncThread::handleSyncError(CSYNC *ctx, const char *state) {
|
||||
|
||||
static void updater_progress_callback(CSYNC_PROGRESS *progress, void *userdata)
|
||||
{
|
||||
static QElapsedTimer localTimer;
|
||||
static QElapsedTimer remoteTimer;
|
||||
Progress::Info pInfo;
|
||||
if (progress->kind == CSYNC_NOTIFY_START_LOCAL_UPDATE) {
|
||||
localTimer.start();
|
||||
pInfo.kind = Progress::StartLocalUpdate;
|
||||
} else if (progress->kind == CSYNC_NOTIFY_FINISHED_LOCAL_UPDATE) {
|
||||
// There is also localTimer.nsecsElapsed()
|
||||
qDebug() << "Local Update took" << localTimer.elapsed() << "msec";
|
||||
pInfo.kind = Progress::EndLocalUpdate;
|
||||
} else if (progress->kind == CSYNC_NOTIFY_START_REMOTE_UPDATE) {
|
||||
remoteTimer.start();
|
||||
pInfo.kind = Progress::StartRemoteUpdate;
|
||||
} else if (progress->kind == CSYNC_NOTIFY_FINISHED_REMOTE_UPDATE) {
|
||||
qDebug() << "Remote Update took" << remoteTimer.elapsed() << "msec";
|
||||
pInfo.kind = Progress::EndRemoteUpdate;
|
||||
} else {
|
||||
return; // FIXME, but most progress stuff should come from the new propagator
|
||||
}
|
||||
|
||||
pInfo.timestamp = QDateTime::currentDateTime();
|
||||
CSyncThread *self = static_cast<CSyncThread*>(userdata);
|
||||
emit self->transmissionProgress( pInfo );
|
||||
}
|
||||
|
||||
void CSyncThread::startSync()
|
||||
@ -506,7 +508,7 @@ void CSyncThread::startSync()
|
||||
|
||||
// csync_set_auth_callback( _csync_ctx, getauth );
|
||||
csync_set_log_callback( csyncLogCatcher );
|
||||
csync_set_log_level( 11 );
|
||||
//csync_set_log_level( 11 ); don't set the loglevel here, it shall be done by folder.cpp or owncloudcmd.cpp
|
||||
|
||||
_syncTime.start();
|
||||
|
||||
|
||||
@ -64,6 +64,11 @@ QString Progress::asResultString( const Progress::Info& progress)
|
||||
case EndRename:
|
||||
re = QCoreApplication::translate( "progress", "Moved to %1").arg(progress.rename_target);
|
||||
break;
|
||||
case StartLocalUpdate:
|
||||
case EndLocalUpdate:
|
||||
case StartRemoteUpdate:
|
||||
case EndRemoteUpdate:
|
||||
break; // FIXME
|
||||
default:
|
||||
Q_ASSERT(false);
|
||||
}
|
||||
@ -118,6 +123,11 @@ QString Progress::asActionString( Kind kind )
|
||||
case EndRename:
|
||||
re = QCoreApplication::translate( "progress", "moved");
|
||||
break;
|
||||
case StartLocalUpdate:
|
||||
case EndLocalUpdate:
|
||||
case StartRemoteUpdate:
|
||||
case EndRemoteUpdate:
|
||||
break; // FIXME
|
||||
default:
|
||||
Q_ASSERT(false);
|
||||
}
|
||||
|
||||
@ -46,7 +46,11 @@ namespace Progress
|
||||
EndRename,
|
||||
SoftError,
|
||||
NormalError,
|
||||
FatalError
|
||||
FatalError,
|
||||
StartLocalUpdate,
|
||||
EndLocalUpdate,
|
||||
StartRemoteUpdate,
|
||||
EndRemoteUpdate
|
||||
};
|
||||
|
||||
struct Info {
|
||||
|
||||
@ -30,6 +30,29 @@
|
||||
|
||||
using namespace Mirall;
|
||||
|
||||
class OwncloudCmd : public QObject {
|
||||
Q_OBJECT
|
||||
public:
|
||||
OwncloudCmd() : QObject() { }
|
||||
public slots:
|
||||
void transmissionProgressSlot(Progress::Info pI) {
|
||||
static QElapsedTimer localTimer;
|
||||
static QElapsedTimer remoteTimer;
|
||||
if (pI.kind == Progress::StartLocalUpdate) {
|
||||
localTimer.start();
|
||||
} else if (pI.kind == Progress::EndLocalUpdate) {
|
||||
// There is also localTimer.nsecsElapsed()
|
||||
qDebug() << "Local Update took" << localTimer.elapsed() << "msec";
|
||||
} else if (pI.kind == Progress::StartRemoteUpdate) {
|
||||
remoteTimer.start();
|
||||
} else if (pI.kind == Progress::EndRemoteUpdate) {
|
||||
qDebug() << "Remote Update took" << remoteTimer.elapsed() << "msec";
|
||||
}
|
||||
}
|
||||
};
|
||||
#include "owncloudcmd/moc_owncloudcmd.cpp"
|
||||
|
||||
|
||||
int getauth(const char* prompt, char* buf, size_t len, int echo, int verify, void*)
|
||||
{
|
||||
std::cout << "** Authentication required: \n" << prompt << std::endl;
|
||||
@ -44,6 +67,7 @@ struct CmdOptions {
|
||||
QString target_url;
|
||||
QString config_directory;
|
||||
QString proxy;
|
||||
bool silent;
|
||||
};
|
||||
|
||||
void help()
|
||||
@ -56,6 +80,7 @@ void help()
|
||||
std::cout << "uses the setting from a configured sync client." << std::endl;
|
||||
std::cout << std::endl;
|
||||
std::cout << "Options:" << std::endl;
|
||||
std::cout << " --silent Don't be so verbose" << std::endl;
|
||||
std::cout << " --confdir = configdir: Read config from there." << std::endl;
|
||||
std::cout << " --httpproxy = proxy: Specify a http proxy to use." << std::endl;
|
||||
std::cout << " Proxy is http://server:port" << std::endl;
|
||||
@ -97,6 +122,8 @@ void parseOptions( const QStringList& app_args, CmdOptions *options )
|
||||
options->config_directory = it.next();
|
||||
} else if( option == "--httpproxy" && !it.peekNext().startsWith("-")) {
|
||||
options->proxy = it.next();
|
||||
} else if( option == "--silent") {
|
||||
options->silent = true;
|
||||
} else {
|
||||
help();
|
||||
}
|
||||
@ -126,7 +153,7 @@ int main(int argc, char **argv) {
|
||||
qFatal("ne_sock_init failed!");
|
||||
}
|
||||
|
||||
csync_set_log_level(11);
|
||||
csync_set_log_level(options.silent ? 1 : 11);
|
||||
csync_enable_conflictcopys(_csync_ctx);
|
||||
Logger::instance()->setLogFile("-");
|
||||
|
||||
@ -174,9 +201,12 @@ int main(int argc, char **argv) {
|
||||
clientProxy.setCSyncProxy(QUrl(url), _csync_ctx);
|
||||
}
|
||||
|
||||
OwncloudCmd owncloudCmd;
|
||||
|
||||
SyncJournalDb db(options.source_dir);
|
||||
CSyncThread csyncthread(_csync_ctx, options.source_dir, QUrl(options.target_url).path(), &db);
|
||||
QObject::connect(&csyncthread, SIGNAL(finished()), &app, SLOT(quit()));
|
||||
QObject::connect(&csyncthread, SIGNAL(transmissionProgress(Progress::Info)), &owncloudCmd, SLOT(transmissionProgressSlot(Progress::Info)));
|
||||
csyncthread.startSync();
|
||||
|
||||
app.exec();
|
||||
|
||||
Loading…
Reference in New Issue
Block a user