cli: Allow rescanning sub dir/file

This commit is contained in:
Martchus 2017-03-22 21:22:30 +01:00
parent 0d5f686185
commit f5ee751374
2 changed files with 13 additions and 6 deletions

View File

@ -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})

View File

@ -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<int>(firstSlash - value)), argToQString(firstSlash + 1));
} else {
m_connection.rescan(argToQString(value));
}
}
cerr.flush();
}