From f5ee751374b4369ff6cf653131624839704a3e2e Mon Sep 17 00:00:00 2001 From: Martchus Date: Wed, 22 Mar 2017 21:22:30 +0100 Subject: [PATCH] cli: Allow rescanning sub dir/file --- CMakeLists.txt | 4 ++-- cli/application.cpp | 15 +++++++++++---- 2 files changed, 13 insertions(+), 6 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index a65a7a2..d2b0f82 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -8,8 +8,8 @@ set(META_APP_URL "https://github.com/${META_APP_AUTHOR}/${META_PROJECT_NAME}") set(META_APP_DESCRIPTION "Tray application for Syncthing") set(META_APP_CATEGORIES "System;Utility;Network;FileTransfer") set(META_VERSION_MAJOR 0) -set(META_VERSION_MINOR 5) -set(META_VERSION_PATCH 1) +set(META_VERSION_MINOR 6) +set(META_VERSION_PATCH 0) set(META_VERSION_EXACT_SONAME ON) project(${META_PROJECT_NAME}) diff --git a/cli/application.cpp b/cli/application.cpp index 500d887..45386ce 100644 --- a/cli/application.cpp +++ b/cli/application.cpp @@ -35,13 +35,13 @@ void exitApplication(int statusCode) terminated = true; } -inline QString argToQString(const char *arg) +inline QString argToQString(const char *arg, int size = -1) { #if !defined(PLATFORM_WINDOWS) - return QString::fromLocal8Bit(arg); + return QString::fromLocal8Bit(arg, size); #else // under Windows args are converted to UTF-8 - return QString::fromUtf8(arg); + return QString::fromUtf8(arg, size); #endif } @@ -230,7 +230,14 @@ void Application::requestRescan(const ArgumentOccurrence &occurrence) connect(&m_connection, &SyncthingConnection::rescanTriggered, this, &Application::handleResponse); for(const char *value : occurrence.values) { cerr << "Request rescanning " << value << " ...\n"; - m_connection.rescan(argToQString(value)); + // split into directory name and relpath + const char *firstSlash = value; + for(; *firstSlash && *firstSlash != '/'; ++firstSlash); + if(*firstSlash) { + m_connection.rescan(argToQString(value, static_cast(firstSlash - value)), argToQString(firstSlash + 1)); + } else { + m_connection.rescan(argToQString(value)); + } } cerr.flush(); }