Comparar commits
1 Commits
| Autor | SHA1 | Data | |
|---|---|---|---|
| 0e58dd79da |
@@ -58,6 +58,9 @@ if( UNIX AND NOT APPLE )
|
||||
endif()
|
||||
####
|
||||
|
||||
# Enable Q_ASSERT etc. in all builds
|
||||
add_definitions( -DQT_FORCE_ASSERTS )
|
||||
|
||||
include(GNUInstallDirs)
|
||||
include(DefineInstallationPaths)
|
||||
include(GenerateExportHeader)
|
||||
|
||||
+4
-5
@@ -1,11 +1,10 @@
|
||||
ChangeLog
|
||||
=========
|
||||
|
||||
version 2.3.0 (2017-02-xx)
|
||||
* Decreased memory usage during sync
|
||||
* Overlay icons: Lower CPU usage
|
||||
* Allow to not sync the server's external storages by default
|
||||
* Switch Windows and OS X build to 5.6.2
|
||||
version 2.3.0 (2017-0x-xx)
|
||||
* WiP!
|
||||
* WiP Switch Windows and OS X build to 5.6.2
|
||||
* WiP Performance improvements for exclude detection
|
||||
* Switch to new ownCloud server WebDAV endpoint
|
||||
* Chunking NG: New file upload chunking algorithmn for ownCloud server 9.2
|
||||
* Allow to sync a folder to multiple different servers (Filename change from .csync_journal.db to _sync_$HASH.db)
|
||||
|
||||
+1
-1
@@ -5,7 +5,7 @@ set( MIRALL_VERSION_YEAR 2016 )
|
||||
set( MIRALL_SOVERSION 0 )
|
||||
|
||||
if ( NOT DEFINED MIRALL_VERSION_SUFFIX )
|
||||
set( MIRALL_VERSION_SUFFIX "beta1") #e.g. beta1, beta2, rc1
|
||||
set( MIRALL_VERSION_SUFFIX "git") #e.g. beta1, beta2, rc1
|
||||
endif( NOT DEFINED MIRALL_VERSION_SUFFIX )
|
||||
|
||||
if( NOT DEFINED MIRALL_VERSION_BUILD )
|
||||
|
||||
@@ -3,7 +3,7 @@ StrCpy $MUI_FINISHPAGE_SHOWREADME_TEXT_STRING "Показати примітки
|
||||
StrCpy $ConfirmEndProcess_MESSAGEBOX_TEXT "Знайдено процес(и) ${APPLICATION_EXECUTABLE}, які необхідно зупинити.$\nХочете щоб програма установки зробила це самостійно?"
|
||||
StrCpy $ConfirmEndProcess_KILLING_PROCESSES_TEXT "Завершення процесів ${APPLICATION_EXECUTABLE}."
|
||||
StrCpy $ConfirmEndProcess_KILL_NOT_FOUND_TEXT "Не знайдено процеси, які необхідно зупинити!"
|
||||
StrCpy $PageReinstall_NEW_Field_1 "У вашої системі встановлена застаріла версія додатку ${APPLICATION_NAME}. Рекомендуємо видалити її перед початком встановлення поточної версії. Оберіть подальшу дію та натисніть $\"Далі$\"."
|
||||
StrCpy $PageReinstall_NEW_Field_1 "Знайдено застарілу версію програми ${APPLICATION_NAME}. Рекомендуємо її спочатку видалити. Оберіть подальшу дію та натисніть $\"Далі$\"."
|
||||
StrCpy $PageReinstall_NEW_Field_2 "Видалити перед установкою"
|
||||
StrCpy $PageReinstall_NEW_Field_3 "Не видаляти"
|
||||
StrCpy $PageReinstall_NEW_MUI_HEADER_TEXT_TITLE "Установлено"
|
||||
|
||||
@@ -41,7 +41,7 @@ endif (MEM_NULL_TESTS)
|
||||
add_subdirectory(src)
|
||||
|
||||
if (UNIT_TESTING)
|
||||
set(WITH_TESTING ON)
|
||||
set(WITH_UNIT_TESTING ON)
|
||||
|
||||
find_package(CMocka)
|
||||
if (CMOCKA_FOUND)
|
||||
|
||||
@@ -26,4 +26,4 @@
|
||||
#cmakedefine HAVE___MINGW_ASPRINTF 1
|
||||
#cmakedefine HAVE_ASPRINTF 1
|
||||
|
||||
#cmakedefine WITH_TESTING 1
|
||||
#cmakedefine WITH_UNIT_TESTING 1
|
||||
|
||||
@@ -45,7 +45,7 @@
|
||||
#define CSYNC_LOG_CATEGORY_NAME "csync.exclude"
|
||||
#include "csync_log.h"
|
||||
|
||||
#ifndef WITH_TESTING
|
||||
#ifndef WITH_UNIT_TESTING
|
||||
static
|
||||
#endif
|
||||
int _csync_exclude_add(c_strlist_t **inList, const char *string) {
|
||||
|
||||
@@ -36,7 +36,7 @@ enum csync_exclude_type_e {
|
||||
};
|
||||
typedef enum csync_exclude_type_e CSYNC_EXCLUDE_TYPE;
|
||||
|
||||
#ifdef WITH_TESTING
|
||||
#ifdef WITH_UNIT_TESTING
|
||||
int OCSYNC_EXPORT _csync_exclude_add(c_strlist_t **inList, const char *string);
|
||||
#endif
|
||||
|
||||
|
||||
@@ -89,7 +89,7 @@ struct csync_s {
|
||||
|
||||
/* hooks for checking the white list (uses the update_callback_userdata) */
|
||||
int (*checkSelectiveSyncBlackListHook)(void*, const char*);
|
||||
int (*checkSelectiveSyncNewFolderHook)(void*, const char* /* path */, const char* /* remotePerm */);
|
||||
int (*checkSelectiveSyncNewFolderHook)(void*, const char*);
|
||||
|
||||
|
||||
csync_vio_opendir_hook remote_opendir_hook;
|
||||
|
||||
@@ -436,7 +436,7 @@ static int _csync_detect_update(CSYNC *ctx, const char *file,
|
||||
st->instruction = CSYNC_INSTRUCTION_NEW;
|
||||
|
||||
if (fs->type == CSYNC_VIO_FILE_TYPE_DIRECTORY && ctx->current == REMOTE_REPLICA && ctx->callbacks.checkSelectiveSyncNewFolderHook) {
|
||||
if (ctx->callbacks.checkSelectiveSyncNewFolderHook(ctx->callbacks.update_callback_userdata, path, fs->remotePerm)) {
|
||||
if (ctx->callbacks.checkSelectiveSyncNewFolderHook(ctx->callbacks.update_callback_userdata, path)) {
|
||||
csync_file_stat_free(st);
|
||||
return 1;
|
||||
}
|
||||
|
||||
@@ -50,21 +50,6 @@ Identifying Basic Functionality Problems
|
||||
As an example, after installing the ``cadaver`` app, you can issue the
|
||||
``propget`` command to obtain various properties pertaining to the current
|
||||
directory and also verify WebDAV server connection.
|
||||
|
||||
"CSync unknown error"
|
||||
---------------------
|
||||
|
||||
If you see this error message stop your client, delete the
|
||||
``.csync_journal.db`` file, and then restart your client.
|
||||
There is a ``.csync_journal.db`` file inside the folder of every account
|
||||
configured on your client.
|
||||
|
||||
.. NOTE::
|
||||
Please note that this will also erase some of your settings about which
|
||||
files to download.
|
||||
|
||||
See https://github.com/owncloud/client/issues/5226 for more discussion of this
|
||||
issue.
|
||||
|
||||
|
||||
Isolating other issues
|
||||
|
||||
+8
-58
@@ -652,51 +652,6 @@ X-GNOME-Autostart-Delay=3
|
||||
# Translations
|
||||
|
||||
|
||||
# Translations
|
||||
|
||||
|
||||
# Translations
|
||||
|
||||
|
||||
# Translations
|
||||
|
||||
|
||||
# Translations
|
||||
|
||||
|
||||
# Translations
|
||||
|
||||
|
||||
# Translations
|
||||
|
||||
|
||||
# Translations
|
||||
|
||||
|
||||
# Translations
|
||||
|
||||
|
||||
# Translations
|
||||
|
||||
|
||||
# Translations
|
||||
|
||||
|
||||
# Translations
|
||||
|
||||
|
||||
# Translations
|
||||
|
||||
|
||||
# Translations
|
||||
|
||||
|
||||
# Translations
|
||||
|
||||
|
||||
# Translations
|
||||
|
||||
|
||||
# Translations
|
||||
Comment[oc]=@APPLICATION_NAME@ sincronizacion del client
|
||||
GenericName[oc]=Dorsièr de Sincronizacion
|
||||
@@ -722,9 +677,7 @@ Comment[ja_JP]=@APPLICATION_NAME@ デスクトップ同期クライアント
|
||||
GenericName[ja_JP]=フォルダー同期
|
||||
Name[ja_JP]=@APPLICATION_NAME@ デスクトップ同期クライアント
|
||||
Icon[ja_JP]=@APPLICATION_EXECUTABLE@
|
||||
Comment[el]=@ΟΝΟΜΑ_ΕΦΑΡΜΟΓΗΣ@ συγχρονισμός επιφάνειας εργασίας πελάτη
|
||||
GenericName[el]=Συγχρονισμός φακέλου
|
||||
Name[el]=@ΟΝΟΜΑ_ΕΦΑΡΜΟΓΗΣ@ συγχρονισμός επιφάνειας εργασίας πελάτη
|
||||
Icon[el]=@APPLICATION_EXECUTABLE@
|
||||
Comment[en_GB]=@APPLICATION_NAME@ desktop synchronisation client
|
||||
GenericName[en_GB]=Folder Sync
|
||||
@@ -738,13 +691,10 @@ Comment[de_DE]=@APPLICATION_NAME@ Desktop-Synchronisationsclient
|
||||
GenericName[de_DE]=Ordner-Synchronisation
|
||||
Name[de_DE]=@APPLICATION_NAME@ Desktop-Synchronisationsclient
|
||||
Icon[de_DE]=@APPLICATION_EXECUTABLE@
|
||||
Comment[bg_BG]=@APPLICATION_NAME@ клиент за десктоп синхронизация
|
||||
GenericName[bg_BG]=Синхронизиране на папката
|
||||
Name[bg_BG]=@APPLICATION_NAME@ клиент десктоп синхронизация
|
||||
Icon[bg_BG]=@APPLICATION_EXECUTABLE@
|
||||
GenericName[fa]=همسان سازی پوشهها
|
||||
Name[fa]=@APPLICATION_EXECUTABLE@ نسخهی همسان سازی مشتری
|
||||
Icon[fa]=@APPLICATION_EXECUTABLE@
|
||||
Comment[pl]=@APPLICATION_NAME@ klient synchronizacji dla komputerów stacjonarnych
|
||||
GenericName[pl]=Folder Synchronizacji
|
||||
Name[pl]=@APPLICATION_NAME@ klient synchronizacji dla komputerów stacjonarnych
|
||||
Icon[pl]=@APPLICATION_EXECUTABLE@
|
||||
Comment[fr]=@APPLICATION_NAME@ synchronisation du client
|
||||
GenericName[fr]=Dossier de Synchronisation
|
||||
Name[fr]=@APPLICATION_NAME@ synchronisation du client
|
||||
@@ -780,10 +730,10 @@ Comment[et_EE]=@APPLICATION_NAME@ sünkroonimise klient töölauale
|
||||
GenericName[et_EE]=Kaustade sünkroonimine
|
||||
Name[et_EE]=@APPLICATION_NAME@ sünkroonimise klient töölauale
|
||||
Icon[et_EE]=@APPLICATION_EXECUTABLE@
|
||||
Comment[pl]=@APPLICATION_NAME@ klient synchronizacji dla komputerów stacjonarnych
|
||||
GenericName[pl]=Folder Synchronizacji
|
||||
Name[pl]=@APPLICATION_NAME@ klient synchronizacji dla komputerów stacjonarnych
|
||||
Icon[pl]=@APPLICATION_EXECUTABLE@
|
||||
Comment[bg_BG]=@APPLICATION_NAME@ клиент за десктоп синхронизация
|
||||
GenericName[bg_BG]=Синхронизиране на папката
|
||||
Name[bg_BG]=@APPLICATION_NAME@ клиент десктоп синхронизация
|
||||
Icon[bg_BG]=@APPLICATION_EXECUTABLE@
|
||||
Comment[pt_BR]=@APPLICATION_NAME@ cliente de sincronização do computador
|
||||
GenericName[pt_BR]=Sincronização de Pasta
|
||||
Name[pt_BR]=@APPLICATION_NAME@ cliente de sincronização de desktop
|
||||
|
||||
@@ -1,6 +1,8 @@
|
||||
project(cmd)
|
||||
set(CMAKE_AUTOMOC TRUE)
|
||||
|
||||
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fno-rtti")
|
||||
|
||||
set(cmd_NAME ${APPLICATION_EXECUTABLE}cmd)
|
||||
set(cmd_SRC
|
||||
cmd.cpp
|
||||
|
||||
@@ -3,6 +3,8 @@ set(CMAKE_AUTOMOC TRUE)
|
||||
|
||||
add_subdirectory(updater)
|
||||
|
||||
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fno-rtti")
|
||||
|
||||
#TODO Move resources files
|
||||
qt_add_resources(MIRALL_RC_SRC ../../client.qrc)
|
||||
if ( IS_DIRECTORY ${OEM_THEME_DIR} )
|
||||
|
||||
@@ -46,17 +46,11 @@ AccountManager *AccountManager::instance()
|
||||
bool AccountManager::restore()
|
||||
{
|
||||
auto settings = Utility::settingsWithGroup(QLatin1String(accountsC));
|
||||
if (settings->status() != QSettings::NoError) {
|
||||
qDebug() << "Could not read settings from" << settings->fileName()
|
||||
<< settings->status();
|
||||
return false;
|
||||
}
|
||||
|
||||
// If there are no accounts, check the old format.
|
||||
if (settings->childGroups().isEmpty()
|
||||
&& !settings->contains(QLatin1String(versionC))) {
|
||||
restoreFromLegacySettings();
|
||||
return true;
|
||||
return restoreFromLegacySettings();
|
||||
}
|
||||
|
||||
foreach (const auto& accountId, settings->childGroups()) {
|
||||
@@ -75,9 +69,6 @@ bool AccountManager::restore()
|
||||
|
||||
bool AccountManager::restoreFromLegacySettings()
|
||||
{
|
||||
qDebug() << "Migrate: restoreFromLegacySettings, checking settings group"
|
||||
<< Theme::instance()->appName();
|
||||
|
||||
// try to open the correctly themed settings
|
||||
auto settings = Utility::settingsWithGroup(Theme::instance()->appName());
|
||||
|
||||
@@ -95,7 +86,7 @@ bool AccountManager::restoreFromLegacySettings()
|
||||
|
||||
QFileInfo fi( oCCfgFile );
|
||||
if( fi.isReadable() ) {
|
||||
std::unique_ptr<QSettings> oCSettings(new QSettings(oCCfgFile, QSettings::IniFormat));
|
||||
QSettings *oCSettings = new QSettings(oCCfgFile, QSettings::IniFormat);
|
||||
oCSettings->beginGroup(QLatin1String("ownCloud"));
|
||||
|
||||
// Check the theme url to see if it is the same url that the oC config was for
|
||||
@@ -110,7 +101,9 @@ bool AccountManager::restoreFromLegacySettings()
|
||||
qDebug() << "Migrate oC config if " << oCUrl << " == " << overrideUrl << ":"
|
||||
<< (oCUrl == overrideUrl ? "Yes" : "No");
|
||||
if( oCUrl == overrideUrl ) {
|
||||
settings = std::move(oCSettings);
|
||||
settings.reset( oCSettings );
|
||||
} else {
|
||||
delete oCSettings;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -203,8 +196,8 @@ void AccountManager::saveAccountHelper(Account* acc, QSettings& settings, bool s
|
||||
if (acc->_am) {
|
||||
CookieJar* jar = qobject_cast<CookieJar*>(acc->_am->cookieJar());
|
||||
if (jar) {
|
||||
qDebug() << "Saving cookies." << acc->cookieJarPath();
|
||||
jar->save(acc->cookieJarPath());
|
||||
qDebug() << "Saving cookies.";
|
||||
jar->save();
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -296,8 +289,6 @@ void AccountManager::deleteAccount(AccountState* account)
|
||||
auto copy = *it; // keep a reference to the shared pointer so it does not delete it just yet
|
||||
_accounts.erase(it);
|
||||
|
||||
QFile::remove(account->account()->cookieJarPath());
|
||||
|
||||
auto settings = Utility::settingsWithGroup(QLatin1String(accountsC));
|
||||
settings->remove(account->account()->id());
|
||||
|
||||
|
||||
@@ -36,9 +36,7 @@ public:
|
||||
|
||||
/**
|
||||
* Creates account objects from a given settings file.
|
||||
*
|
||||
* Returns false if there was an error reading the settings,
|
||||
* but note that settings not existing is not an error.
|
||||
* return true if the account was restored
|
||||
*/
|
||||
bool restore();
|
||||
|
||||
|
||||
@@ -675,13 +675,8 @@ void AccountSettings::refreshSelectiveSyncStatus()
|
||||
ui->selectiveSyncButtons->setVisible(true);
|
||||
ui->bigFolderUi->setVisible(false);
|
||||
} else {
|
||||
ConfigFile cfg;
|
||||
QString info =
|
||||
!cfg.confirmExternalStorage() ? tr("There are folders that were not synchronized because they are too big: ") :
|
||||
!cfg.newBigFolderSizeLimit().first ? tr("There are folders that were not synchronized because they are external storages: ") :
|
||||
tr("There are folders that were not synchronized because they are too big or external storages: ");
|
||||
|
||||
ui->selectiveSyncNotification->setText(info + msg);
|
||||
QString wholeMsg = tr("There are new folders that were not synchronized because they are too big: ") + msg;
|
||||
ui->selectiveSyncNotification->setText(wholeMsg);
|
||||
ui->selectiveSyncButtons->setVisible(false);
|
||||
ui->bigFolderUi->setVisible(true);
|
||||
shouldBeVisible = true;
|
||||
|
||||
@@ -156,23 +156,7 @@ Application::Application(int &argc, char **argv) :
|
||||
|
||||
connect(this, SIGNAL(messageReceived(QString, QObject*)), SLOT(slotParseMessage(QString, QObject*)));
|
||||
|
||||
if (!AccountManager::instance()->restore()) {
|
||||
// If there is an error reading the account settings, try again
|
||||
// after a couple of seconds, if that fails, give up.
|
||||
// (non-existence is not an error)
|
||||
Utility::sleep(5);
|
||||
if (!AccountManager::instance()->restore()) {
|
||||
qDebug() << "Could not read the account settings, quitting";
|
||||
QMessageBox::critical(
|
||||
0,
|
||||
tr("Error accessing the configuration file"),
|
||||
tr("There was an error while accessing the configuration "
|
||||
"file at %1.").arg(ConfigFile().configFile()),
|
||||
tr("Quit ownCloud"));
|
||||
QTimer::singleShot(0, qApp, SLOT(quit()));
|
||||
return;
|
||||
}
|
||||
}
|
||||
AccountManager::instance()->restore();
|
||||
|
||||
FolderMan::instance()->setSyncEnabled(true);
|
||||
|
||||
|
||||
@@ -130,7 +130,7 @@ void ShibbolethCredentials::fetchFromKeychain()
|
||||
ReadPasswordJob *job = new ReadPasswordJob(Theme::instance()->appName());
|
||||
job->setSettings(Utility::settingsWithGroup(Theme::instance()->appName(), job).release());
|
||||
job->setInsecureFallback(false);
|
||||
job->setKey(keychainKey(_account->url().toString(), user()));
|
||||
job->setKey(keychainKey(_account->url().toString(), "shibAssertion"));
|
||||
connect(job, SIGNAL(finished(QKeychain::Job*)), SLOT(slotReadJobDone(QKeychain::Job*)));
|
||||
job->start();
|
||||
}
|
||||
@@ -309,7 +309,7 @@ void ShibbolethCredentials::storeShibCookie(const QNetworkCookie &cookie)
|
||||
job->setSettings(Utility::settingsWithGroup(Theme::instance()->appName(), job).release());
|
||||
// we don't really care if it works...
|
||||
//connect(job, SIGNAL(finished(QKeychain::Job*)), SLOT(slotWriteJobDone(QKeychain::Job*)));
|
||||
job->setKey(keychainKey(_account->url().toString(), user()));
|
||||
job->setKey(keychainKey(_account->url().toString(), "shibAssertion"));
|
||||
job->setTextData(QString::fromUtf8(cookie.toRawForm()));
|
||||
job->start();
|
||||
}
|
||||
@@ -318,7 +318,7 @@ void ShibbolethCredentials::removeShibCookie()
|
||||
{
|
||||
DeletePasswordJob *job = new DeletePasswordJob(Theme::instance()->appName());
|
||||
job->setSettings(Utility::settingsWithGroup(Theme::instance()->appName(), job).release());
|
||||
job->setKey(keychainKey(_account->url().toString(), user()));
|
||||
job->setKey(keychainKey(_account->url().toString(), "shibAssertion"));
|
||||
job->start();
|
||||
}
|
||||
|
||||
|
||||
+166
-70
@@ -52,6 +52,7 @@ Folder::Folder(const FolderDefinition& definition,
|
||||
: QObject(parent)
|
||||
, _accountState(accountState)
|
||||
, _definition(definition)
|
||||
, _csyncError(false)
|
||||
, _csyncUnavail(false)
|
||||
, _wipeDb(false)
|
||||
, _proxyDirty(true)
|
||||
@@ -86,6 +87,8 @@ Folder::Folder(const FolderDefinition& definition,
|
||||
|
||||
connect(_accountState.data(), SIGNAL(isConnectedChanged()), this, SIGNAL(canSyncChanged()));
|
||||
connect(_engine.data(), SIGNAL(rootEtag(QString)), this, SLOT(etagRetreivedFromSyncEngine(QString)));
|
||||
connect(_engine.data(), SIGNAL(treeWalkResult(const SyncFileItemVector&)),
|
||||
this, SLOT(slotThreadTreeWalkResult(const SyncFileItemVector&)), Qt::QueuedConnection);
|
||||
|
||||
connect(_engine.data(), SIGNAL(started()), SLOT(slotSyncStarted()), Qt::QueuedConnection);
|
||||
connect(_engine.data(), SIGNAL(finished(bool)), SLOT(slotSyncFinished(bool)), Qt::QueuedConnection);
|
||||
@@ -99,10 +102,9 @@ Folder::Folder(const FolderDefinition& definition,
|
||||
SLOT(slotAboutToRestoreBackup(bool*)));
|
||||
connect(_engine.data(), SIGNAL(folderDiscovered(bool,QString)), this, SLOT(slotFolderDiscovered(bool,QString)));
|
||||
connect(_engine.data(), SIGNAL(transmissionProgress(ProgressInfo)), this, SLOT(slotTransmissionProgress(ProgressInfo)));
|
||||
connect(_engine.data(), SIGNAL(itemCompleted(const SyncFileItemPtr &)),
|
||||
this, SLOT(slotItemCompleted(const SyncFileItemPtr &)));
|
||||
connect(_engine.data(), SIGNAL(newBigFolder(QString,bool)),
|
||||
this, SLOT(slotNewBigFolderDiscovered(QString,bool)));
|
||||
connect(_engine.data(), SIGNAL(itemCompleted(const SyncFileItem &, const PropagatorJob &)),
|
||||
this, SLOT(slotItemCompleted(const SyncFileItem &, const PropagatorJob &)));
|
||||
connect(_engine.data(), SIGNAL(newBigFolder(QString)), this, SLOT(slotNewBigFolderDiscovered(QString)));
|
||||
connect(_engine.data(), SIGNAL(seenLockedFile(QString)), FolderMan::instance(), SLOT(slotSyncOnceFileUnlocks(QString)));
|
||||
connect(_engine.data(), SIGNAL(aboutToPropagate(SyncFileItemVector&)),
|
||||
SLOT(slotLogPropagationStart()));
|
||||
@@ -136,13 +138,13 @@ void Folder::checkLocalPath()
|
||||
} else {
|
||||
// Check directory again
|
||||
if( !FileSystem::fileExists(_definition.localPath, fi) ) {
|
||||
_syncResult.appendErrorString(tr("Local folder %1 does not exist.").arg(_definition.localPath));
|
||||
_syncResult.setErrorString(tr("Local folder %1 does not exist.").arg(_definition.localPath));
|
||||
_syncResult.setStatus( SyncResult::SetupError );
|
||||
} else if( !fi.isDir() ) {
|
||||
_syncResult.appendErrorString(tr("%1 should be a folder but is not.").arg(_definition.localPath));
|
||||
_syncResult.setErrorString(tr("%1 should be a folder but is not.").arg(_definition.localPath));
|
||||
_syncResult.setStatus( SyncResult::SetupError );
|
||||
} else if( !fi.isReadable() ) {
|
||||
_syncResult.appendErrorString(tr("%1 is not readable.").arg(_definition.localPath));
|
||||
_syncResult.setErrorString(tr("%1 is not readable.").arg(_definition.localPath));
|
||||
_syncResult.setStatus( SyncResult::SetupError );
|
||||
}
|
||||
}
|
||||
@@ -265,8 +267,8 @@ SyncResult Folder::syncResult() const
|
||||
|
||||
void Folder::prepareToSync()
|
||||
{
|
||||
_syncResult.reset();
|
||||
_syncResult.setStatus( SyncResult::NotYetStarted );
|
||||
_syncResult.clearErrors();
|
||||
}
|
||||
|
||||
void Folder::slotRunEtagJob()
|
||||
@@ -320,33 +322,120 @@ void Folder::etagRetreivedFromSyncEngine(const QString& etag)
|
||||
}
|
||||
|
||||
|
||||
void Folder::showSyncResultPopup()
|
||||
void Folder::bubbleUpSyncResult()
|
||||
{
|
||||
if( _syncResult.firstItemNew() ) {
|
||||
createGuiLog( _syncResult.firstItemNew()->_file, LogStatusNew, _syncResult.numNewItems() );
|
||||
}
|
||||
if( _syncResult.firstItemDeleted() ) {
|
||||
createGuiLog( _syncResult.firstItemDeleted()->_file, LogStatusRemove, _syncResult.numRemovedItems() );
|
||||
}
|
||||
if( _syncResult.firstItemUpdated() ) {
|
||||
createGuiLog( _syncResult.firstItemUpdated()->_file, LogStatusUpdated, _syncResult.numUpdatedItems() );
|
||||
// count new, removed and updated items
|
||||
int newItems = 0;
|
||||
int removedItems = 0;
|
||||
int updatedItems = 0;
|
||||
int ignoredItems = 0;
|
||||
int renamedItems = 0;
|
||||
int conflictItems = 0;
|
||||
int errorItems = 0;
|
||||
|
||||
SyncFileItemPtr firstItemNew;
|
||||
SyncFileItemPtr firstItemDeleted;
|
||||
SyncFileItemPtr firstItemUpdated;
|
||||
SyncFileItemPtr firstItemRenamed;
|
||||
SyncFileItemPtr firstConflictItem;
|
||||
SyncFileItemPtr firstItemError;
|
||||
|
||||
QElapsedTimer timer;
|
||||
timer.start();
|
||||
|
||||
foreach (const SyncFileItemPtr &item, _syncResult.syncFileItemVector() ) {
|
||||
// Process the item to the gui
|
||||
if( item->_status == SyncFileItem::FatalError || item->_status == SyncFileItem::NormalError ) {
|
||||
//: this displays an error string (%2) for a file %1
|
||||
slotSyncError( tr("%1: %2").arg(item->_file, item->_errorString) );
|
||||
errorItems++;
|
||||
if (!firstItemError) {
|
||||
firstItemError = item;
|
||||
}
|
||||
} else if( item->_status == SyncFileItem::FileIgnored ) {
|
||||
// ignored files don't show up in notifications
|
||||
continue;
|
||||
} else if( item->_status == SyncFileItem::Conflict ) {
|
||||
conflictItems++;
|
||||
if (!firstConflictItem) {
|
||||
firstConflictItem = item;
|
||||
}
|
||||
} else {
|
||||
// add new directories or remove gone away dirs to the watcher
|
||||
if (item->_isDirectory && item->_instruction == CSYNC_INSTRUCTION_NEW ) {
|
||||
FolderMan::instance()->addMonitorPath( alias(), path()+item->_file );
|
||||
}
|
||||
if (item->_isDirectory && item->_instruction == CSYNC_INSTRUCTION_REMOVE ) {
|
||||
FolderMan::instance()->removeMonitorPath( alias(), path()+item->_file );
|
||||
}
|
||||
|
||||
if (!item->hasErrorStatus() && item->_direction == SyncFileItem::Down) {
|
||||
switch (item->_instruction) {
|
||||
case CSYNC_INSTRUCTION_NEW:
|
||||
case CSYNC_INSTRUCTION_TYPE_CHANGE:
|
||||
newItems++;
|
||||
if (!firstItemNew)
|
||||
firstItemNew = item;
|
||||
break;
|
||||
case CSYNC_INSTRUCTION_REMOVE:
|
||||
removedItems++;
|
||||
if (!firstItemDeleted)
|
||||
firstItemDeleted = item;
|
||||
break;
|
||||
case CSYNC_INSTRUCTION_SYNC:
|
||||
updatedItems++;
|
||||
if (!firstItemUpdated)
|
||||
firstItemUpdated = item;
|
||||
break;
|
||||
case CSYNC_INSTRUCTION_ERROR:
|
||||
qDebug() << "Got Instruction ERROR. " << _syncResult.errorString();
|
||||
break;
|
||||
case CSYNC_INSTRUCTION_RENAME:
|
||||
if (!firstItemRenamed) {
|
||||
firstItemRenamed = item;
|
||||
}
|
||||
renamedItems++;
|
||||
break;
|
||||
default:
|
||||
// nothing.
|
||||
break;
|
||||
}
|
||||
} else if( item->_direction == SyncFileItem::None ) { // ignored files counting.
|
||||
if( item->_instruction == CSYNC_INSTRUCTION_IGNORE ) {
|
||||
ignoredItems++;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if( _syncResult.firstItemRenamed() ) {
|
||||
qDebug() << "Processing result list and logging took " << timer.elapsed() << " Milliseconds.";
|
||||
_syncResult.setWarnCount(ignoredItems);
|
||||
|
||||
if( firstItemNew ) {
|
||||
createGuiLog( firstItemNew->_file, LogStatusNew, newItems );
|
||||
}
|
||||
if( firstItemDeleted ) {
|
||||
createGuiLog( firstItemDeleted->_file, LogStatusRemove, removedItems );
|
||||
}
|
||||
if( firstItemUpdated ) {
|
||||
createGuiLog( firstItemUpdated->_file, LogStatusUpdated, updatedItems );
|
||||
}
|
||||
|
||||
if( firstItemRenamed ) {
|
||||
LogStatus status(LogStatusRename);
|
||||
// if the path changes it's rather a move
|
||||
QDir renTarget = QFileInfo(_syncResult.firstItemRenamed()->_renameTarget).dir();
|
||||
QDir renSource = QFileInfo(_syncResult.firstItemRenamed()->_file).dir();
|
||||
QDir renTarget = QFileInfo(firstItemRenamed->_renameTarget).dir();
|
||||
QDir renSource = QFileInfo(firstItemRenamed->_file).dir();
|
||||
if(renTarget != renSource) {
|
||||
status = LogStatusMove;
|
||||
}
|
||||
createGuiLog( _syncResult.firstItemRenamed()->_originalFile, status, _syncResult.numRenamedItems(), _syncResult.firstItemRenamed()->_renameTarget );
|
||||
createGuiLog( firstItemRenamed->_originalFile, status, renamedItems, firstItemRenamed->_renameTarget );
|
||||
}
|
||||
|
||||
if( _syncResult.firstConflictItem() ) {
|
||||
createGuiLog( _syncResult.firstConflictItem()->_file, LogStatusConflict, _syncResult.numConflictItems() );
|
||||
if( firstConflictItem ) {
|
||||
createGuiLog( firstConflictItem->_file, LogStatusConflict, conflictItems );
|
||||
}
|
||||
createGuiLog( _syncResult.firstItemError()->_file, LogStatusError, _syncResult.numErrorItems() );
|
||||
createGuiLog( firstItemError->_file, LogStatusError, errorItems );
|
||||
|
||||
qDebug() << "OO folder slotSyncFinished: result: " << int(_syncResult.status());
|
||||
}
|
||||
@@ -485,6 +574,12 @@ void Folder::slotWatchedPathChanged(const QString& path)
|
||||
scheduleThisFolderSoon();
|
||||
}
|
||||
|
||||
void Folder::slotThreadTreeWalkResult(const SyncFileItemVector& items)
|
||||
{
|
||||
_syncResult.setSyncFileItemVector(items);
|
||||
}
|
||||
|
||||
|
||||
void Folder::saveToSettings() const
|
||||
{
|
||||
// Remove first to make sure we don't get duplicates
|
||||
@@ -547,6 +642,9 @@ void Folder::slotTerminateSync()
|
||||
if( _engine->isSyncRunning() ) {
|
||||
_engine->abort();
|
||||
|
||||
// Do not display an error message, user knows his own actions.
|
||||
// _errors.append( tr("The CSync thread terminated.") );
|
||||
// _csyncError = true;
|
||||
setSyncState(SyncResult::SyncAbortRequested);
|
||||
}
|
||||
}
|
||||
@@ -594,9 +692,10 @@ bool Folder::setIgnoredFiles()
|
||||
// a QSet of files to load.
|
||||
ConfigFile cfg;
|
||||
QString systemList = cfg.excludeFile(ConfigFile::SystemScope);
|
||||
qDebug() << "==== adding system ignore list to csync:" << systemList;
|
||||
_engine->excludedFiles().addExcludeFilePath(systemList);
|
||||
|
||||
if( QFile::exists(systemList) ) {
|
||||
qDebug() << "==== adding system ignore list to csync:" << systemList;
|
||||
_engine->excludedFiles().addExcludeFilePath(systemList);
|
||||
}
|
||||
QString userList = cfg.excludeFile(ConfigFile::UserScope);
|
||||
if( QFile::exists(userList) ) {
|
||||
qDebug() << "==== adding user defined ignore list to csync:" << userList;
|
||||
@@ -627,17 +726,19 @@ void Folder::startSync(const QStringList &pathList)
|
||||
qCritical() << "* ERROR csync is still running and new sync requested.";
|
||||
return;
|
||||
}
|
||||
_errors.clear();
|
||||
_csyncError = false;
|
||||
_csyncUnavail = false;
|
||||
|
||||
_timeSinceLastSyncStart.restart();
|
||||
_syncResult.clearErrors();
|
||||
_syncResult.setStatus( SyncResult::SyncPrepare );
|
||||
_syncResult.setSyncFileItemVector(SyncFileItemVector());
|
||||
emit syncStateChange();
|
||||
|
||||
qDebug() << "*** Start syncing " << remoteUrl().toString() << " - client version"
|
||||
<< qPrintable(Theme::instance()->version());
|
||||
|
||||
_fileLog->start(path());
|
||||
|
||||
if (!setIgnoredFiles())
|
||||
{
|
||||
slotSyncError(tr("Could not read system exclude file"));
|
||||
@@ -647,15 +748,15 @@ void Folder::startSync(const QStringList &pathList)
|
||||
|
||||
setDirtyNetworkLimits();
|
||||
|
||||
SyncOptions opt;
|
||||
ConfigFile cfgFile;
|
||||
auto newFolderLimit = cfgFile.newBigFolderSizeLimit();
|
||||
opt._newBigFolderSizeLimit = newFolderLimit.first ? newFolderLimit.second * 1000LL * 1000LL : -1; // convert from MB to B
|
||||
opt._confirmExternalStorage = cfgFile.confirmExternalStorage();
|
||||
_engine->setSyncOptions(opt);
|
||||
quint64 limit = newFolderLimit.first ? newFolderLimit.second * 1000 * 1000 : -1; // convert from MB to B
|
||||
_engine->setNewBigFolderSizeLimit(limit);
|
||||
|
||||
_engine->setIgnoreHiddenFiles(_definition.ignoreHiddenFiles);
|
||||
|
||||
_fileLog->start(path());
|
||||
|
||||
QMetaObject::invokeMethod(_engine.data(), "startSync", Qt::QueuedConnection);
|
||||
|
||||
emit syncStarted();
|
||||
@@ -686,7 +787,8 @@ void Folder::setDirtyNetworkLimits()
|
||||
|
||||
void Folder::slotSyncError(const QString& err)
|
||||
{
|
||||
_syncResult.appendErrorString(err);
|
||||
_errors.append( err );
|
||||
_csyncError = true;
|
||||
}
|
||||
|
||||
void Folder::slotSyncStarted()
|
||||
@@ -708,26 +810,29 @@ void Folder::slotSyncFinished(bool success)
|
||||
#if QT_VERSION >= QT_VERSION_CHECK(5,0,0)
|
||||
<< " SSL " << QSslSocket::sslLibraryVersionString().toUtf8().data()
|
||||
#endif
|
||||
;
|
||||
;
|
||||
|
||||
bool syncError = !_syncResult.errorStrings().isEmpty();
|
||||
if( syncError ) {
|
||||
qDebug() << "-> SyncEngine finished with ERROR";
|
||||
|
||||
if( _csyncError ) {
|
||||
qDebug() << "-> SyncEngine finished with ERROR, warn count is" << _syncResult.warnCount();
|
||||
} else {
|
||||
qDebug() << "-> SyncEngine finished without problem.";
|
||||
}
|
||||
_fileLog->finish();
|
||||
showSyncResultPopup();
|
||||
bubbleUpSyncResult();
|
||||
|
||||
auto anotherSyncNeeded = _engine->isAnotherSyncNeeded();
|
||||
|
||||
if (syncError) {
|
||||
if (_csyncError) {
|
||||
_syncResult.setStatus(SyncResult::Error);
|
||||
qDebug() << " ** error Strings: " << _errors;
|
||||
_syncResult.setErrorStrings( _errors );
|
||||
qDebug() << " * owncloud csync thread finished with error";
|
||||
} else if (_csyncUnavail) {
|
||||
_syncResult.setStatus(SyncResult::Error);
|
||||
qDebug() << " ** csync not available.";
|
||||
} else if( _syncResult.foundFilesNotSynced() ) {
|
||||
} else if( _syncResult.warnCount() > 0 ) {
|
||||
// there have been warnings on the way.
|
||||
_syncResult.setStatus(SyncResult::Problem);
|
||||
} else if( _definition.paused ) {
|
||||
// Maybe the sync was terminated because the user paused the folder
|
||||
@@ -804,28 +909,26 @@ void Folder::slotFolderDiscovered(bool, QString folderName)
|
||||
// and hand the result over to the progress dispatcher.
|
||||
void Folder::slotTransmissionProgress(const ProgressInfo &pi)
|
||||
{
|
||||
if( !pi.isUpdatingEstimates() ) {
|
||||
// this is the beginning of a sync, set the warning level to 0
|
||||
_syncResult.setWarnCount(0);
|
||||
}
|
||||
emit progressInfo(pi);
|
||||
ProgressDispatcher::instance()->setProgressInfo(alias(), pi);
|
||||
}
|
||||
|
||||
// a item is completed: count the errors and forward to the ProgressDispatcher
|
||||
void Folder::slotItemCompleted(const SyncFileItemPtr &item)
|
||||
void Folder::slotItemCompleted(const SyncFileItem &item, const PropagatorJob& job)
|
||||
{
|
||||
// add new directories or remove gone away dirs to the watcher
|
||||
if (item->_isDirectory && item->_instruction == CSYNC_INSTRUCTION_NEW ) {
|
||||
FolderMan::instance()->addMonitorPath( alias(), path()+item->_file );
|
||||
if (Progress::isWarningKind(item._status)) {
|
||||
// Count all error conditions.
|
||||
_syncResult.setWarnCount(_syncResult.warnCount()+1);
|
||||
}
|
||||
if (item->_isDirectory && item->_instruction == CSYNC_INSTRUCTION_REMOVE ) {
|
||||
FolderMan::instance()->removeMonitorPath( alias(), path()+item->_file );
|
||||
}
|
||||
|
||||
_syncResult.processCompletedItem(item);
|
||||
|
||||
_fileLog->logItem(*item);
|
||||
emit ProgressDispatcher::instance()->itemCompleted(alias(), item);
|
||||
_fileLog->logItem(item);
|
||||
emit ProgressDispatcher::instance()->itemCompleted(alias(), item, job);
|
||||
}
|
||||
|
||||
void Folder::slotNewBigFolderDiscovered(const QString &newF, bool isExternal)
|
||||
void Folder::slotNewBigFolderDiscovered(const QString &newF)
|
||||
{
|
||||
auto newFolder = newF;
|
||||
if (!newFolder.endsWith(QLatin1Char('/'))) {
|
||||
@@ -850,11 +953,9 @@ void Folder::slotNewBigFolderDiscovered(const QString &newF, bool isExternal)
|
||||
journal->setSelectiveSyncList(SyncJournalDb::SelectiveSyncUndecidedList, undecidedList);
|
||||
emit newBigFolderDiscovered(newFolder);
|
||||
}
|
||||
QString message = !isExternal ?
|
||||
(tr("A new folder larger than %1 MB has been added: %2.\n")
|
||||
.arg(ConfigFile().newBigFolderSizeLimit().second).arg(newF))
|
||||
: (tr("A folder from an external storage has been added.\n"));
|
||||
message += tr("Please go in the settings to select it if you wish to download it.");
|
||||
QString message = tr("A new folder larger than %1 MB has been added: %2.\n"
|
||||
"Please go in the settings to select it if you wish to download it.")
|
||||
.arg(ConfigFile().newBigFolderSizeLimit().second).arg(newF);
|
||||
|
||||
auto logger = Logger::instance();
|
||||
logger->postOptionalGuiLog(Theme::instance()->appNameGUI(), message);
|
||||
@@ -883,22 +984,17 @@ void Folder::setSaveBackwardsCompatible(bool save)
|
||||
_saveBackwardsCompatible = save;
|
||||
}
|
||||
|
||||
void Folder::slotAboutToRemoveAllFiles(SyncFileItem::Direction dir, bool *cancel)
|
||||
void Folder::slotAboutToRemoveAllFiles(SyncFileItem::Direction, bool *cancel)
|
||||
{
|
||||
ConfigFile cfgFile;
|
||||
if (!cfgFile.promptDeleteFiles())
|
||||
return;
|
||||
|
||||
QString msg = dir == SyncFileItem::Down ?
|
||||
tr("All files in the sync folder '%1' folder were deleted on the server.\n"
|
||||
"These deletes will be synchronized to your local sync folder, making such files "
|
||||
"unavailable unless you have a right to restore. \n"
|
||||
"If you decide to keep the files, they will be re-synced with the server if you have rights to do so.\n"
|
||||
"If you decide to delete the files, they will be unavailable to you, unless you are the owner.") :
|
||||
tr("All the files in your local sync folder '%1' were deleted. These deletes will be "
|
||||
"synchronized with your server, making such files unavailable unless restored.\n"
|
||||
"Are you sure you want to sync those actions with the server?\n"
|
||||
"If this was an accident and you decide to keep your files, they will be re-synced from the server.");
|
||||
QString msg =
|
||||
tr("This sync would remove all the files in the sync folder '%1'.\n"
|
||||
"This might be because the folder was silently reconfigured, or that all "
|
||||
"the files were manually removed.\n"
|
||||
"Are you sure you want to perform this operation?");
|
||||
QMessageBox msgBox(QMessageBox::Warning, tr("Remove All Files?"),
|
||||
msg.arg(shortGuiLocalPath()));
|
||||
msgBox.addButton(tr("Remove all files"), QMessageBox::DestructiveRole);
|
||||
|
||||
+7
-3
@@ -280,15 +280,17 @@ private slots:
|
||||
|
||||
void slotFolderDiscovered(bool local, QString folderName);
|
||||
void slotTransmissionProgress(const ProgressInfo& pi);
|
||||
void slotItemCompleted(const SyncFileItemPtr&);
|
||||
void slotItemCompleted(const SyncFileItem&, const PropagatorJob&);
|
||||
|
||||
void slotRunEtagJob();
|
||||
void etagRetreived(const QString &);
|
||||
void etagRetreivedFromSyncEngine(const QString &);
|
||||
|
||||
void slotThreadTreeWalkResult(const SyncFileItemVector& ); // after sync is done
|
||||
|
||||
void slotEmitFinishedDelayed();
|
||||
|
||||
void slotNewBigFolderDiscovered(const QString &, bool isExternal);
|
||||
void slotNewBigFolderDiscovered(const QString &);
|
||||
|
||||
void slotLogPropagationStart();
|
||||
|
||||
@@ -300,7 +302,7 @@ private slots:
|
||||
private:
|
||||
bool setIgnoredFiles();
|
||||
|
||||
void showSyncResultPopup();
|
||||
void bubbleUpSyncResult();
|
||||
|
||||
void checkLocalPath();
|
||||
|
||||
@@ -323,6 +325,8 @@ private:
|
||||
|
||||
SyncResult _syncResult;
|
||||
QScopedPointer<SyncEngine> _engine;
|
||||
QStringList _errors;
|
||||
bool _csyncError;
|
||||
bool _csyncUnavail;
|
||||
bool _wipeDb;
|
||||
bool _proxyDirty;
|
||||
|
||||
@@ -23,7 +23,6 @@
|
||||
#include "accountmanager.h"
|
||||
#include "filesystem.h"
|
||||
#include "lockwatcher.h"
|
||||
#include "asserts.h"
|
||||
#include <syncengine.h>
|
||||
|
||||
#ifdef Q_OS_MAC
|
||||
@@ -49,7 +48,7 @@ FolderMan::FolderMan(QObject *parent) :
|
||||
_lockWatcher(new LockWatcher),
|
||||
_appRestartRequired(false)
|
||||
{
|
||||
ASSERT(!_instance);
|
||||
Q_ASSERT(!_instance);
|
||||
_instance = this;
|
||||
|
||||
_socketApi.reset(new SocketApi);
|
||||
@@ -134,13 +133,12 @@ int FolderMan::unloadAndDeleteAllFolders()
|
||||
delete f;
|
||||
cnt++;
|
||||
}
|
||||
ASSERT(_folderMap.isEmpty());
|
||||
|
||||
_lastSyncFolder = 0;
|
||||
_currentSyncFolder = 0;
|
||||
_scheduledFolders.clear();
|
||||
emit scheduleQueueChanged();
|
||||
|
||||
Q_ASSERT(_folderMap.count() == 0);
|
||||
return cnt;
|
||||
}
|
||||
|
||||
@@ -262,6 +260,7 @@ int FolderMan::setupFoldersMigration()
|
||||
{
|
||||
ConfigFile cfg;
|
||||
QDir storageDir(cfg.configPath());
|
||||
storageDir.mkpath(QLatin1String("folders"));
|
||||
_folderConfigPath = cfg.configPath() + QLatin1String("folders");
|
||||
|
||||
qDebug() << "* Setup folders from " << _folderConfigPath << "(migration)";
|
||||
@@ -464,7 +463,7 @@ void FolderMan::slotFolderSyncPaused( Folder *f, bool paused )
|
||||
void FolderMan::slotFolderCanSyncChanged()
|
||||
{
|
||||
Folder *f = qobject_cast<Folder*>(sender());
|
||||
ASSERT(f);
|
||||
Q_ASSERT(f);
|
||||
if (f->canSync()) {
|
||||
_socketApi->slotRegisterPath(f->alias());
|
||||
} else {
|
||||
@@ -1122,7 +1121,7 @@ void FolderMan::setDirtyNetworkLimits()
|
||||
|
||||
SyncResult FolderMan::accountStatus(const QList<Folder*> &folders)
|
||||
{
|
||||
SyncResult overallResult;
|
||||
SyncResult overallResult(SyncResult::Undefined);
|
||||
|
||||
int cnt = folders.count();
|
||||
|
||||
@@ -1236,10 +1235,10 @@ SyncResult FolderMan::accountStatus(const QList<Folder*> &folders)
|
||||
return overallResult;
|
||||
}
|
||||
|
||||
QString FolderMan::statusToString( SyncResult::Status syncStatus, bool paused ) const
|
||||
QString FolderMan::statusToString( SyncResult syncStatus, bool paused ) const
|
||||
{
|
||||
QString folderMessage;
|
||||
switch( syncStatus ) {
|
||||
switch( syncStatus.status() ) {
|
||||
case SyncResult::Undefined:
|
||||
folderMessage = tr( "Undefined State." );
|
||||
break;
|
||||
|
||||
@@ -106,7 +106,7 @@ public:
|
||||
/** Creates a new and empty local directory. */
|
||||
bool startFromScratch( const QString& );
|
||||
|
||||
QString statusToString(SyncResult::Status, bool paused ) const;
|
||||
QString statusToString(SyncResult, bool paused ) const;
|
||||
|
||||
static SyncResult accountStatus( const QList<Folder*> &folders );
|
||||
|
||||
|
||||
@@ -16,7 +16,6 @@
|
||||
#include "folderman.h"
|
||||
#include "accountstate.h"
|
||||
#include "utility.h"
|
||||
#include "asserts.h"
|
||||
#include <theme.h>
|
||||
#include <account.h>
|
||||
#include "folderstatusdelegate.h"
|
||||
@@ -30,14 +29,6 @@ Q_DECLARE_METATYPE(QPersistentModelIndex)
|
||||
namespace OCC {
|
||||
|
||||
static const char propertyParentIndexC[] = "oc_parentIndex";
|
||||
static const char propertyPermissionMap[] = "oc_permissionMap";
|
||||
|
||||
static QString removeTrailingSlash(const QString &s) {
|
||||
if (s.endsWith('/')) {
|
||||
return s.left(s.size() - 1);
|
||||
}
|
||||
return s;
|
||||
}
|
||||
|
||||
FolderStatusModel::FolderStatusModel(QObject *parent)
|
||||
:QAbstractItemModel(parent), _accountState(0), _dirty(false)
|
||||
@@ -171,7 +162,7 @@ QVariant FolderStatusModel::data(const QModelIndex &index, int role) const
|
||||
case Qt::CheckStateRole:
|
||||
return x._checked;
|
||||
case Qt::DecorationRole:
|
||||
return QFileIconProvider().icon(x._isExternal ? QFileIconProvider::Network : QFileIconProvider::Folder);
|
||||
return QFileIconProvider().icon(QFileIconProvider::Folder);
|
||||
case Qt::ForegroundRole:
|
||||
if (x._isUndecided) {
|
||||
return QColor(Qt::red);
|
||||
@@ -377,9 +368,6 @@ FolderStatusModel::SubFolderInfo* FolderStatusModel::infoForIndex(const QModelIn
|
||||
if (parentInfo->hasLabel()) {
|
||||
return 0;
|
||||
}
|
||||
if (index.row() >= parentInfo->_subs.size()) {
|
||||
return 0;
|
||||
}
|
||||
return &parentInfo->_subs[index.row()];
|
||||
} else {
|
||||
if (index.row() >= _folders.count()) {
|
||||
@@ -481,14 +469,14 @@ QModelIndex FolderStatusModel::parent(const QModelIndex& child) const
|
||||
}
|
||||
auto pathIdx = static_cast<SubFolderInfo*>(child.internalPointer())->_pathIdx;
|
||||
int i = 1;
|
||||
ASSERT(pathIdx.at(0) < _folders.count());
|
||||
Q_ASSERT(pathIdx.at(0) < _folders.count());
|
||||
if (pathIdx.count() == 1) {
|
||||
return createIndex(pathIdx.at(0), 0/*, nullptr*/);
|
||||
}
|
||||
|
||||
const SubFolderInfo *info = &_folders[pathIdx.at(0)];
|
||||
while (i < pathIdx.count() - 1) {
|
||||
ASSERT(pathIdx.at(i) < info->_subs.count());
|
||||
Q_ASSERT(pathIdx.at(i) < info->_subs.count());
|
||||
info = &info->_subs[pathIdx.at(i)];
|
||||
++i;
|
||||
}
|
||||
@@ -549,15 +537,12 @@ void FolderStatusModel::fetchMore(const QModelIndex& parent)
|
||||
path += info->_path;
|
||||
}
|
||||
LsColJob *job = new LsColJob(_accountState->account(), path, this);
|
||||
job->setProperties(QList<QByteArray>() << "resourcetype" << "http://owncloud.org/ns:size" << "http://owncloud.org/ns:permissions");
|
||||
job->setProperties(QList<QByteArray>() << "resourcetype" << "http://owncloud.org/ns:size");
|
||||
job->setTimeout(60 * 1000);
|
||||
connect(job, SIGNAL(directoryListingSubfolders(QStringList)),
|
||||
SLOT(slotUpdateDirectories(QStringList)));
|
||||
connect(job, SIGNAL(finishedWithError(QNetworkReply*)),
|
||||
this, SLOT(slotLscolFinishedWithError(QNetworkReply*)));
|
||||
connect(job, SIGNAL(directoryListingIterated(const QString&, const QMap<QString,QString>&)),
|
||||
this, SLOT(slotGatherPermissions(const QString&, const QMap<QString,QString>&)));
|
||||
|
||||
job->start();
|
||||
|
||||
QPersistentModelIndex persistentIndex(parent);
|
||||
@@ -568,24 +553,10 @@ void FolderStatusModel::fetchMore(const QModelIndex& parent)
|
||||
QTimer::singleShot(1000, this, SLOT(slotShowFetchProgress()));
|
||||
}
|
||||
|
||||
void FolderStatusModel::slotGatherPermissions(const QString &href, const QMap<QString,QString> &map)
|
||||
{
|
||||
auto it = map.find("permissions");
|
||||
if (it == map.end())
|
||||
return;
|
||||
|
||||
auto job = sender();
|
||||
auto permissionMap = job->property(propertyPermissionMap).toMap();
|
||||
job->setProperty(propertyPermissionMap, QVariant()); // avoid a detach of the map while it is modified
|
||||
ASSERT(!href.endsWith(QLatin1Char('/')), "LsColXMLParser::parse should remove the trailing slash before calling us.");
|
||||
permissionMap[href] = *it;
|
||||
job->setProperty(propertyPermissionMap, permissionMap);
|
||||
}
|
||||
|
||||
void FolderStatusModel::slotUpdateDirectories(const QStringList &list)
|
||||
{
|
||||
auto job = qobject_cast<LsColJob *>(sender());
|
||||
ASSERT(job);
|
||||
Q_ASSERT(job);
|
||||
QModelIndex idx = qvariant_cast<QPersistentModelIndex>(job->property(propertyParentIndexC));
|
||||
auto parentInfo = infoForIndex(idx);
|
||||
if (!parentInfo) {
|
||||
@@ -627,7 +598,6 @@ void FolderStatusModel::slotUpdateDirectories(const QStringList &list)
|
||||
selectiveSyncUndecidedSet.insert(str);
|
||||
}
|
||||
}
|
||||
const auto permissionMap = job->property(propertyPermissionMap).toMap();
|
||||
|
||||
QStringList sortedSubfolders = list;
|
||||
// skip the parent item (first in the list)
|
||||
@@ -648,8 +618,8 @@ void FolderStatusModel::slotUpdateDirectories(const QStringList &list)
|
||||
newInfo._folder = parentInfo->_folder;
|
||||
newInfo._pathIdx = parentInfo->_pathIdx;
|
||||
newInfo._pathIdx << newSubs.size();
|
||||
newInfo._size = job->_sizes.value(path);
|
||||
newInfo._isExternal = permissionMap.value(removeTrailingSlash(path)).toString().contains("M");
|
||||
auto size = job ? job->_sizes.value(path) : 0;
|
||||
newInfo._size = size;
|
||||
newInfo._path = relativePath;
|
||||
newInfo._name = relativePath.split('/', QString::SkipEmptyParts).last();
|
||||
|
||||
@@ -716,7 +686,7 @@ void FolderStatusModel::slotUpdateDirectories(const QStringList &list)
|
||||
void FolderStatusModel::slotLscolFinishedWithError(QNetworkReply* r)
|
||||
{
|
||||
auto job = qobject_cast<LsColJob *>(sender());
|
||||
ASSERT(job);
|
||||
Q_ASSERT(job);
|
||||
QModelIndex idx = qvariant_cast<QPersistentModelIndex>(job->property(propertyParentIndexC));
|
||||
if (!idx.isValid()) {
|
||||
return;
|
||||
@@ -731,7 +701,7 @@ void FolderStatusModel::slotLscolFinishedWithError(QNetworkReply* r)
|
||||
if (r->error() == QNetworkReply::ContentNotFoundError) {
|
||||
parentInfo->_fetched = true;
|
||||
} else {
|
||||
ASSERT(!parentInfo->hasLabel());
|
||||
Q_ASSERT(!parentInfo->hasLabel());
|
||||
beginInsertRows(idx, 0, 0);
|
||||
parentInfo->_hasError = true;
|
||||
endInsertRows();
|
||||
@@ -1011,7 +981,7 @@ void FolderStatusModel::slotFolderSyncStateChange(Folder *f)
|
||||
auto& pi = _folders[folderIndex]._progress;
|
||||
|
||||
SyncResult::Status state = f->syncResult().status();
|
||||
if (!f->canSync()) {
|
||||
if (f->syncPaused()) {
|
||||
// Reset progress info.
|
||||
pi = SubFolderInfo::Progress();
|
||||
} else if (state == SyncResult::NotYetStarted) {
|
||||
@@ -1042,10 +1012,18 @@ void FolderStatusModel::slotFolderSyncStateChange(Folder *f)
|
||||
// update the icon etc. now
|
||||
slotUpdateFolderState(f);
|
||||
|
||||
if (state == SyncResult::Success && f->syncResult().folderStructureWasChanged()) {
|
||||
// There is a new or a removed folder. reset all data
|
||||
auto & info = _folders[folderIndex];
|
||||
info.resetSubs(this, index(folderIndex));
|
||||
if (state == SyncResult::Success) {
|
||||
foreach (const SyncFileItemPtr &i, f->syncResult().syncFileItemVector()) {
|
||||
if (i->_isDirectory && (i->_instruction == CSYNC_INSTRUCTION_NEW
|
||||
|| i->_instruction == CSYNC_INSTRUCTION_TYPE_CHANGE
|
||||
|| i->_instruction == CSYNC_INSTRUCTION_REMOVE
|
||||
|| i->_instruction == CSYNC_INSTRUCTION_RENAME)) {
|
||||
// There is a new or a removed folder. reset all data
|
||||
auto & info = _folders[folderIndex];
|
||||
info.resetSubs(this, index(folderIndex));
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1136,7 +1114,7 @@ void FolderStatusModel::slotSyncNoPendingBigFolders()
|
||||
void FolderStatusModel::slotNewBigFolder()
|
||||
{
|
||||
auto f = qobject_cast<Folder *>(sender());
|
||||
ASSERT(f);
|
||||
Q_ASSERT(f);
|
||||
|
||||
int folderIndex = -1;
|
||||
for (int i = 0; i < _folders.count(); ++i) {
|
||||
|
||||
@@ -51,7 +51,7 @@ public:
|
||||
|
||||
struct SubFolderInfo {
|
||||
SubFolderInfo()
|
||||
: _folder(0), _size(0), _isExternal(false), _fetched(false), _fetching(false),
|
||||
: _folder(0), _size(0), _fetched(false), _fetching(false),
|
||||
_hasError(false), _fetchingLabel(false), _isUndecided(false), _checked(Qt::Checked) {}
|
||||
Folder *_folder;
|
||||
QString _name;
|
||||
@@ -59,7 +59,6 @@ public:
|
||||
QVector<int> _pathIdx;
|
||||
QVector<SubFolderInfo> _subs;
|
||||
qint64 _size;
|
||||
bool _isExternal;
|
||||
|
||||
bool _fetched; // If we did the LSCOL for this folder already
|
||||
bool _fetching; // Whether a LSCOL job is currently running
|
||||
@@ -114,7 +113,6 @@ public slots:
|
||||
|
||||
private slots:
|
||||
void slotUpdateDirectories(const QStringList &);
|
||||
void slotGatherPermissions(const QString &name, const QMap<QString,QString> &properties);
|
||||
void slotLscolFinishedWithError(QNetworkReply *r);
|
||||
void slotFolderSyncStateChange(Folder* f);
|
||||
void slotFolderScheduleQueueChanged();
|
||||
|
||||
@@ -482,8 +482,9 @@ void FolderWizardRemotePath::showWarn( const QString& msg ) const
|
||||
FolderWizardSelectiveSync::FolderWizardSelectiveSync(const AccountPtr& account)
|
||||
{
|
||||
QVBoxLayout *layout = new QVBoxLayout(this);
|
||||
_selectiveSync = new SelectiveSyncWidget(account, this);
|
||||
layout->addWidget(_selectiveSync);
|
||||
_treeView = new SelectiveSyncTreeView(account, this);
|
||||
layout->addWidget(new QLabel(tr("Choose What to Sync: You can optionally deselect remote subfolders you do not wish to synchronize.")));
|
||||
layout->addWidget(_treeView);
|
||||
}
|
||||
|
||||
FolderWizardSelectiveSync::~FolderWizardSelectiveSync()
|
||||
@@ -500,17 +501,13 @@ void FolderWizardSelectiveSync::initializePage()
|
||||
QString alias = QFileInfo(targetPath).fileName();
|
||||
if (alias.isEmpty())
|
||||
alias = Theme::instance()->appName();
|
||||
QStringList initialBlacklist;
|
||||
if (Theme::instance()->wizardSelectiveSyncDefaultNothing()) {
|
||||
initialBlacklist = QStringList("/");
|
||||
}
|
||||
_selectiveSync->setFolderInfo(targetPath, alias, initialBlacklist);
|
||||
_treeView->setFolderInfo(targetPath, alias);
|
||||
QWizardPage::initializePage();
|
||||
}
|
||||
|
||||
bool FolderWizardSelectiveSync::validatePage()
|
||||
{
|
||||
wizard()->setProperty("selectiveSyncBlackList", QVariant(_selectiveSync->createBlackList()));
|
||||
wizard()->setProperty("selectiveSyncBlackList", QVariant(_treeView->createBlackList()));
|
||||
return true;
|
||||
}
|
||||
|
||||
@@ -520,7 +517,7 @@ void FolderWizardSelectiveSync::cleanupPage()
|
||||
QString alias = QFileInfo(targetPath).fileName();
|
||||
if (alias.isEmpty())
|
||||
alias = Theme::instance()->appName();
|
||||
_selectiveSync->setFolderInfo(targetPath, alias);
|
||||
_treeView->setFolderInfo(targetPath, alias);
|
||||
QWizardPage::cleanupPage();
|
||||
}
|
||||
|
||||
|
||||
@@ -27,7 +27,7 @@
|
||||
|
||||
namespace OCC {
|
||||
|
||||
class SelectiveSyncWidget;
|
||||
class SelectiveSyncTreeView;
|
||||
|
||||
class ownCloudInfo;
|
||||
|
||||
@@ -127,7 +127,7 @@ public:
|
||||
virtual void cleanupPage() Q_DECL_OVERRIDE;
|
||||
|
||||
private:
|
||||
SelectiveSyncWidget *_selectiveSync;
|
||||
SelectiveSyncTreeView *_treeView;
|
||||
|
||||
};
|
||||
|
||||
|
||||
@@ -32,14 +32,12 @@
|
||||
|
||||
#include <QNetworkProxy>
|
||||
#include <QDir>
|
||||
#include <QScopedValueRollback>
|
||||
|
||||
namespace OCC {
|
||||
|
||||
GeneralSettings::GeneralSettings(QWidget *parent) :
|
||||
QWidget(parent),
|
||||
_ui(new Ui::GeneralSettings),
|
||||
_currentlyLoading(false)
|
||||
_ui(new Ui::GeneralSettings)
|
||||
{
|
||||
_ui->setupUi(this);
|
||||
|
||||
@@ -68,7 +66,6 @@ GeneralSettings::GeneralSettings(QWidget *parent) :
|
||||
connect(_ui->crashreporterCheckBox, SIGNAL(toggled(bool)), SLOT(saveMiscSettings()));
|
||||
connect(_ui->newFolderLimitCheckBox, SIGNAL(toggled(bool)), SLOT(saveMiscSettings()));
|
||||
connect(_ui->newFolderLimitSpinBox, SIGNAL(valueChanged(int)), SLOT(saveMiscSettings()));
|
||||
connect(_ui->newExternalStorage, SIGNAL(toggled(bool)), SLOT(saveMiscSettings()));
|
||||
|
||||
#ifndef WITH_CRASHREPORTER
|
||||
_ui->crashreporterCheckBox->setVisible(false);
|
||||
@@ -88,9 +85,6 @@ GeneralSettings::GeneralSettings(QWidget *parent) :
|
||||
_ui->monoIconsCheckBox->setVisible(QDir(themeDir).exists());
|
||||
|
||||
connect(_ui->ignoredFilesButton, SIGNAL(clicked()), SLOT(slotIgnoreFilesEditor()));
|
||||
|
||||
// accountAdded means the wizard was finished and the wizard might change some options.
|
||||
connect(AccountManager::instance(), SIGNAL(accountAdded(AccountState*)), this, SLOT(loadMiscSettings()));
|
||||
}
|
||||
|
||||
GeneralSettings::~GeneralSettings()
|
||||
@@ -105,12 +99,6 @@ QSize GeneralSettings::sizeHint() const {
|
||||
|
||||
void GeneralSettings::loadMiscSettings()
|
||||
{
|
||||
#if QT_VERSION < QT_VERSION_CHECK( 5, 4, 0 )
|
||||
QScopedValueRollback<bool> scope(_currentlyLoading);
|
||||
_currentlyLoading = true;
|
||||
#else
|
||||
QScopedValueRollback<bool> scope(_currentlyLoading, true);
|
||||
#endif
|
||||
ConfigFile cfgFile;
|
||||
_ui->monoIconsCheckBox->setChecked(cfgFile.monoIcons());
|
||||
_ui->desktopNotificationsCheckBox->setChecked(cfgFile.optionalDesktopNotifications());
|
||||
@@ -118,8 +106,6 @@ void GeneralSettings::loadMiscSettings()
|
||||
auto newFolderLimit = cfgFile.newBigFolderSizeLimit();
|
||||
_ui->newFolderLimitCheckBox->setChecked(newFolderLimit.first);
|
||||
_ui->newFolderLimitSpinBox->setValue(newFolderLimit.second);
|
||||
_ui->newExternalStorage->setChecked(cfgFile.confirmExternalStorage());
|
||||
_ui->monoIconsCheckBox->setChecked(cfgFile.monoIcons());
|
||||
}
|
||||
|
||||
void GeneralSettings::slotUpdateInfo()
|
||||
@@ -144,8 +130,6 @@ void GeneralSettings::slotUpdateInfo()
|
||||
|
||||
void GeneralSettings::saveMiscSettings()
|
||||
{
|
||||
if (_currentlyLoading)
|
||||
return;
|
||||
ConfigFile cfgFile;
|
||||
bool isChecked = _ui->monoIconsCheckBox->isChecked();
|
||||
cfgFile.setMonoIcons(isChecked);
|
||||
@@ -154,7 +138,6 @@ void GeneralSettings::saveMiscSettings()
|
||||
|
||||
cfgFile.setNewBigFolderSizeLimit(_ui->newFolderLimitCheckBox->isChecked(),
|
||||
_ui->newFolderLimitSpinBox->value());
|
||||
cfgFile.setConfirmExternalStorage(_ui->newExternalStorage->isChecked());
|
||||
}
|
||||
|
||||
void GeneralSettings::slotToggleLaunchOnStartup(bool enable)
|
||||
|
||||
@@ -45,14 +45,13 @@ private slots:
|
||||
void slotToggleOptionalDesktopNotifications(bool);
|
||||
void slotUpdateInfo();
|
||||
void slotIgnoreFilesEditor();
|
||||
void loadMiscSettings();
|
||||
|
||||
private:
|
||||
void loadMiscSettings();
|
||||
|
||||
Ui::GeneralSettings *_ui;
|
||||
QPointer<IgnoreListEditor> _ignoreEditor;
|
||||
QPointer<SyncLogDialog> _syncLogDialog;
|
||||
bool _currentlyLoading;
|
||||
};
|
||||
|
||||
|
||||
|
||||
@@ -6,7 +6,7 @@
|
||||
<rect>
|
||||
<x>0</x>
|
||||
<y>0</y>
|
||||
<width>785</width>
|
||||
<width>706</width>
|
||||
<height>523</height>
|
||||
</rect>
|
||||
</property>
|
||||
@@ -52,37 +52,33 @@
|
||||
<property name="title">
|
||||
<string>Advanced</string>
|
||||
</property>
|
||||
<layout class="QVBoxLayout" name="verticalLayout">
|
||||
<item>
|
||||
<layout class="QHBoxLayout" name="horizontalLayout_4">
|
||||
<item>
|
||||
<widget class="QPushButton" name="ignoredFilesButton">
|
||||
<property name="text">
|
||||
<string>Edit &Ignored Files</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<spacer name="horizontalSpacer_4">
|
||||
<property name="orientation">
|
||||
<enum>Qt::Horizontal</enum>
|
||||
</property>
|
||||
<property name="sizeHint" stdset="0">
|
||||
<size>
|
||||
<width>555</width>
|
||||
<height>20</height>
|
||||
</size>
|
||||
</property>
|
||||
</spacer>
|
||||
</item>
|
||||
</layout>
|
||||
<layout class="QGridLayout" name="gridLayout">
|
||||
<item row="0" column="0">
|
||||
<widget class="QPushButton" name="ignoredFilesButton">
|
||||
<property name="text">
|
||||
<string>Edit &Ignored Files</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<item row="0" column="1" colspan="2">
|
||||
<spacer name="horizontalSpacer_4">
|
||||
<property name="orientation">
|
||||
<enum>Qt::Horizontal</enum>
|
||||
</property>
|
||||
<property name="sizeHint" stdset="0">
|
||||
<size>
|
||||
<width>555</width>
|
||||
<height>20</height>
|
||||
</size>
|
||||
</property>
|
||||
</spacer>
|
||||
</item>
|
||||
<item row="1" column="0" colspan="3">
|
||||
<layout class="QHBoxLayout" name="horizontalLayout_3">
|
||||
<item>
|
||||
<widget class="QCheckBox" name="newFolderLimitCheckBox">
|
||||
<property name="text">
|
||||
<string>Ask for confirmation before synchronizing folders larger than</string>
|
||||
<string>Ask &confirmation before downloading folders larger than</string>
|
||||
</property>
|
||||
<property name="checked">
|
||||
<bool>true</bool>
|
||||
@@ -102,7 +98,7 @@
|
||||
<item>
|
||||
<widget class="QLabel" name="label">
|
||||
<property name="text">
|
||||
<string extracomment="Trailing part of "Ask confirmation before syncing folder larger than" ">MB</string>
|
||||
<string>MB</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
@@ -121,14 +117,7 @@
|
||||
</item>
|
||||
</layout>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QCheckBox" name="newExternalStorage">
|
||||
<property name="text">
|
||||
<string>Ask for confirmation before synchronizing external storages</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<item row="2" column="0" colspan="2">
|
||||
<widget class="QCheckBox" name="crashreporterCheckBox">
|
||||
<property name="sizePolicy">
|
||||
<sizepolicy hsizetype="MinimumExpanding" vsizetype="Fixed">
|
||||
@@ -141,6 +130,23 @@
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="2" column="2">
|
||||
<layout class="QHBoxLayout" name="horizontalLayout_5">
|
||||
<item>
|
||||
<spacer name="horizontalSpacer_5">
|
||||
<property name="orientation">
|
||||
<enum>Qt::Horizontal</enum>
|
||||
</property>
|
||||
<property name="sizeHint" stdset="0">
|
||||
<size>
|
||||
<width>40</width>
|
||||
<height>20</height>
|
||||
</size>
|
||||
</property>
|
||||
</spacer>
|
||||
</item>
|
||||
</layout>
|
||||
</item>
|
||||
</layout>
|
||||
</widget>
|
||||
</item>
|
||||
|
||||
@@ -15,7 +15,6 @@
|
||||
#include "notificationwidget.h"
|
||||
#include "QProgressIndicator.h"
|
||||
#include "utility.h"
|
||||
#include "asserts.h"
|
||||
|
||||
#include <QPushButton>
|
||||
|
||||
@@ -34,8 +33,8 @@ void NotificationWidget::setActivity(const Activity& activity)
|
||||
{
|
||||
_myActivity = activity;
|
||||
|
||||
Q_ASSERT( !activity._accName.isEmpty() );
|
||||
_accountName = activity._accName;
|
||||
ASSERT(!_accountName.isEmpty());
|
||||
|
||||
// _ui._headerLabel->setText( );
|
||||
_ui._subjectLabel->setVisible( !activity._subject.isEmpty() );
|
||||
|
||||
@@ -533,11 +533,9 @@ void OwncloudSetupWizard::slotAssistantFinished( int result )
|
||||
if (f) {
|
||||
f->journalDb()->setSelectiveSyncList(SyncJournalDb::SelectiveSyncBlackList,
|
||||
_ocWizard->selectiveSyncBlacklist());
|
||||
if (!_ocWizard->isConfirmBigFolderChecked()) {
|
||||
// The user already accepted the selective sync dialog. everything is in the white list
|
||||
f->journalDb()->setSelectiveSyncList(SyncJournalDb::SelectiveSyncWhiteList,
|
||||
// The user already accepted the selective sync dialog. everything is in the white list
|
||||
f->journalDb()->setSelectiveSyncList(SyncJournalDb::SelectiveSyncWhiteList,
|
||||
QStringList() << QLatin1String("/"));
|
||||
}
|
||||
}
|
||||
_ocWizard->appendToConfigurationLog(tr("<font color=\"green\"><b>Local sync folder %1 successfully created!</b></font>").arg(localFolder));
|
||||
}
|
||||
|
||||
@@ -27,6 +27,7 @@
|
||||
#include "syncfileitem.h"
|
||||
#include "folder.h"
|
||||
#include "openfilemanager.h"
|
||||
#include "owncloudpropagator.h"
|
||||
#include "activityitemdelegate.h"
|
||||
|
||||
#include "ui_protocolwidget.h"
|
||||
@@ -44,8 +45,8 @@ ProtocolWidget::ProtocolWidget(QWidget *parent) :
|
||||
|
||||
connect(ProgressDispatcher::instance(), SIGNAL(progressInfo(QString,ProgressInfo)),
|
||||
this, SLOT(slotProgressInfo(QString,ProgressInfo)));
|
||||
connect(ProgressDispatcher::instance(), SIGNAL(itemCompleted(QString,SyncFileItemPtr)),
|
||||
this, SLOT(slotItemCompleted(QString,SyncFileItemPtr)));
|
||||
connect(ProgressDispatcher::instance(), SIGNAL(itemCompleted(QString,SyncFileItem,PropagatorJob)),
|
||||
this, SLOT(slotItemCompleted(QString,SyncFileItem,PropagatorJob)));
|
||||
|
||||
connect(_ui->_treeWidget, SIGNAL(itemActivated(QTreeWidgetItem*,int)), SLOT(slotOpenFile(QTreeWidgetItem*,int)));
|
||||
|
||||
@@ -221,11 +222,15 @@ void ProtocolWidget::slotProgressInfo( const QString& folder, const ProgressInfo
|
||||
}
|
||||
}
|
||||
|
||||
void ProtocolWidget::slotItemCompleted(const QString &folder, const SyncFileItemPtr &item)
|
||||
void ProtocolWidget::slotItemCompleted(const QString &folder, const SyncFileItem &item, const PropagatorJob &job)
|
||||
{
|
||||
QTreeWidgetItem *line = createCompletedTreewidgetItem(folder, *item);
|
||||
if (qobject_cast<const PropagateDirectory*>(&job)) {
|
||||
return;
|
||||
}
|
||||
|
||||
QTreeWidgetItem *line = createCompletedTreewidgetItem(folder, item);
|
||||
if(line) {
|
||||
if( item->hasErrorStatus() ) {
|
||||
if( item.hasErrorStatus() ) {
|
||||
_issueItemView->insertTopLevelItem(0, line);
|
||||
emit issueItemCountUpdated(_issueItemView->topLevelItemCount());
|
||||
} else {
|
||||
|
||||
@@ -52,7 +52,7 @@ public:
|
||||
|
||||
public slots:
|
||||
void slotProgressInfo( const QString& folder, const ProgressInfo& progress );
|
||||
void slotItemCompleted( const QString& folder, const SyncFileItemPtr& item);
|
||||
void slotItemCompleted( const QString& folder, const SyncFileItem& item, const PropagatorJob& job);
|
||||
void slotOpenFile( QTreeWidgetItem* item, int );
|
||||
|
||||
protected:
|
||||
|
||||
@@ -18,7 +18,6 @@
|
||||
#include "networkjobs.h"
|
||||
#include "theme.h"
|
||||
#include "folderman.h"
|
||||
#include "configfile.h"
|
||||
#include <QDialogButtonBox>
|
||||
#include <QVBoxLayout>
|
||||
#include <QTreeWidget>
|
||||
@@ -30,7 +29,6 @@
|
||||
#include <QScopedValueRollback>
|
||||
#include <QTreeWidgetItem>
|
||||
#include <QLabel>
|
||||
#include <QVBoxLayout>
|
||||
|
||||
namespace OCC {
|
||||
|
||||
@@ -56,48 +54,32 @@ private:
|
||||
}
|
||||
};
|
||||
|
||||
SelectiveSyncWidget::SelectiveSyncWidget(AccountPtr account, QWidget *parent)
|
||||
: QWidget(parent)
|
||||
, _account(account)
|
||||
, _inserting(false)
|
||||
, _folderTree(new QTreeWidget(this))
|
||||
SelectiveSyncTreeView::SelectiveSyncTreeView(AccountPtr account, QWidget* parent)
|
||||
: QTreeWidget(parent), _inserting(false), _account(account)
|
||||
{
|
||||
_loading = new QLabel(tr("Loading ..."), _folderTree);
|
||||
|
||||
auto layout = new QVBoxLayout(this);
|
||||
layout->setContentsMargins(0, 0, 0, 0);
|
||||
|
||||
auto header = new QLabel(this);
|
||||
header->setText(tr("Deselect remote folders you do not wish to synchronize."));
|
||||
header->setWordWrap(true);
|
||||
layout->addWidget(header);
|
||||
|
||||
layout->addWidget(_folderTree);
|
||||
|
||||
connect(_folderTree, SIGNAL(itemExpanded(QTreeWidgetItem*)),
|
||||
SLOT(slotItemExpanded(QTreeWidgetItem*)));
|
||||
connect(_folderTree, SIGNAL(itemChanged(QTreeWidgetItem*,int)),
|
||||
SLOT(slotItemChanged(QTreeWidgetItem*,int)));
|
||||
_folderTree->setSortingEnabled(true);
|
||||
_folderTree->sortByColumn(0, Qt::AscendingOrder);
|
||||
_folderTree->setColumnCount(2);
|
||||
_loading = new QLabel(tr("Loading ..."), this);
|
||||
connect(this, SIGNAL(itemExpanded(QTreeWidgetItem*)), this, SLOT(slotItemExpanded(QTreeWidgetItem*)));
|
||||
connect(this, SIGNAL(itemChanged(QTreeWidgetItem*,int)), this, SLOT(slotItemChanged(QTreeWidgetItem*,int)));
|
||||
setSortingEnabled(true);
|
||||
sortByColumn(0, Qt::AscendingOrder);
|
||||
setColumnCount(2);
|
||||
#if QT_VERSION >= QT_VERSION_CHECK(5, 0, 0)
|
||||
_folderTree->header()->setSectionResizeMode(0, QHeaderView::QHeaderView::ResizeToContents);
|
||||
_folderTree->header()->setSectionResizeMode(1, QHeaderView::QHeaderView::ResizeToContents);
|
||||
header()->setSectionResizeMode(0, QHeaderView::QHeaderView::ResizeToContents);
|
||||
header()->setSectionResizeMode(1, QHeaderView::QHeaderView::ResizeToContents);
|
||||
#else
|
||||
_folderTree->header()->resizeSection(0, sizeHint().width()/2);
|
||||
header()->resizeSection(0, sizeHint().width()/2);
|
||||
#endif
|
||||
_folderTree->header()->setStretchLastSection(true);
|
||||
_folderTree->headerItem()->setText(0, tr("Name"));
|
||||
_folderTree->headerItem()->setText(1, tr("Size"));
|
||||
header()->setStretchLastSection(true);
|
||||
headerItem()->setText(0, tr("Name"));
|
||||
headerItem()->setText(1, tr("Size"));
|
||||
}
|
||||
|
||||
QSize SelectiveSyncWidget::sizeHint() const
|
||||
QSize SelectiveSyncTreeView::sizeHint() const
|
||||
{
|
||||
return QWidget::sizeHint().expandedTo(QSize(600, 600));
|
||||
return QTreeView::sizeHint().expandedTo(QSize(400, 400));
|
||||
}
|
||||
|
||||
void SelectiveSyncWidget::refreshFolders()
|
||||
void SelectiveSyncTreeView::refreshFolders()
|
||||
{
|
||||
LsColJob *job = new LsColJob(_account, _folderPath, this);
|
||||
job->setProperties(QList<QByteArray>() << "resourcetype" << "http://owncloud.org/ns:size");
|
||||
@@ -106,12 +88,12 @@ void SelectiveSyncWidget::refreshFolders()
|
||||
connect(job, SIGNAL(finishedWithError(QNetworkReply*)),
|
||||
this, SLOT(slotLscolFinishedWithError(QNetworkReply*)));
|
||||
job->start();
|
||||
_folderTree->clear();
|
||||
clear();
|
||||
_loading->show();
|
||||
_loading->move(10, _folderTree->header()->height() + 10);
|
||||
_loading->move(10,header()->height() + 10);
|
||||
}
|
||||
|
||||
void SelectiveSyncWidget::setFolderInfo(const QString& folderPath, const QString& rootName, const QStringList& oldBlackList)
|
||||
void SelectiveSyncTreeView::setFolderInfo(const QString& folderPath, const QString& rootName, const QStringList& oldBlackList)
|
||||
{
|
||||
_folderPath = folderPath;
|
||||
if (_folderPath.startsWith(QLatin1Char('/'))) {
|
||||
@@ -134,7 +116,7 @@ static QTreeWidgetItem* findFirstChild(QTreeWidgetItem *parent, const QString& t
|
||||
return 0;
|
||||
}
|
||||
|
||||
void SelectiveSyncWidget::recursiveInsert(QTreeWidgetItem* parent, QStringList pathTrail, QString path, qint64 size)
|
||||
void SelectiveSyncTreeView::recursiveInsert(QTreeWidgetItem* parent, QStringList pathTrail, QString path, qint64 size)
|
||||
{
|
||||
QFileIconProvider prov;
|
||||
QIcon folderIcon = prov.icon(QFileIconProvider::Folder);
|
||||
@@ -177,13 +159,13 @@ void SelectiveSyncWidget::recursiveInsert(QTreeWidgetItem* parent, QStringList p
|
||||
}
|
||||
}
|
||||
|
||||
void SelectiveSyncWidget::slotUpdateDirectories(QStringList list)
|
||||
void SelectiveSyncTreeView::slotUpdateDirectories(QStringList list)
|
||||
{
|
||||
auto job = qobject_cast<LsColJob *>(sender());
|
||||
QScopedValueRollback<bool> isInserting(_inserting);
|
||||
_inserting = true;
|
||||
|
||||
SelectiveSyncTreeViewItem *root = static_cast<SelectiveSyncTreeViewItem*>(_folderTree->topLevelItem(0));
|
||||
SelectiveSyncTreeViewItem *root = static_cast<SelectiveSyncTreeViewItem*>(topLevelItem(0));
|
||||
|
||||
QUrl url = _account->davUrl();
|
||||
QString pathToRemove = url.path();
|
||||
@@ -224,11 +206,15 @@ void SelectiveSyncWidget::slotUpdateDirectories(QStringList list)
|
||||
}
|
||||
|
||||
if (!root) {
|
||||
root = new SelectiveSyncTreeViewItem(_folderTree);
|
||||
root = new SelectiveSyncTreeViewItem(this);
|
||||
root->setText(0, _rootName);
|
||||
root->setIcon(0, Theme::instance()->applicationIcon());
|
||||
root->setData(0, Qt::UserRole, QString());
|
||||
root->setCheckState(0, Qt::Checked);
|
||||
if (_oldBlackList.isEmpty()) {
|
||||
root->setCheckState(0, Qt::Checked);
|
||||
} else {
|
||||
root->setCheckState(0, Qt::PartiallyChecked);
|
||||
}
|
||||
qint64 size = job ? job->_sizes.value(pathToRemove, -1) : -1;
|
||||
if (size >= 0) {
|
||||
root->setText(1, Utility::octetsToString(size));
|
||||
@@ -250,19 +236,10 @@ void SelectiveSyncWidget::slotUpdateDirectories(QStringList list)
|
||||
recursiveInsert(root, paths, path, size);
|
||||
}
|
||||
|
||||
// Root is partially checked if any children are not checked
|
||||
for (int i = 0; i < root->childCount(); ++i) {
|
||||
const auto child = root->child(i);
|
||||
if (child->checkState(0) != Qt::Checked) {
|
||||
root->setCheckState(0, Qt::PartiallyChecked);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
root->setExpanded(true);
|
||||
}
|
||||
|
||||
void SelectiveSyncWidget::slotLscolFinishedWithError(QNetworkReply *r)
|
||||
void SelectiveSyncTreeView::slotLscolFinishedWithError(QNetworkReply *r)
|
||||
{
|
||||
if (r->error() == QNetworkReply::ContentNotFoundError) {
|
||||
_loading->setText(tr("No subfolders currently on the server."));
|
||||
@@ -272,7 +249,7 @@ void SelectiveSyncWidget::slotLscolFinishedWithError(QNetworkReply *r)
|
||||
_loading->resize(_loading->sizeHint()); // because it's not in a layout
|
||||
}
|
||||
|
||||
void SelectiveSyncWidget::slotItemExpanded(QTreeWidgetItem *item)
|
||||
void SelectiveSyncTreeView::slotItemExpanded(QTreeWidgetItem *item)
|
||||
{
|
||||
QString dir = item->data(0, Qt::UserRole).toString();
|
||||
if (dir.isEmpty()) return;
|
||||
@@ -287,7 +264,7 @@ void SelectiveSyncWidget::slotItemExpanded(QTreeWidgetItem *item)
|
||||
job->start();
|
||||
}
|
||||
|
||||
void SelectiveSyncWidget::slotItemChanged(QTreeWidgetItem *item, int col)
|
||||
void SelectiveSyncTreeView::slotItemChanged(QTreeWidgetItem *item, int col)
|
||||
{
|
||||
if (col != 0 || _inserting)
|
||||
return;
|
||||
@@ -345,10 +322,10 @@ void SelectiveSyncWidget::slotItemChanged(QTreeWidgetItem *item, int col)
|
||||
}
|
||||
}
|
||||
|
||||
QStringList SelectiveSyncWidget::createBlackList(QTreeWidgetItem* root) const
|
||||
QStringList SelectiveSyncTreeView::createBlackList(QTreeWidgetItem* root) const
|
||||
{
|
||||
if (!root) {
|
||||
root = _folderTree->topLevelItem(0);
|
||||
root = topLevelItem(0);
|
||||
}
|
||||
if (!root) return QStringList();
|
||||
|
||||
@@ -377,15 +354,15 @@ QStringList SelectiveSyncWidget::createBlackList(QTreeWidgetItem* root) const
|
||||
return result;
|
||||
}
|
||||
|
||||
QStringList SelectiveSyncWidget::oldBlackList() const
|
||||
QStringList SelectiveSyncTreeView::oldBlackList() const
|
||||
{
|
||||
return _oldBlackList;
|
||||
}
|
||||
|
||||
qint64 SelectiveSyncWidget::estimatedSize(QTreeWidgetItem* root)
|
||||
qint64 SelectiveSyncTreeView::estimatedSize(QTreeWidgetItem* root)
|
||||
{
|
||||
if (!root) {
|
||||
root = _folderTree->topLevelItem(0);
|
||||
root = topLevelItem(0);
|
||||
}
|
||||
if (!root) return -1;
|
||||
|
||||
@@ -419,10 +396,10 @@ SelectiveSyncDialog::SelectiveSyncDialog(AccountPtr account, Folder* folder, QWi
|
||||
_okButton(0) // defined in init()
|
||||
{
|
||||
bool ok;
|
||||
init(account);
|
||||
init(account, tr("Unchecked folders will be <b>removed</b> from your local file system and will not be synchronized to this computer anymore"));
|
||||
QStringList selectiveSyncList = _folder->journalDb()->getSelectiveSyncList(SyncJournalDb::SelectiveSyncBlackList, &ok);
|
||||
if( ok ) {
|
||||
_selectiveSync->setFolderInfo(_folder->remotePath(), _folder->alias(),selectiveSyncList);
|
||||
_treeView->setFolderInfo(_folder->remotePath(), _folder->alias(),selectiveSyncList);
|
||||
} else {
|
||||
_okButton->setEnabled(false);
|
||||
}
|
||||
@@ -434,16 +411,22 @@ SelectiveSyncDialog::SelectiveSyncDialog(AccountPtr account, const QString &fold
|
||||
const QStringList& blacklist, QWidget* parent, Qt::WindowFlags f)
|
||||
: QDialog(parent, f), _folder(0)
|
||||
{
|
||||
init(account);
|
||||
_selectiveSync->setFolderInfo(folder, folder, blacklist);
|
||||
init(account,
|
||||
Theme::instance()->wizardSelectiveSyncDefaultNothing() ?
|
||||
tr("Choose What to Sync: Select remote subfolders you wish to synchronize.") :
|
||||
tr("Choose What to Sync: Deselect remote subfolders you do not wish to synchronize."));
|
||||
_treeView->setFolderInfo(folder, folder, blacklist);
|
||||
}
|
||||
|
||||
void SelectiveSyncDialog::init(const AccountPtr &account)
|
||||
void SelectiveSyncDialog::init(const AccountPtr &account, const QString &labelText)
|
||||
{
|
||||
setWindowTitle(tr("Choose What to Sync"));
|
||||
QVBoxLayout *layout = new QVBoxLayout(this);
|
||||
_selectiveSync = new SelectiveSyncWidget(account, this);
|
||||
layout->addWidget(_selectiveSync);
|
||||
_treeView = new SelectiveSyncTreeView(account, this);
|
||||
auto label = new QLabel(labelText);
|
||||
label->setWordWrap(true);
|
||||
layout->addWidget(label);
|
||||
layout->addWidget(_treeView);
|
||||
QDialogButtonBox *buttonBox = new QDialogButtonBox(Qt::Horizontal);
|
||||
_okButton = buttonBox->addButton(QDialogButtonBox::Ok);
|
||||
connect(_okButton, SIGNAL(clicked()), this, SLOT(accept()));
|
||||
@@ -461,7 +444,7 @@ void SelectiveSyncDialog::accept()
|
||||
if( ! ok ) {
|
||||
return;
|
||||
}
|
||||
QStringList blackList = _selectiveSync->createBlackList();
|
||||
QStringList blackList = _treeView->createBlackList();
|
||||
_folder->journalDb()->setSelectiveSyncList(SyncJournalDb::SelectiveSyncBlackList, blackList);
|
||||
|
||||
FolderMan *folderMan = FolderMan::instance();
|
||||
@@ -484,18 +467,19 @@ void SelectiveSyncDialog::accept()
|
||||
|
||||
QStringList SelectiveSyncDialog::createBlackList() const
|
||||
{
|
||||
return _selectiveSync->createBlackList();
|
||||
return _treeView->createBlackList();
|
||||
}
|
||||
|
||||
QStringList SelectiveSyncDialog::oldBlackList() const
|
||||
{
|
||||
return _selectiveSync->oldBlackList();
|
||||
return _treeView->oldBlackList();
|
||||
}
|
||||
|
||||
qint64 SelectiveSyncDialog::estimatedSize()
|
||||
{
|
||||
return _selectiveSync->estimatedSize();
|
||||
return _treeView->estimatedSize();
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
@@ -26,50 +26,40 @@ namespace OCC {
|
||||
class Folder;
|
||||
|
||||
/**
|
||||
* @brief The SelectiveSyncWidget contains a folder tree with labels
|
||||
* @brief The SelectiveSyncTreeView class
|
||||
* @ingroup gui
|
||||
*/
|
||||
class SelectiveSyncWidget : public QWidget {
|
||||
class SelectiveSyncTreeView : public QTreeWidget {
|
||||
Q_OBJECT
|
||||
public:
|
||||
explicit SelectiveSyncWidget(AccountPtr account, QWidget* parent = 0);
|
||||
explicit SelectiveSyncTreeView(AccountPtr account, QWidget* parent = 0);
|
||||
|
||||
/// Returns a list of blacklisted paths, each including the trailing /
|
||||
QStringList createBlackList(QTreeWidgetItem* root = 0) const;
|
||||
|
||||
/** Returns the oldBlackList passed into setFolderInfo(), except that
|
||||
* a "/" entry is expanded to all top-level folder names.
|
||||
*/
|
||||
QStringList oldBlackList() const;
|
||||
|
||||
// Estimates the total size of checked items (recursively)
|
||||
qint64 estimatedSize(QTreeWidgetItem *root = 0);
|
||||
void refreshFolders();
|
||||
|
||||
// oldBlackList is a list of excluded paths, each including a trailing /
|
||||
void setFolderInfo(const QString &folderPath, const QString &rootName,
|
||||
const QStringList &oldBlackList = QStringList());
|
||||
|
||||
QSize sizeHint() const Q_DECL_OVERRIDE;
|
||||
|
||||
private slots:
|
||||
void slotUpdateDirectories(QStringList);
|
||||
void slotItemExpanded(QTreeWidgetItem *);
|
||||
void slotItemChanged(QTreeWidgetItem*,int);
|
||||
void slotLscolFinishedWithError(QNetworkReply*);
|
||||
private:
|
||||
void refreshFolders();
|
||||
void recursiveInsert(QTreeWidgetItem* parent, QStringList pathTrail, QString path, qint64 size);
|
||||
|
||||
AccountPtr _account;
|
||||
|
||||
QString _folderPath;
|
||||
QString _rootName;
|
||||
QStringList _oldBlackList;
|
||||
|
||||
bool _inserting; // set to true when we are inserting new items on the list
|
||||
AccountPtr _account;
|
||||
QLabel *_loading;
|
||||
|
||||
QTreeWidget *_folderTree;
|
||||
};
|
||||
|
||||
/**
|
||||
@@ -95,9 +85,9 @@ public:
|
||||
|
||||
private:
|
||||
|
||||
void init(const AccountPtr &account);
|
||||
void init(const AccountPtr &account, const QString &label);
|
||||
|
||||
SelectiveSyncWidget *_selectiveSync;
|
||||
SelectiveSyncTreeView *_treeView;
|
||||
|
||||
Folder *_folder;
|
||||
QPushButton *_okButton;
|
||||
|
||||
@@ -229,7 +229,7 @@ void ShareLinkWidget::slotSharesFetched(const QList<QSharedPointer<Share>> &shar
|
||||
Q_FOREACH(auto share, shares) {
|
||||
|
||||
if (share->getShareType() == Share::TypeLink) {
|
||||
_share = qSharedPointerDynamicCast<LinkShare>(share);
|
||||
_share = qSharedPointerObjectCast<LinkShare>(share);
|
||||
_ui->pushButton_copy->show();
|
||||
_ui->pushButton_mail->show();
|
||||
|
||||
|
||||
@@ -31,7 +31,6 @@
|
||||
#include "accountstate.h"
|
||||
#include "account.h"
|
||||
#include "capabilities.h"
|
||||
#include "asserts.h"
|
||||
|
||||
#include <QBitArray>
|
||||
#include <QDebug>
|
||||
@@ -61,6 +60,9 @@
|
||||
|
||||
#define DEBUG qDebug() << "SocketApi: "
|
||||
|
||||
Q_DECLARE_METATYPE(OCC::SocketListener)
|
||||
|
||||
|
||||
static inline QString removeTrailingSlash(QString path)
|
||||
{
|
||||
Q_ASSERT(path.endsWith(QLatin1Char('/')));
|
||||
@@ -111,7 +113,7 @@ class SocketListener {
|
||||
public:
|
||||
QIODevice* socket;
|
||||
|
||||
SocketListener(QIODevice* socket = 0) : socket(socket) { }
|
||||
SocketListener(QIODevice* socket = nullptr) : socket(socket) { }
|
||||
|
||||
void sendMessage(const QString& message, bool doWait = false) const
|
||||
{
|
||||
@@ -214,7 +216,7 @@ SocketApi::~SocketApi()
|
||||
DEBUG << "dtor";
|
||||
_localServer.close();
|
||||
// All remaining sockets will be destroyed with _localServer, their parent
|
||||
ASSERT(_listeners.isEmpty() || _listeners.first().socket->parent() == &_localServer);
|
||||
Q_ASSERT(_listeners.isEmpty() || _listeners.first().socket->parent() == &_localServer);
|
||||
_listeners.clear();
|
||||
}
|
||||
|
||||
@@ -229,7 +231,7 @@ void SocketApi::slotNewConnection()
|
||||
connect(socket, SIGNAL(readyRead()), this, SLOT(slotReadSocket()));
|
||||
connect(socket, SIGNAL(disconnected()), this, SLOT(onLostConnection()));
|
||||
connect(socket, SIGNAL(destroyed(QObject*)), this, SLOT(slotSocketDestroyed(QObject*)));
|
||||
ASSERT(socket->readAll().isEmpty());
|
||||
Q_ASSERT(socket->readAll().isEmpty());
|
||||
|
||||
_listeners.append(SocketListener(socket));
|
||||
SocketListener &listener = _listeners.last();
|
||||
@@ -257,7 +259,7 @@ void SocketApi::slotSocketDestroyed(QObject* obj)
|
||||
void SocketApi::slotReadSocket()
|
||||
{
|
||||
QIODevice* socket = qobject_cast<QIODevice*>(sender());
|
||||
ASSERT(socket);
|
||||
Q_ASSERT(socket);
|
||||
SocketListener *listener = &*std::find_if(_listeners.begin(), _listeners.end(), ListenerHasSocketPred(socket));
|
||||
|
||||
while(socket->canReadLine()) {
|
||||
@@ -515,5 +517,3 @@ QString SocketApi::buildRegisterPathMessage(const QString& path)
|
||||
}
|
||||
|
||||
} // namespace OCC
|
||||
|
||||
Q_DECLARE_METATYPE(OCC::SocketListener)
|
||||
|
||||
@@ -145,18 +145,18 @@ void SyncRunFileLog::logItem( const SyncFileItem& item )
|
||||
|
||||
const QChar L = QLatin1Char('|');
|
||||
_out << ts << L;
|
||||
_out << L;
|
||||
if( item._instruction != CSYNC_INSTRUCTION_RENAME ) {
|
||||
_out << QString::number(item._requestDuration) << L;
|
||||
if( item.log._instruction != CSYNC_INSTRUCTION_RENAME ) {
|
||||
_out << item._file << L;
|
||||
} else {
|
||||
_out << item._file << QLatin1String(" -> ") << item._renameTarget << L;
|
||||
}
|
||||
_out << instructionToStr( item._instruction ) << L;
|
||||
_out << instructionToStr( item.log._instruction ) << L;
|
||||
_out << directionToStr( item._direction ) << L;
|
||||
_out << QString::number(item._modtime) << L;
|
||||
_out << item._etag << L;
|
||||
_out << QString::number(item._size) << L;
|
||||
_out << item._fileId << L;
|
||||
_out << QString::number(item.log._modtime) << L;
|
||||
_out << item.log._etag << L;
|
||||
_out << QString::number(item.log._size) << L;
|
||||
_out << item.log._fileId << L;
|
||||
_out << item._status << L;
|
||||
_out << item._errorString << L;
|
||||
_out << QString::number(item._httpErrorCode) << L;
|
||||
|
||||
@@ -68,15 +68,6 @@ OwncloudAdvancedSetupPage::OwncloudAdvancedSetupPage()
|
||||
_ui.lServerIcon->setPixmap(appIcon.pixmap(48));
|
||||
_ui.lLocalIcon->setText(QString());
|
||||
_ui.lLocalIcon->setPixmap(QPixmap(Theme::hidpiFileName(":/client/resources/folder-sync.png")));
|
||||
|
||||
if (theme->wizardHideExternalStorageConfirmationCheckbox()) {
|
||||
_ui.confCheckBoxExternal->hide();
|
||||
}
|
||||
if (theme->wizardHideFolderSizeLimitCheckbox()) {
|
||||
_ui.confCheckBoxSize->hide();
|
||||
_ui.confSpinBox->hide();
|
||||
_ui.confTraillingSizeLabel->hide();
|
||||
}
|
||||
}
|
||||
|
||||
void OwncloudAdvancedSetupPage::setupCustomization()
|
||||
@@ -127,12 +118,6 @@ void OwncloudAdvancedSetupPage::initializePage()
|
||||
_selectiveSyncBlacklist = QStringList("/");
|
||||
QTimer::singleShot(0, this, SLOT(slotSelectiveSyncClicked()));
|
||||
}
|
||||
|
||||
ConfigFile cfgFile;
|
||||
auto newFolderLimit = cfgFile.newBigFolderSizeLimit();
|
||||
_ui.confCheckBoxSize->setChecked(newFolderLimit.first);
|
||||
_ui.confSpinBox->setValue(newFolderLimit.second);
|
||||
_ui.confCheckBoxExternal->setChecked(cfgFile.confirmExternalStorage());
|
||||
}
|
||||
|
||||
// Called if the user changes the user- or url field. Adjust the texts and
|
||||
@@ -215,11 +200,6 @@ QStringList OwncloudAdvancedSetupPage::selectiveSyncBlacklist() const
|
||||
return _selectiveSyncBlacklist;
|
||||
}
|
||||
|
||||
bool OwncloudAdvancedSetupPage::isConfirmBigFolderChecked() const
|
||||
{
|
||||
return _ui.rSyncEverything->isChecked() && _ui.confCheckBoxSize->isChecked();
|
||||
}
|
||||
|
||||
bool OwncloudAdvancedSetupPage::validatePage()
|
||||
{
|
||||
if(!_created) {
|
||||
@@ -228,13 +208,6 @@ bool OwncloudAdvancedSetupPage::validatePage()
|
||||
startSpinner();
|
||||
emit completeChanged();
|
||||
|
||||
if (_ui.rSyncEverything->isChecked()) {
|
||||
ConfigFile cfgFile;
|
||||
cfgFile.setNewBigFolderSizeLimit(_ui.confCheckBoxSize->isChecked(),
|
||||
_ui.confSpinBox->value());
|
||||
cfgFile.setConfirmExternalStorage(_ui.confCheckBoxExternal->isChecked());
|
||||
}
|
||||
|
||||
emit createLocalAndRemoteFolders(localFolder(), _remoteFolder);
|
||||
return false;
|
||||
} else {
|
||||
|
||||
@@ -41,7 +41,6 @@ public:
|
||||
bool validatePage() Q_DECL_OVERRIDE;
|
||||
QString localFolder() const;
|
||||
QStringList selectiveSyncBlacklist() const;
|
||||
bool isConfirmBigFolderChecked() const;
|
||||
void setRemoteFolder( const QString& remoteFolder);
|
||||
void setMultipleFoldersExist( bool exist );
|
||||
void directoriesCreated();
|
||||
|
||||
@@ -6,12 +6,12 @@
|
||||
<rect>
|
||||
<x>0</x>
|
||||
<y>0</y>
|
||||
<width>912</width>
|
||||
<height>633</height>
|
||||
<width>917</width>
|
||||
<height>493</height>
|
||||
</rect>
|
||||
</property>
|
||||
<property name="sizePolicy">
|
||||
<sizepolicy hsizetype="Maximum" vsizetype="Maximum">
|
||||
<sizepolicy hsizetype="Preferred" vsizetype="Maximum">
|
||||
<horstretch>0</horstretch>
|
||||
<verstretch>0</verstretch>
|
||||
</sizepolicy>
|
||||
@@ -226,14 +226,11 @@
|
||||
<item row="0" column="1" colspan="2">
|
||||
<widget class="QWidget" name="widget" native="true">
|
||||
<layout class="QVBoxLayout" name="verticalLayout">
|
||||
<property name="leftMargin">
|
||||
<number>0</number>
|
||||
</property>
|
||||
<property name="rightMargin">
|
||||
<number>0</number>
|
||||
</property>
|
||||
<item>
|
||||
<layout class="QHBoxLayout" name="horizontalLayout_2">
|
||||
<property name="spacing">
|
||||
<number>0</number>
|
||||
</property>
|
||||
<item>
|
||||
<widget class="QRadioButton" name="rSyncEverything">
|
||||
<property name="text">
|
||||
@@ -266,64 +263,6 @@
|
||||
</item>
|
||||
</layout>
|
||||
</item>
|
||||
<item>
|
||||
<layout class="QGridLayout" name="gridLayout_2">
|
||||
<property name="horizontalSpacing">
|
||||
<number>0</number>
|
||||
</property>
|
||||
<item row="0" column="0">
|
||||
<spacer name="horizontalSpacer_4">
|
||||
<property name="orientation">
|
||||
<enum>Qt::Horizontal</enum>
|
||||
</property>
|
||||
<property name="sizeType">
|
||||
<enum>QSizePolicy::Minimum</enum>
|
||||
</property>
|
||||
<property name="sizeHint" stdset="0">
|
||||
<size>
|
||||
<width>10</width>
|
||||
<height>20</height>
|
||||
</size>
|
||||
</property>
|
||||
</spacer>
|
||||
</item>
|
||||
<item row="0" column="1">
|
||||
<layout class="QHBoxLayout" name="horizontalLayout_3">
|
||||
<item>
|
||||
<widget class="QCheckBox" name="confCheckBoxSize">
|
||||
<property name="text">
|
||||
<string>Ask for confirmation before synchroni&zing folders larger than</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QSpinBox" name="confSpinBox">
|
||||
<property name="maximum">
|
||||
<number>999999</number>
|
||||
</property>
|
||||
<property name="value">
|
||||
<number>99</number>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QLabel" name="confTraillingSizeLabel">
|
||||
<property name="text">
|
||||
<string extracomment="Trailing part of "Ask confirmation before syncing folder larger than" ">MB</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</item>
|
||||
<item row="1" column="1">
|
||||
<widget class="QCheckBox" name="confCheckBoxExternal">
|
||||
<property name="text">
|
||||
<string>Ask for confirmation before synchronizing e&xternal storages</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</item>
|
||||
<item>
|
||||
<layout class="QHBoxLayout" name="horizontalLayout">
|
||||
<item>
|
||||
@@ -406,70 +345,5 @@
|
||||
</layout>
|
||||
</widget>
|
||||
<resources/>
|
||||
<connections>
|
||||
<connection>
|
||||
<sender>rSyncEverything</sender>
|
||||
<signal>toggled(bool)</signal>
|
||||
<receiver>confCheckBoxSize</receiver>
|
||||
<slot>setEnabled(bool)</slot>
|
||||
<hints>
|
||||
<hint type="sourcelabel">
|
||||
<x>217</x>
|
||||
<y>78</y>
|
||||
</hint>
|
||||
<hint type="destinationlabel">
|
||||
<x>298</x>
|
||||
<y>126</y>
|
||||
</hint>
|
||||
</hints>
|
||||
</connection>
|
||||
<connection>
|
||||
<sender>rSyncEverything</sender>
|
||||
<signal>toggled(bool)</signal>
|
||||
<receiver>confSpinBox</receiver>
|
||||
<slot>setEnabled(bool)</slot>
|
||||
<hints>
|
||||
<hint type="sourcelabel">
|
||||
<x>311</x>
|
||||
<y>83</y>
|
||||
</hint>
|
||||
<hint type="destinationlabel">
|
||||
<x>952</x>
|
||||
<y>134</y>
|
||||
</hint>
|
||||
</hints>
|
||||
</connection>
|
||||
<connection>
|
||||
<sender>rSyncEverything</sender>
|
||||
<signal>toggled(bool)</signal>
|
||||
<receiver>confTraillingSizeLabel</receiver>
|
||||
<slot>setEnabled(bool)</slot>
|
||||
<hints>
|
||||
<hint type="sourcelabel">
|
||||
<x>277</x>
|
||||
<y>76</y>
|
||||
</hint>
|
||||
<hint type="destinationlabel">
|
||||
<x>1076</x>
|
||||
<y>136</y>
|
||||
</hint>
|
||||
</hints>
|
||||
</connection>
|
||||
<connection>
|
||||
<sender>rSyncEverything</sender>
|
||||
<signal>toggled(bool)</signal>
|
||||
<receiver>confCheckBoxExternal</receiver>
|
||||
<slot>setEnabled(bool)</slot>
|
||||
<hints>
|
||||
<hint type="sourcelabel">
|
||||
<x>181</x>
|
||||
<y>78</y>
|
||||
</hint>
|
||||
<hint type="destinationlabel">
|
||||
<x>382</x>
|
||||
<y>174</y>
|
||||
</hint>
|
||||
</hints>
|
||||
</connection>
|
||||
</connections>
|
||||
<connections/>
|
||||
</ui>
|
||||
|
||||
@@ -6,8 +6,8 @@
|
||||
<rect>
|
||||
<x>0</x>
|
||||
<y>0</y>
|
||||
<width>506</width>
|
||||
<height>515</height>
|
||||
<width>602</width>
|
||||
<height>193</height>
|
||||
</rect>
|
||||
</property>
|
||||
<property name="sizePolicy">
|
||||
@@ -80,7 +80,7 @@
|
||||
<item>
|
||||
<widget class="QLabel" name="label_2">
|
||||
<property name="text">
|
||||
<string>Ser&ver Address</string>
|
||||
<string>Server &Address</string>
|
||||
</property>
|
||||
<property name="buddy">
|
||||
<cstring>leUrl</cstring>
|
||||
@@ -166,13 +166,10 @@
|
||||
<property name="orientation">
|
||||
<enum>Qt::Vertical</enum>
|
||||
</property>
|
||||
<property name="sizeType">
|
||||
<enum>QSizePolicy::MinimumExpanding</enum>
|
||||
</property>
|
||||
<property name="sizeHint" stdset="0">
|
||||
<size>
|
||||
<width>20</width>
|
||||
<height>200</height>
|
||||
<height>40</height>
|
||||
</size>
|
||||
</property>
|
||||
</spacer>
|
||||
|
||||
@@ -44,7 +44,6 @@ void OwncloudShibbolethCredsPage::setupBrowser()
|
||||
// i.e. if someone presses "back"
|
||||
QNetworkAccessManager *qnam = account->networkAccessManager();
|
||||
CookieJar *jar = new CookieJar;
|
||||
jar->restore(account->cookieJarPath());
|
||||
// Implicitly deletes the old cookie jar, and reparents the jar
|
||||
qnam->setCookieJar(jar);
|
||||
|
||||
|
||||
@@ -86,6 +86,7 @@ OwncloudWizard::OwncloudWizard(QWidget *parent)
|
||||
setTitleFormat(Qt::RichText);
|
||||
setSubTitleFormat(Qt::RichText);
|
||||
setButtonText(QWizard::CustomButton1, tr("Skip folders configuration"));
|
||||
|
||||
}
|
||||
|
||||
void OwncloudWizard::setAccount(AccountPtr account)
|
||||
@@ -108,10 +109,6 @@ QStringList OwncloudWizard::selectiveSyncBlacklist() const
|
||||
return _advancedSetupPage->selectiveSyncBlacklist();
|
||||
}
|
||||
|
||||
bool OwncloudWizard::isConfirmBigFolderChecked() const
|
||||
{
|
||||
return _advancedSetupPage->isConfirmBigFolderChecked();
|
||||
}
|
||||
|
||||
QString OwncloudWizard::ocUrl() const
|
||||
{
|
||||
|
||||
@@ -59,7 +59,6 @@ public:
|
||||
QString ocUrl() const;
|
||||
QString localFolder() const;
|
||||
QStringList selectiveSyncBlacklist() const;
|
||||
bool isConfirmBigFolderChecked() const;
|
||||
|
||||
void enableFinishOnResultWidget(bool enable);
|
||||
|
||||
|
||||
@@ -1,6 +1,8 @@
|
||||
project(libsync)
|
||||
set(CMAKE_AUTOMOC TRUE)
|
||||
|
||||
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fno-rtti")
|
||||
|
||||
configure_file( version.h.in "${CMAKE_CURRENT_BINARY_DIR}/version.h" )
|
||||
|
||||
include_directories(${CMAKE_CURRENT_SOURCE_DIR} ${CMAKE_CURRENT_BINARY_DIR})
|
||||
@@ -55,6 +57,7 @@ set(libsync_SRCS
|
||||
propagateremotedelete.cpp
|
||||
propagateremotemove.cpp
|
||||
propagateremotemkdir.cpp
|
||||
propagatefiles.cpp
|
||||
syncengine.cpp
|
||||
syncfilestatus.cpp
|
||||
syncfilestatustracker.cpp
|
||||
|
||||
@@ -172,6 +172,7 @@ void AbstractNetworkJob::slotFinished()
|
||||
|
||||
// get the Date timestamp from reply
|
||||
_responseTimestamp = _reply->rawHeader("Date");
|
||||
_duration = _durationTimer.elapsed();
|
||||
|
||||
if (_followRedirects) {
|
||||
// ### the qWarnings here should be exported via displayErrors() so they
|
||||
@@ -205,6 +206,11 @@ void AbstractNetworkJob::slotFinished()
|
||||
}
|
||||
}
|
||||
|
||||
quint64 AbstractNetworkJob::duration()
|
||||
{
|
||||
return _duration;
|
||||
}
|
||||
|
||||
QByteArray AbstractNetworkJob::responseTimestamp()
|
||||
{
|
||||
return _responseTimestamp;
|
||||
@@ -218,6 +224,8 @@ AbstractNetworkJob::~AbstractNetworkJob()
|
||||
void AbstractNetworkJob::start()
|
||||
{
|
||||
_timer.start();
|
||||
_durationTimer.start();
|
||||
_duration = 0;
|
||||
|
||||
const QUrl url = account()->url();
|
||||
const QString displayUrl = QString( "%1://%2%3").arg(url.scheme()).arg(url.host()).arg(url.path());
|
||||
|
||||
@@ -55,6 +55,7 @@ public:
|
||||
bool ignoreCredentialFailure() const { return _ignoreCredentialFailure; }
|
||||
|
||||
QByteArray responseTimestamp();
|
||||
quint64 duration();
|
||||
|
||||
qint64 timeoutMsec() { return _timer.interval(); }
|
||||
|
||||
@@ -81,6 +82,8 @@ protected:
|
||||
int maxRedirects() const { return 10; }
|
||||
virtual bool finished() = 0;
|
||||
QByteArray _responseTimestamp;
|
||||
QElapsedTimer _durationTimer;
|
||||
quint64 _duration;
|
||||
bool _timedout; // set to true when the timeout slot is received
|
||||
|
||||
// Automatically follows redirects. Note that this only works for
|
||||
|
||||
@@ -20,7 +20,6 @@
|
||||
#include "creds/abstractcredentials.h"
|
||||
#include "capabilities.h"
|
||||
#include "theme.h"
|
||||
#include "asserts.h"
|
||||
|
||||
#include <QSettings>
|
||||
#include <QMutex>
|
||||
@@ -154,9 +153,8 @@ QUrl Account::davUrl() const
|
||||
*/
|
||||
void Account::clearCookieJar()
|
||||
{
|
||||
auto jar = qobject_cast<CookieJar*>(_am->cookieJar());
|
||||
ASSERT(jar);
|
||||
jar->setAllCookies(QList<QNetworkCookie>());
|
||||
Q_ASSERT(qobject_cast<CookieJar*>(_am->cookieJar()));
|
||||
static_cast<CookieJar*>(_am->cookieJar())->setAllCookies(QList<QNetworkCookie>());
|
||||
emit wantsAccountSaved(this);
|
||||
}
|
||||
|
||||
@@ -171,12 +169,6 @@ void Account::lendCookieJarTo(QNetworkAccessManager *guest)
|
||||
jar->setParent(oldParent); // takes it back
|
||||
}
|
||||
|
||||
QString Account::cookieJarPath()
|
||||
{
|
||||
ConfigFile cfg;
|
||||
return cfg.configPath() + "/cookies" + id() + ".db";
|
||||
}
|
||||
|
||||
void Account::resetNetworkAccessManager()
|
||||
{
|
||||
if (!_credentials || !_am) {
|
||||
|
||||
@@ -172,7 +172,6 @@ public:
|
||||
|
||||
void clearCookieJar();
|
||||
void lendCookieJarTo(QNetworkAccessManager *guest);
|
||||
QString cookieJarPath();
|
||||
|
||||
void resetNetworkAccessManager();
|
||||
QNetworkAccessManager* networkAccessManager();
|
||||
|
||||
@@ -1,52 +0,0 @@
|
||||
#ifndef OWNCLOUD_ASSERTS_H
|
||||
#define OWNCLOUD_ASSERTS_H
|
||||
|
||||
#include <qglobal.h>
|
||||
|
||||
#if defined(QT_FORCE_ASSERTS) || !defined(QT_NO_DEBUG)
|
||||
#define OC_ASSERT_MSG qFatal
|
||||
#else
|
||||
#define OC_ASSERT_MSG qWarning
|
||||
#endif
|
||||
|
||||
// For overloading macros by argument count
|
||||
// See stackoverflow.com/questions/16683146/can-macros-be-overloaded-by-number-of-arguments
|
||||
#define OC_ASSERT_CAT(A, B) A ## B
|
||||
#define OC_ASSERT_SELECT(NAME, NUM) OC_ASSERT_CAT(NAME ## _, NUM)
|
||||
#define OC_ASSERT_GET_COUNT(_1, _2, _3, COUNT, ...) COUNT
|
||||
#define OC_ASSERT_VA_SIZE(...) OC_ASSERT_GET_COUNT(__VA_ARGS__, 3, 2, 1, 0)
|
||||
|
||||
#define OC_ASSERT_OVERLOAD(NAME, ...) OC_ASSERT_SELECT(NAME, OC_ASSERT_VA_SIZE(__VA_ARGS__))(__VA_ARGS__)
|
||||
|
||||
// Default assert: If the condition is false in debug builds, terminate.
|
||||
//
|
||||
// Prints a message on failure, even in release builds.
|
||||
#define ASSERT(...) OC_ASSERT_OVERLOAD(ASSERT, __VA_ARGS__)
|
||||
#define ASSERT_1(cond) \
|
||||
if (!(cond)) { \
|
||||
OC_ASSERT_MSG("ASSERT: \"%s\" in file %s, line %d", #cond, __FILE__, __LINE__); \
|
||||
} else {}
|
||||
#define ASSERT_2(cond, message) \
|
||||
if (!(cond)) { \
|
||||
OC_ASSERT_MSG("ASSERT: \"%s\" in file %s, line %d with message: %s", #cond, __FILE__, __LINE__, message); \
|
||||
} else {}
|
||||
|
||||
// Enforce condition to be true, even in release builds.
|
||||
//
|
||||
// Prints 'message' and aborts execution if 'cond' is false.
|
||||
#define ENFORCE(...) OC_ASSERT_OVERLOAD(ENFORCE, __VA_ARGS__)
|
||||
#define ENFORCE_1(cond) \
|
||||
if (!(cond)) { \
|
||||
qFatal("ENFORCE: \"%s\" in file %s, line %d", #cond, __FILE__, __LINE__); \
|
||||
} else {}
|
||||
#define ENFORCE_2(cond, message) \
|
||||
if (!(cond)) { \
|
||||
qFatal("ENFORCE: \"%s\" in file %s, line %d with message: %s", #cond, __FILE__, __LINE__, message); \
|
||||
} else {}
|
||||
|
||||
// An assert that is only present in debug builds: typically used for
|
||||
// asserts that are too expensive for release mode.
|
||||
//
|
||||
// Q_ASSERT
|
||||
|
||||
#endif
|
||||
@@ -116,6 +116,15 @@ bool Capabilities::chunkingNg() const
|
||||
return _capabilities["dav"].toMap()["chunking"].toByteArray() >= "1.0";
|
||||
}
|
||||
|
||||
bool Capabilities::scheduling() const
|
||||
{
|
||||
static const auto scheduling = qgetenv("OWNCLOUD_SCHEDULING");
|
||||
if (scheduling == "0") return false;
|
||||
if (scheduling == "1") return true;
|
||||
|
||||
return _capabilities["dav"].toMap()["scheduling"].toByteArray() >= "1.0";
|
||||
}
|
||||
|
||||
bool Capabilities::chunkingParallelUploadDisabled() const
|
||||
{
|
||||
return _capabilities["dav"].toMap()["chunkingParallelUploadDisabled"].toBool();
|
||||
|
||||
@@ -41,6 +41,7 @@ public:
|
||||
int sharePublicLinkExpireDateDays() const;
|
||||
bool shareResharing() const;
|
||||
bool chunkingNg() const;
|
||||
bool scheduling() const;
|
||||
|
||||
/// disable parallel upload in chunking
|
||||
bool chunkingParallelUploadDisabled() const;
|
||||
|
||||
@@ -111,10 +111,10 @@ bool uploadChecksumEnabled()
|
||||
QByteArray contentChecksumType()
|
||||
{
|
||||
static QByteArray type = qgetenv("OWNCLOUD_CONTENT_CHECKSUM_TYPE");
|
||||
if (type.isNull()) { // can set to "" to disable checksumming
|
||||
type = "SHA1";
|
||||
if (!type.isNull()) { // can set to "" to disable checksumming
|
||||
return type;
|
||||
}
|
||||
return type;
|
||||
return "SHA1";
|
||||
}
|
||||
|
||||
ComputeChecksum::ComputeChecksum(QObject* parent)
|
||||
|
||||
@@ -17,7 +17,6 @@
|
||||
#include "configfile.h"
|
||||
#include "theme.h"
|
||||
#include "utility.h"
|
||||
#include "asserts.h"
|
||||
|
||||
#include "creds/abstractcredentials.h"
|
||||
|
||||
@@ -53,6 +52,7 @@ static const char updateCheckIntervalC[] = "updateCheckInterval";
|
||||
static const char geometryC[] = "geometry";
|
||||
static const char timeoutC[] = "timeout";
|
||||
static const char chunkSizeC[] = "chunkSize";
|
||||
static const char smallFileSizeC[] = "smallFileSize";
|
||||
|
||||
static const char proxyHostC[] = "Proxy/host";
|
||||
static const char proxyTypeC[] = "Proxy/type";
|
||||
@@ -68,7 +68,6 @@ static const char downloadLimitC[] = "BWLimit/downloadLimit";
|
||||
|
||||
static const char newBigFolderSizeLimitC[] = "newBigFolderSizeLimit";
|
||||
static const char useNewBigFolderSizeLimitC[] = "useNewBigFolderSizeLimit";
|
||||
static const char confirmExternalStorageC[] = "confirmExternalStorage";
|
||||
|
||||
static const char maxLogLinesC[] = "Logging/maxLogLines";
|
||||
|
||||
@@ -130,6 +129,12 @@ quint64 ConfigFile::chunkSize() const
|
||||
return settings.value(QLatin1String(chunkSizeC), 10*1000*1000).toLongLong(); // default to 10 MB
|
||||
}
|
||||
|
||||
quint64 ConfigFile::smallFileSize() const
|
||||
{
|
||||
QSettings settings(configFile(), QSettings::IniFormat);
|
||||
return settings.value(QLatin1String(smallFileSizeC), 500*1000).toLongLong(); // default to 500 kB
|
||||
}
|
||||
|
||||
void ConfigFile::setOptionalDesktopNotifications(bool show)
|
||||
{
|
||||
QSettings settings(configFile(), QSettings::IniFormat);
|
||||
@@ -140,7 +145,7 @@ void ConfigFile::setOptionalDesktopNotifications(bool show)
|
||||
void ConfigFile::saveGeometry(QWidget *w)
|
||||
{
|
||||
#ifndef TOKEN_AUTH_ONLY
|
||||
ASSERT(!w->objectName().isNull());
|
||||
Q_ASSERT(!w->objectName().isNull());
|
||||
QSettings settings(configFile(), QSettings::IniFormat);
|
||||
settings.beginGroup(w->objectName());
|
||||
settings.setValue(QLatin1String(geometryC), w->saveGeometry());
|
||||
@@ -159,7 +164,7 @@ void ConfigFile::saveGeometryHeader(QHeaderView *header)
|
||||
{
|
||||
#ifndef TOKEN_AUTH_ONLY
|
||||
if(!header) return;
|
||||
ASSERT(!header->objectName().isEmpty());
|
||||
Q_ASSERT(!header->objectName().isEmpty());
|
||||
|
||||
QSettings settings(configFile(), QSettings::IniFormat);
|
||||
settings.beginGroup(header->objectName());
|
||||
@@ -172,7 +177,7 @@ void ConfigFile::restoreGeometryHeader(QHeaderView *header)
|
||||
{
|
||||
#ifndef TOKEN_AUTH_ONLY
|
||||
if(!header) return;
|
||||
ASSERT(!header->objectName().isNull());
|
||||
Q_ASSERT(!header->objectName().isNull());
|
||||
|
||||
QSettings settings(configFile(), QSettings::IniFormat);
|
||||
settings.beginGroup(header->objectName());
|
||||
@@ -231,8 +236,8 @@ QString ConfigFile::excludeFile(Scope scope) const
|
||||
// directories.
|
||||
QFileInfo fi;
|
||||
|
||||
switch (scope) {
|
||||
case UserScope:
|
||||
if (scope != SystemScope) {
|
||||
QFileInfo fi;
|
||||
fi.setFile( configPath(), exclFile );
|
||||
|
||||
if( ! fi.isReadable() ) {
|
||||
@@ -242,12 +247,12 @@ QString ConfigFile::excludeFile(Scope scope) const
|
||||
fi.setFile( configPath(), exclFile );
|
||||
}
|
||||
return fi.absoluteFilePath();
|
||||
case SystemScope:
|
||||
} else if (scope != UserScope) {
|
||||
return ConfigFile::excludeFileFromSystem();
|
||||
} else {
|
||||
Q_ASSERT(false);
|
||||
return QString(); // unreachable
|
||||
}
|
||||
|
||||
ASSERT(false);
|
||||
return QString();
|
||||
}
|
||||
|
||||
QString ConfigFile::excludeFileFromSystem()
|
||||
@@ -598,16 +603,6 @@ void ConfigFile::setNewBigFolderSizeLimit(bool isChecked, quint64 mbytes)
|
||||
setValue(useNewBigFolderSizeLimitC, isChecked);
|
||||
}
|
||||
|
||||
bool ConfigFile::confirmExternalStorage() const
|
||||
{
|
||||
return getValue(confirmExternalStorageC, QString(), true).toBool();
|
||||
}
|
||||
|
||||
void ConfigFile::setConfirmExternalStorage(bool isChecked)
|
||||
{
|
||||
setValue(confirmExternalStorageC, isChecked);
|
||||
}
|
||||
|
||||
bool ConfigFile::promptDeleteFiles() const
|
||||
{
|
||||
QSettings settings(configFile(), QSettings::IniFormat);
|
||||
|
||||
@@ -105,8 +105,6 @@ public:
|
||||
/** [checked, size in MB] **/
|
||||
QPair<bool, quint64> newBigFolderSizeLimit() const;
|
||||
void setNewBigFolderSizeLimit(bool isChecked, quint64 mbytes);
|
||||
bool confirmExternalStorage() const;
|
||||
void setConfirmExternalStorage(bool);
|
||||
|
||||
static bool setConfDir(const QString &value);
|
||||
|
||||
@@ -115,6 +113,7 @@ public:
|
||||
|
||||
int timeout() const;
|
||||
quint64 chunkSize() const;
|
||||
quint64 smallFileSize() const;
|
||||
|
||||
void saveGeometry(QWidget *w);
|
||||
void restoreGeometry(QWidget *w);
|
||||
|
||||
@@ -68,6 +68,7 @@ QDataStream &operator>>(QDataStream &stream, QList<QNetworkCookie> &list)
|
||||
CookieJar::CookieJar(QObject *parent) :
|
||||
QNetworkCookieJar(parent)
|
||||
{
|
||||
restore();
|
||||
}
|
||||
|
||||
CookieJar::~CookieJar()
|
||||
@@ -96,21 +97,21 @@ void CookieJar::clearSessionCookies()
|
||||
setAllCookies(removeExpired(allCookies()));
|
||||
}
|
||||
|
||||
void CookieJar::save(const QString &fileName)
|
||||
void CookieJar::save()
|
||||
{
|
||||
QFile file;
|
||||
file.setFileName(fileName);
|
||||
qDebug() << fileName;
|
||||
file.setFileName(storagePath());
|
||||
qDebug() << storagePath();
|
||||
file.open(QIODevice::WriteOnly);
|
||||
QDataStream stream(&file);
|
||||
stream << removeExpired(allCookies());
|
||||
file.close();
|
||||
}
|
||||
|
||||
void CookieJar::restore(const QString &fileName)
|
||||
void CookieJar::restore()
|
||||
{
|
||||
QFile file;
|
||||
file.setFileName(fileName);
|
||||
file.setFileName(storagePath());
|
||||
file.open(QIODevice::ReadOnly);
|
||||
QDataStream stream(&file);
|
||||
QList<QNetworkCookie> list;
|
||||
@@ -130,4 +131,10 @@ QList<QNetworkCookie> CookieJar::removeExpired(const QList<QNetworkCookie> &cook
|
||||
return updatedList;
|
||||
}
|
||||
|
||||
QString CookieJar::storagePath() const
|
||||
{
|
||||
ConfigFile cfg;
|
||||
return cfg.configPath() + "/cookies.db";
|
||||
}
|
||||
|
||||
} // namespace OCC
|
||||
|
||||
@@ -39,13 +39,15 @@ public:
|
||||
using QNetworkCookieJar::setAllCookies;
|
||||
using QNetworkCookieJar::allCookies;
|
||||
|
||||
void save(const QString &fileName);
|
||||
void restore(const QString &fileName);
|
||||
void save();
|
||||
|
||||
signals:
|
||||
void newCookiesForUrl(const QList<QNetworkCookie>& cookieList, const QUrl& url);
|
||||
private:
|
||||
void restore();
|
||||
QList<QNetworkCookie> removeExpired(const QList<QNetworkCookie> &cookies);
|
||||
QString storagePath() const;
|
||||
|
||||
};
|
||||
|
||||
} // namespace OCC
|
||||
|
||||
@@ -12,10 +12,10 @@
|
||||
* for more details.
|
||||
*/
|
||||
|
||||
|
||||
#include <QString>
|
||||
#include <QDebug>
|
||||
|
||||
#include "asserts.h"
|
||||
#include "creds/abstractcredentials.h"
|
||||
|
||||
namespace OCC
|
||||
@@ -28,7 +28,7 @@ AbstractCredentials::AbstractCredentials()
|
||||
|
||||
void AbstractCredentials::setAccount(Account *account)
|
||||
{
|
||||
ENFORCE(!_account, "should only setAccount once");
|
||||
Q_ASSERT(!_account);
|
||||
_account = account;
|
||||
}
|
||||
|
||||
|
||||
@@ -13,19 +13,13 @@
|
||||
*/
|
||||
|
||||
#include "discoveryphase.h"
|
||||
|
||||
#include "account.h"
|
||||
#include "theme.h"
|
||||
#include "asserts.h"
|
||||
|
||||
#include <csync_private.h>
|
||||
#include <csync_rename.h>
|
||||
|
||||
#include <qdebug.h>
|
||||
#include <QUrl>
|
||||
#include <QFileInfo>
|
||||
#include <cstring>
|
||||
|
||||
#include <QUrl>
|
||||
#include "account.h"
|
||||
#include <QFileInfo>
|
||||
|
||||
namespace OCC {
|
||||
|
||||
@@ -87,32 +81,14 @@ int DiscoveryJob::isInSelectiveSyncBlackListCallback(void *data, const char *pat
|
||||
return static_cast<DiscoveryJob*>(data)->isInSelectiveSyncBlackList(path);
|
||||
}
|
||||
|
||||
bool DiscoveryJob::checkSelectiveSyncNewFolder(const QString& path, const char *remotePerm)
|
||||
bool DiscoveryJob::checkSelectiveSyncNewFolder(const QString& path)
|
||||
{
|
||||
|
||||
if (_syncOptions._confirmExternalStorage && std::strchr(remotePerm, 'M')) {
|
||||
// 'M' in the permission means external storage.
|
||||
|
||||
/* Note: DiscoverySingleDirectoryJob::directoryListingIteratedSlot make sure that only the
|
||||
* root of a mounted storage has 'M', all sub entries have 'm' */
|
||||
|
||||
// Only allow it if the white list contains exactly this path (not parents)
|
||||
// We want to ask confirmation for external storage even if the parents where selected
|
||||
if (_selectiveSyncWhiteList.contains(path + QLatin1Char('/'))) {
|
||||
return false;
|
||||
}
|
||||
|
||||
emit newBigFolder(path, true);
|
||||
return true;
|
||||
}
|
||||
|
||||
// If this path or the parent is in the white list, then we do not block this file
|
||||
// If this path or the parent is in the white list, then we do not block this file
|
||||
if (findPathInList(_selectiveSyncWhiteList, path)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
auto limit = _syncOptions._newBigFolderSizeLimit;
|
||||
if (limit < 0) {
|
||||
if (_newBigFolderSizeLimit < 0) {
|
||||
// no limit, everything is allowed;
|
||||
return false;
|
||||
}
|
||||
@@ -126,9 +102,10 @@ bool DiscoveryJob::checkSelectiveSyncNewFolder(const QString& path, const char *
|
||||
_vioWaitCondition.wait(&_vioMutex);
|
||||
}
|
||||
|
||||
auto limit = _newBigFolderSizeLimit;
|
||||
if (result >= limit) {
|
||||
// we tell the UI there is a new folder
|
||||
emit newBigFolder(path, false);
|
||||
emit newBigFolder(path);
|
||||
return true;
|
||||
} else {
|
||||
// it is not too big, put it in the white list (so we will not do more query for the children)
|
||||
@@ -142,9 +119,9 @@ bool DiscoveryJob::checkSelectiveSyncNewFolder(const QString& path, const char *
|
||||
}
|
||||
}
|
||||
|
||||
int DiscoveryJob::checkSelectiveSyncNewFolderCallback(void *data, const char *path, const char *remotePerm)
|
||||
int DiscoveryJob::checkSelectiveSyncNewFolderCallback(void *data, const char *path)
|
||||
{
|
||||
return static_cast<DiscoveryJob*>(data)->checkSelectiveSyncNewFolder(QString::fromUtf8(path), remotePerm);
|
||||
return static_cast<DiscoveryJob*>(data)->checkSelectiveSyncNewFolder(QString::fromUtf8(path));
|
||||
}
|
||||
|
||||
|
||||
@@ -247,7 +224,7 @@ int get_errno_from_http_errcode( int err, const QString & reason ) {
|
||||
|
||||
|
||||
DiscoverySingleDirectoryJob::DiscoverySingleDirectoryJob(const AccountPtr &account, const QString &path, QObject *parent)
|
||||
: QObject(parent), _subPath(path), _account(account), _ignoredFirst(false), _isRootPath(false), _isExternalStorage(false)
|
||||
: QObject(parent), _subPath(path), _account(account), _ignoredFirst(false), _isRootPath(false)
|
||||
{
|
||||
}
|
||||
|
||||
@@ -344,9 +321,7 @@ void DiscoverySingleDirectoryJob::directoryListingIteratedSlot(QString file, con
|
||||
// The first entry is for the folder itself, we should process it differently.
|
||||
_ignoredFirst = true;
|
||||
if (map.contains("permissions")) {
|
||||
auto perm = map.value("permissions");
|
||||
emit firstDirectoryPermissions(perm);
|
||||
_isExternalStorage = perm.contains(QLatin1Char('M'));
|
||||
emit firstDirectoryPermissions(map.value("permissions"));
|
||||
}
|
||||
if (map.contains("data-fingerprint")) {
|
||||
_dataFingerprint = map.value("data-fingerprint").toUtf8();
|
||||
@@ -369,13 +344,6 @@ void DiscoverySingleDirectoryJob::directoryListingIteratedSlot(QString file, con
|
||||
if (!file_stat->etag || strlen(file_stat->etag) == 0) {
|
||||
qDebug() << "WARNING: etag of" << file_stat->name << "is" << file_stat->etag << " This must not happen.";
|
||||
}
|
||||
if (_isExternalStorage) {
|
||||
/* All the entries in a external storage have 'M' in their permission. However, for all
|
||||
purposes in the desktop client, we only need to know about the mount points.
|
||||
So replace the 'M' by a 'm' for every sub entries in an external storage */
|
||||
std::replace(file_stat->remotePerm, file_stat->remotePerm + strlen(file_stat->remotePerm),
|
||||
'M', 'm');
|
||||
}
|
||||
|
||||
QStringRef fileRef(&file);
|
||||
int slashPos = file.lastIndexOf(QLatin1Char('/'));
|
||||
|
||||
@@ -34,16 +34,6 @@ class Account;
|
||||
* if the files are new, or changed.
|
||||
*/
|
||||
|
||||
struct SyncOptions {
|
||||
SyncOptions() : _newBigFolderSizeLimit(-1), _confirmExternalStorage(false) {}
|
||||
/** Maximum size (in Bytes) a folder can have without asking for confirmation.
|
||||
* -1 means infinite */
|
||||
qint64 _newBigFolderSizeLimit;
|
||||
/** If a confirmation should be asked for external storages */
|
||||
bool _confirmExternalStorage;
|
||||
};
|
||||
|
||||
|
||||
/**
|
||||
* @brief The FileStatPointer class
|
||||
* @ingroup libsync
|
||||
@@ -117,8 +107,6 @@ private:
|
||||
bool _ignoredFirst;
|
||||
// Set to true if this is the root path and we need to check the data-fingerprint
|
||||
bool _isRootPath;
|
||||
// If this directory is an external storage (The first item has 'M' in its permission)
|
||||
bool _isExternalStorage;
|
||||
QPointer<LsColJob> _lsColJob;
|
||||
|
||||
public:
|
||||
@@ -188,8 +176,8 @@ class DiscoveryJob : public QObject {
|
||||
*/
|
||||
bool isInSelectiveSyncBlackList(const char* path) const;
|
||||
static int isInSelectiveSyncBlackListCallback(void *, const char *);
|
||||
bool checkSelectiveSyncNewFolder(const QString &path, const char *remotePerm);
|
||||
static int checkSelectiveSyncNewFolderCallback(void* data, const char* path, const char* remotePerm);
|
||||
bool checkSelectiveSyncNewFolder(const QString &path);
|
||||
static int checkSelectiveSyncNewFolderCallback(void*, const char*);
|
||||
|
||||
// Just for progress
|
||||
static void update_job_update_callback (bool local,
|
||||
@@ -209,7 +197,7 @@ class DiscoveryJob : public QObject {
|
||||
|
||||
public:
|
||||
explicit DiscoveryJob(CSYNC *ctx, QObject* parent = 0)
|
||||
: QObject(parent), _csync_ctx(ctx) {
|
||||
: QObject(parent), _csync_ctx(ctx), _newBigFolderSizeLimit(-1) {
|
||||
// We need to forward the log property as csync uses thread local
|
||||
// and updates run in another thread
|
||||
_log_callback = csync_get_log_callback();
|
||||
@@ -219,7 +207,7 @@ public:
|
||||
|
||||
QStringList _selectiveSyncBlackList;
|
||||
QStringList _selectiveSyncWhiteList;
|
||||
SyncOptions _syncOptions;
|
||||
qint64 _newBigFolderSizeLimit;
|
||||
Q_INVOKABLE void start();
|
||||
signals:
|
||||
void finished(int result);
|
||||
@@ -230,7 +218,7 @@ signals:
|
||||
void doGetSizeSignal(const QString &path, qint64 *result);
|
||||
|
||||
// A new folder was discovered and was not synced because of the confirmation feature
|
||||
void newBigFolder(const QString &folder, bool isExternal);
|
||||
void newBigFolder(const QString &folder);
|
||||
};
|
||||
|
||||
}
|
||||
|
||||
@@ -47,7 +47,7 @@ void ExcludedFiles::addExcludeFilePath(const QString& path)
|
||||
_excludeFiles.insert(path);
|
||||
}
|
||||
|
||||
#ifdef WITH_TESTING
|
||||
#ifdef WITH_UNIT_TESTING
|
||||
void ExcludedFiles::addExcludeExpr(const QString &expr)
|
||||
{
|
||||
_csync_exclude_add(_excludesPtr, expr.toLatin1().constData());
|
||||
|
||||
@@ -58,7 +58,7 @@ public:
|
||||
const QString& basePath,
|
||||
bool excludeHidden) const;
|
||||
|
||||
#ifdef WITH_TESTING
|
||||
#ifdef WITH_UNIT_TESTING
|
||||
void addExcludeExpr(const QString &expr);
|
||||
#endif
|
||||
|
||||
|
||||
@@ -25,7 +25,6 @@
|
||||
#include "configfile.h"
|
||||
#include "utility.h"
|
||||
#include "account.h"
|
||||
#include "asserts.h"
|
||||
#include <json.h>
|
||||
|
||||
#ifdef Q_OS_WIN
|
||||
@@ -173,7 +172,7 @@ void PropagateItemJob::done(SyncFileItem::Status status, const QString &errorStr
|
||||
|
||||
_item->_status = status;
|
||||
|
||||
emit itemCompleted(_item);
|
||||
emit itemCompleted(*_item, *this);
|
||||
emit finished(status);
|
||||
}
|
||||
|
||||
@@ -222,7 +221,7 @@ bool PropagateItemJob::checkForProblemsWithShared(int httpStatusCode, const QStr
|
||||
if( newJob ) {
|
||||
newJob->setRestoreJobMsg(msg);
|
||||
_restoreJob.reset(newJob);
|
||||
connect(_restoreJob.data(), SIGNAL(itemCompleted(const SyncFileItemPtr &)),
|
||||
connect(_restoreJob.data(), SIGNAL(itemCompleted(const SyncFileItemPtr &, const PropagatorJob &)),
|
||||
this, SLOT(slotRestoreJobCompleted(const SyncFileItemPtr &)));
|
||||
QMetaObject::invokeMethod(newJob, "start");
|
||||
}
|
||||
@@ -313,6 +312,8 @@ void OwncloudPropagator::start(const SyncFileItemVector& items)
|
||||
directories.push(qMakePair(QString(), _rootJob.data()));
|
||||
QVector<PropagatorJob*> directoriesToRemove;
|
||||
QString removedDirectory;
|
||||
bool enableScheduledRequests = true;
|
||||
PropagateFiles* filesJob = new PropagateFiles(this);
|
||||
foreach(const SyncFileItemPtr &item, items) {
|
||||
|
||||
if (!removedDirectory.isEmpty() && item->_file.startsWith(removedDirectory)) {
|
||||
@@ -389,6 +390,9 @@ void OwncloudPropagator::start(const SyncFileItemVector& items)
|
||||
currentDirJob->append(dir);
|
||||
}
|
||||
directories.push(qMakePair(item->destination() + "/" , dir));
|
||||
} else if (enableScheduledRequests
|
||||
&& (item->_instruction == CSYNC_INSTRUCTION_NEW || item->_instruction == CSYNC_INSTRUCTION_SYNC)) {
|
||||
filesJob->append(item);
|
||||
} else if (PropagateItemJob* current = createJob(item)) {
|
||||
if (item->_instruction == CSYNC_INSTRUCTION_TYPE_CHANGE) {
|
||||
// will delete directories, so defer execution
|
||||
@@ -400,12 +404,20 @@ void OwncloudPropagator::start(const SyncFileItemVector& items)
|
||||
}
|
||||
}
|
||||
|
||||
if (enableScheduledRequests && !filesJob->isEmpty()){
|
||||
// This job has parallelism WaitForFinished to allow directoriesToRemove be last
|
||||
_rootJob->append(filesJob);
|
||||
} else {
|
||||
delete filesJob;
|
||||
}
|
||||
|
||||
foreach(PropagatorJob* it, directoriesToRemove) {
|
||||
_rootJob->append(it);
|
||||
}
|
||||
|
||||
connect(_rootJob.data(), SIGNAL(itemCompleted(const SyncFileItemPtr &)),
|
||||
this, SIGNAL(itemCompleted(const SyncFileItemPtr &)));
|
||||
|
||||
connect(_rootJob.data(), SIGNAL(itemCompleted(const SyncFileItem &, const PropagatorJob &)),
|
||||
this, SIGNAL(itemCompleted(const SyncFileItem &, const PropagatorJob &)));
|
||||
connect(_rootJob.data(), SIGNAL(progress(const SyncFileItem &,quint64)), this, SIGNAL(progress(const SyncFileItem &,quint64)));
|
||||
connect(_rootJob.data(), SIGNAL(finished(SyncFileItem::Status)), this, SLOT(emitFinished(SyncFileItem::Status)));
|
||||
connect(_rootJob.data(), SIGNAL(ready()), this, SLOT(scheduleNextJob()), Qt::QueuedConnection);
|
||||
@@ -459,6 +471,20 @@ quint64 OwncloudPropagator::chunkSize()
|
||||
return chunkSize;
|
||||
}
|
||||
|
||||
quint64 OwncloudPropagator::smallFileSize()
|
||||
{
|
||||
// A small filesize item is a file whose transfer time
|
||||
// typically will be lower than its bookkeeping time.
|
||||
static uint smallFileSize;
|
||||
if (!smallFileSize) {
|
||||
smallFileSize = qgetenv("OWNCLOUD_SMALLFILE_SIZE").toUInt();
|
||||
if (smallFileSize == 0) {
|
||||
ConfigFile cfg;
|
||||
smallFileSize = cfg.smallFileSize();
|
||||
}
|
||||
}
|
||||
return smallFileSize;
|
||||
}
|
||||
|
||||
bool OwncloudPropagator::localFileNameClash( const QString& relFile )
|
||||
{
|
||||
@@ -589,12 +615,17 @@ OwncloudPropagator *PropagatorJob::propagator() const
|
||||
PropagatorJob::JobParallelism PropagateDirectory::parallelism()
|
||||
{
|
||||
// If any of the non-finished sub jobs is not parallel, we have to wait
|
||||
if (_firstJob && _firstJob->parallelism() != FullParallelism) {
|
||||
return WaitForFinished;
|
||||
|
||||
// FIXME! we should probably cache this result
|
||||
|
||||
if (_firstJob && _firstJob->_state != Finished) {
|
||||
if (_firstJob->parallelism() != FullParallelism)
|
||||
return WaitForFinished;
|
||||
}
|
||||
|
||||
// FIXME: use the cached value of finished job
|
||||
for (int i = 0; i < _subJobs.count(); ++i) {
|
||||
if (_subJobs.at(i)->parallelism() != FullParallelism) {
|
||||
if (_subJobs.at(i)->_state != Finished && _subJobs.at(i)->parallelism() != FullParallelism) {
|
||||
return WaitForFinished;
|
||||
}
|
||||
}
|
||||
@@ -625,8 +656,15 @@ bool PropagateDirectory::scheduleNextJob()
|
||||
return false;
|
||||
}
|
||||
|
||||
// cache the value of first unfinished subjob
|
||||
bool stopAtDirectory = false;
|
||||
for (int i = 0; i < _subJobs.size(); ++i) {
|
||||
int i = _firstUnfinishedSubJob;
|
||||
int subJobsCount = _subJobs.count();
|
||||
while (i < subJobsCount && _subJobs.at(i)->_state == Finished) {
|
||||
_firstUnfinishedSubJob = ++i;
|
||||
}
|
||||
|
||||
for (int i = _firstUnfinishedSubJob; i < subJobsCount; ++i) {
|
||||
if (_subJobs.at(i)->_state == Finished) {
|
||||
continue;
|
||||
}
|
||||
@@ -639,7 +677,7 @@ bool PropagateDirectory::scheduleNextJob()
|
||||
return true;
|
||||
}
|
||||
|
||||
ASSERT(_subJobs.at(i)->_state == Running);
|
||||
Q_ASSERT(_subJobs.at(i)->_state == Running);
|
||||
|
||||
auto paral = _subJobs.at(i)->parallelism();
|
||||
if (paral == WaitForFinished) {
|
||||
@@ -654,23 +692,8 @@ bool PropagateDirectory::scheduleNextJob()
|
||||
|
||||
void PropagateDirectory::slotSubJobFinished(SyncFileItem::Status status)
|
||||
{
|
||||
PropagatorJob *subJob = static_cast<PropagatorJob *>(sender());
|
||||
ASSERT(subJob);
|
||||
|
||||
// Delete the job and remove it from our list of jobs.
|
||||
subJob->deleteLater();
|
||||
bool wasFirstJob = false;
|
||||
if (subJob == _firstJob.data()) {
|
||||
wasFirstJob = true;
|
||||
_firstJob.reset();
|
||||
} else {
|
||||
int i = _subJobs.indexOf(subJob);
|
||||
ASSERT(i >= 0);
|
||||
_subJobs.remove(i);
|
||||
}
|
||||
|
||||
if (status == SyncFileItem::FatalError ||
|
||||
(wasFirstJob && status != SyncFileItem::Success && status != SyncFileItem::Restoration)) {
|
||||
(sender() == _firstJob.data() && status != SyncFileItem::Success && status != SyncFileItem::Restoration)) {
|
||||
abort();
|
||||
_state = Finished;
|
||||
emit finished(status);
|
||||
@@ -678,10 +701,18 @@ void PropagateDirectory::slotSubJobFinished(SyncFileItem::Status status)
|
||||
} else if (status == SyncFileItem::NormalError || status == SyncFileItem::SoftError) {
|
||||
_hasError = status;
|
||||
}
|
||||
_runningNow--;
|
||||
_jobsFinished++;
|
||||
|
||||
int totalJobs = _subJobs.count();
|
||||
if (_firstJob) {
|
||||
totalJobs++;
|
||||
}
|
||||
|
||||
// We finished processing all the jobs
|
||||
// check if we finished
|
||||
if (!_firstJob && _subJobs.isEmpty()) {
|
||||
if (_jobsFinished >= totalJobs) {
|
||||
Q_ASSERT(!_runningNow); // how can we be finished if there are still jobs running now
|
||||
finalize();
|
||||
} else {
|
||||
emit ready();
|
||||
@@ -761,7 +792,7 @@ void CleanupPollsJob::start()
|
||||
void CleanupPollsJob::slotPollFinished()
|
||||
{
|
||||
PollJob *job = qobject_cast<PollJob *>(sender());
|
||||
ASSERT(job);
|
||||
Q_ASSERT(job);
|
||||
if (job->_item->_status == SyncFileItem::FatalError) {
|
||||
emit aborted(job->_item->_errorString);
|
||||
deleteLater();
|
||||
|
||||
@@ -114,7 +114,7 @@ signals:
|
||||
/**
|
||||
* Emitted when one item has been completed within a job.
|
||||
*/
|
||||
void itemCompleted(const SyncFileItemPtr &);
|
||||
void itemCompleted(const SyncFileItem &, const PropagatorJob &);
|
||||
|
||||
/**
|
||||
* Emitted when all the sub-jobs have been finished and
|
||||
@@ -192,11 +192,14 @@ public:
|
||||
|
||||
SyncFileItemPtr _item;
|
||||
|
||||
int _jobsFinished; // number of jobs that have completed
|
||||
int _runningNow; // number of subJobs running right now
|
||||
SyncFileItem::Status _hasError; // NoStatus, or NormalError / SoftError if there was an error
|
||||
int _firstUnfinishedSubJob;
|
||||
|
||||
explicit PropagateDirectory(OwncloudPropagator *propagator, const SyncFileItemPtr &item = SyncFileItemPtr(new SyncFileItem))
|
||||
: PropagatorJob(propagator)
|
||||
, _item(item), _hasError(SyncFileItem::NoStatus)
|
||||
, _firstJob(0), _item(item), _jobsFinished(0), _runningNow(0), _hasError(SyncFileItem::NoStatus), _firstUnfinishedSubJob(0)
|
||||
{ }
|
||||
|
||||
virtual ~PropagateDirectory() {
|
||||
@@ -228,9 +231,11 @@ private slots:
|
||||
bool possiblyRunNextJob(PropagatorJob *next) {
|
||||
if (next->_state == NotYetStarted) {
|
||||
connect(next, SIGNAL(finished(SyncFileItem::Status)), this, SLOT(slotSubJobFinished(SyncFileItem::Status)), Qt::QueuedConnection);
|
||||
connect(next, SIGNAL(itemCompleted(const SyncFileItemPtr &)), this, SIGNAL(itemCompleted(const SyncFileItemPtr &)));
|
||||
connect(next, SIGNAL(itemCompleted(const SyncFileItem &, const PropagatorJob &)),
|
||||
this, SIGNAL(itemCompleted(const SyncFileItem &, const PropagatorJob &)));
|
||||
connect(next, SIGNAL(progress(const SyncFileItem &,quint64)), this, SIGNAL(progress(const SyncFileItem &,quint64)));
|
||||
connect(next, SIGNAL(ready()), this, SIGNAL(ready()));
|
||||
_runningNow++;
|
||||
}
|
||||
return next->scheduleNextJob();
|
||||
}
|
||||
@@ -257,7 +262,6 @@ public:
|
||||
class OwncloudPropagator : public QObject {
|
||||
Q_OBJECT
|
||||
|
||||
PropagateItemJob *createJob(const SyncFileItemPtr& item);
|
||||
QScopedPointer<PropagateDirectory> _rootJob;
|
||||
|
||||
public:
|
||||
@@ -322,6 +326,7 @@ public:
|
||||
|
||||
/** returns the size of chunks in bytes */
|
||||
static quint64 chunkSize();
|
||||
static quint64 smallFileSize();
|
||||
|
||||
AccountPtr account() const;
|
||||
|
||||
@@ -337,7 +342,11 @@ public:
|
||||
*/
|
||||
DiskSpaceResult diskSpaceCheck() const;
|
||||
|
||||
PropagateItemJob *createJob(const SyncFileItemPtr& item);
|
||||
|
||||
int runningAtRootJob(){
|
||||
return _rootJob.data()->_runningNow;
|
||||
}
|
||||
|
||||
private slots:
|
||||
|
||||
@@ -351,7 +360,7 @@ private slots:
|
||||
void scheduleNextJob();
|
||||
|
||||
signals:
|
||||
void itemCompleted(const SyncFileItemPtr &);
|
||||
void itemCompleted(const SyncFileItem &, const PropagatorJob &);
|
||||
void progress(const SyncFileItem&, quint64 bytes);
|
||||
void finished(bool success);
|
||||
|
||||
@@ -410,6 +419,106 @@ private slots:
|
||||
void slotPollFinished();
|
||||
};
|
||||
|
||||
/**
|
||||
* @brief The PropagateFiles class is a container class.
|
||||
*
|
||||
* It will also ensure proper bandwidth utilization vs bookkeeping balance
|
||||
*
|
||||
* @ingroup libsync
|
||||
*
|
||||
* State Machine:
|
||||
*
|
||||
* _________________________________________________ ___________________________________________
|
||||
* | | |
|
||||
* | (Empty DB items queue and populated Data items queue?) |
|
||||
* | | | |
|
||||
* | Yes | | No |
|
||||
* | | | |
|
||||
* |<-----------[Schedule Data job] (Empty Data items queue and populated DB items queue?) |
|
||||
* | | | |
|
||||
* | No | | Yes |
|
||||
* | | | |
|
||||
* | | [Schedule DB job]--------------->|
|
||||
* | | |
|
||||
* | | |
|
||||
* | (Populated Data items queue and populated DB items queue?) |
|
||||
* | | | |
|
||||
* | Yes | | No |
|
||||
* | | | |
|
||||
* | (Active running Data items number exceeded limit?) [Finish - no items] |
|
||||
* | | | |
|
||||
* | No | | Yes |
|
||||
* | | | |
|
||||
* <---[Schedule Data job] [Schedule DB job]------------------------------------------>
|
||||
*
|
||||
*
|
||||
*/
|
||||
class PropagateFiles : public PropagatorJob {
|
||||
Q_OBJECT
|
||||
public:
|
||||
QVector<PropagatorJob *> _subJobs;
|
||||
|
||||
QVector<SyncFileItemPtr> _syncDBItems; // Items which bookkeeping on the server is longer then the transfer of its payload
|
||||
|
||||
QVector<SyncFileItemPtr> _syncDataItems; // Items which transfer of the payload is longer then bookkeeping on the server
|
||||
|
||||
int _jobsFinished; // number of jobs that have completed
|
||||
SyncFileItem::Status _hasError; // NoStatus, or NormalError / SoftError if there was an error
|
||||
int _firstUnfinishedSubJob;
|
||||
int _totalItems;
|
||||
int _activeDBJobsNow;
|
||||
int _activeDataJobsNow;
|
||||
|
||||
explicit PropagateFiles(OwncloudPropagator *propagator)
|
||||
: PropagatorJob(propagator)
|
||||
, _jobsFinished(0), _hasError(SyncFileItem::NoStatus), _firstUnfinishedSubJob(0), _totalItems(0), _activeDBJobsNow(0), _activeDataJobsNow(0) { }
|
||||
|
||||
virtual ~PropagateFiles() {
|
||||
qDeleteAll(_subJobs);
|
||||
}
|
||||
|
||||
bool isEmpty() {
|
||||
return _syncDBItems.isEmpty() && _syncDataItems.isEmpty();
|
||||
}
|
||||
|
||||
void append(const SyncFileItemPtr &item);
|
||||
virtual bool scheduleNextJob() Q_DECL_OVERRIDE;
|
||||
bool scheduleNewJob(QVector<SyncFileItemPtr> &syncJobs);
|
||||
bool scheduleNextItem();
|
||||
|
||||
virtual void abort() Q_DECL_OVERRIDE {
|
||||
foreach (PropagatorJob *n, _subJobs)
|
||||
n->abort();
|
||||
}
|
||||
|
||||
void finalize();
|
||||
|
||||
qint64 committedDiskSpace() const Q_DECL_OVERRIDE;
|
||||
|
||||
JobParallelism parallelism() Q_DECL_OVERRIDE { return OCC::PropagatorJob::WaitForFinished; }
|
||||
|
||||
private slots:
|
||||
bool possiblyRunNextJob(PropagatorJob *next) {
|
||||
if (next->_state == NotYetStarted) {
|
||||
connect(next, SIGNAL(finished(SyncFileItem::Status)), this, SLOT(slotSubJobFinished(SyncFileItem::Status)), Qt::QueuedConnection);
|
||||
connect(next, SIGNAL(itemCompleted(const SyncFileItem &, const PropagatorJob &)),
|
||||
this, SIGNAL(itemCompleted(const SyncFileItem &, const PropagatorJob &)));
|
||||
connect(next, SIGNAL(progress(const SyncFileItem &,quint64)), this, SIGNAL(progress(const SyncFileItem &,quint64)));
|
||||
connect(next, SIGNAL(ready()), this, SIGNAL(ready()));
|
||||
|
||||
PropagateItemJob *job = qobject_cast<PropagateItemJob *>(next);
|
||||
if(job->_item->_size <= propagator()->smallFileSize()){
|
||||
_activeDBJobsNow++;
|
||||
} else {
|
||||
_activeDataJobsNow++;
|
||||
}
|
||||
}
|
||||
return next->scheduleNextJob();
|
||||
}
|
||||
|
||||
void slotSubJobFinished(SyncFileItem::Status status);
|
||||
};
|
||||
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
+59
-56
@@ -20,7 +20,6 @@
|
||||
|
||||
#include "ownsql.h"
|
||||
#include "utility.h"
|
||||
#include "asserts.h"
|
||||
|
||||
#define SQLITE_SLEEP_TIME_USEC 100000
|
||||
#define SQLITE_REPEAT_COUNT 20
|
||||
@@ -148,8 +147,10 @@ void SqlDatabase::close()
|
||||
{
|
||||
if( _db ) {
|
||||
SQLITE_DO(sqlite3_close(_db) );
|
||||
// Fatal because reopening an unclosed db might be problematic.
|
||||
ENFORCE(_errId == SQLITE_OK, "Error when closing DB");
|
||||
if (_errId != SQLITE_OK) {
|
||||
qWarning() << "ERROR When closing DB" << _error;
|
||||
Q_ASSERT(!"SQLite Close Error");
|
||||
}
|
||||
_db = 0;
|
||||
}
|
||||
}
|
||||
@@ -222,7 +223,11 @@ int SqlQuery::prepare( const QString& sql, bool allow_failure )
|
||||
if( _errId != SQLITE_OK ) {
|
||||
_error = QString::fromUtf8(sqlite3_errmsg(_db));
|
||||
qWarning() << "Sqlite prepare statement error:" << _error << "in" <<_sql;
|
||||
ENFORCE(allow_failure, "SQLITE Prepare error");
|
||||
if (!allow_failure) {
|
||||
qFatal("SQLITE Prepare error: %s in %s",
|
||||
_error.toLocal8Bit().data(),
|
||||
sql.toLocal8Bit().data());
|
||||
}
|
||||
}
|
||||
}
|
||||
return _errId;
|
||||
@@ -279,63 +284,61 @@ bool SqlQuery::next()
|
||||
void SqlQuery::bindValue(int pos, const QVariant& value)
|
||||
{
|
||||
int res = -1;
|
||||
if (!_stmt) {
|
||||
ASSERT(false);
|
||||
return;
|
||||
}
|
||||
|
||||
switch (value.type()) {
|
||||
case QVariant::Int:
|
||||
case QVariant::Bool:
|
||||
res = sqlite3_bind_int(_stmt, pos, value.toInt());
|
||||
break;
|
||||
case QVariant::Double:
|
||||
res = sqlite3_bind_double(_stmt, pos, value.toDouble());
|
||||
break;
|
||||
case QVariant::UInt:
|
||||
case QVariant::LongLong:
|
||||
res = sqlite3_bind_int64(_stmt, pos, value.toLongLong());
|
||||
break;
|
||||
case QVariant::DateTime: {
|
||||
const QDateTime dateTime = value.toDateTime();
|
||||
const QString str = dateTime.toString(QLatin1String("yyyy-MM-ddThh:mm:ss.zzz"));
|
||||
res = sqlite3_bind_text16(_stmt, pos, str.utf16(),
|
||||
str.size() * sizeof(ushort), SQLITE_TRANSIENT);
|
||||
break;
|
||||
}
|
||||
case QVariant::Time: {
|
||||
const QTime time = value.toTime();
|
||||
const QString str = time.toString(QLatin1String("hh:mm:ss.zzz"));
|
||||
res = sqlite3_bind_text16(_stmt, pos, str.utf16(),
|
||||
str.size() * sizeof(ushort), SQLITE_TRANSIENT);
|
||||
break;
|
||||
}
|
||||
case QVariant::String: {
|
||||
if( !value.toString().isNull() ) {
|
||||
// lifetime of string == lifetime of its qvariant
|
||||
const QString *str = static_cast<const QString*>(value.constData());
|
||||
res = sqlite3_bind_text16(_stmt, pos, str->utf16(),
|
||||
(str->size()) * sizeof(QChar), SQLITE_TRANSIENT);
|
||||
} else {
|
||||
res = sqlite3_bind_null(_stmt, pos);
|
||||
Q_ASSERT(_stmt);
|
||||
if( _stmt ) {
|
||||
switch (value.type()) {
|
||||
case QVariant::Int:
|
||||
case QVariant::Bool:
|
||||
res = sqlite3_bind_int(_stmt, pos, value.toInt());
|
||||
break;
|
||||
case QVariant::Double:
|
||||
res = sqlite3_bind_double(_stmt, pos, value.toDouble());
|
||||
break;
|
||||
case QVariant::UInt:
|
||||
case QVariant::LongLong:
|
||||
res = sqlite3_bind_int64(_stmt, pos, value.toLongLong());
|
||||
break;
|
||||
case QVariant::DateTime: {
|
||||
const QDateTime dateTime = value.toDateTime();
|
||||
const QString str = dateTime.toString(QLatin1String("yyyy-MM-ddThh:mm:ss.zzz"));
|
||||
res = sqlite3_bind_text16(_stmt, pos, str.utf16(),
|
||||
str.size() * sizeof(ushort), SQLITE_TRANSIENT);
|
||||
break;
|
||||
}
|
||||
case QVariant::Time: {
|
||||
const QTime time = value.toTime();
|
||||
const QString str = time.toString(QLatin1String("hh:mm:ss.zzz"));
|
||||
res = sqlite3_bind_text16(_stmt, pos, str.utf16(),
|
||||
str.size() * sizeof(ushort), SQLITE_TRANSIENT);
|
||||
break;
|
||||
}
|
||||
case QVariant::String: {
|
||||
if( !value.toString().isNull() ) {
|
||||
// lifetime of string == lifetime of its qvariant
|
||||
const QString *str = static_cast<const QString*>(value.constData());
|
||||
res = sqlite3_bind_text16(_stmt, pos, str->utf16(),
|
||||
(str->size()) * sizeof(QChar), SQLITE_TRANSIENT);
|
||||
} else {
|
||||
res = sqlite3_bind_null(_stmt, pos);
|
||||
}
|
||||
break; }
|
||||
case QVariant::ByteArray: {
|
||||
auto ba = value.toByteArray();
|
||||
res = sqlite3_bind_text(_stmt, pos, ba.constData(), ba.size(), SQLITE_TRANSIENT);
|
||||
break;
|
||||
}
|
||||
default: {
|
||||
QString str = value.toString();
|
||||
// SQLITE_TRANSIENT makes sure that sqlite buffers the data
|
||||
res = sqlite3_bind_text16(_stmt, pos, str.utf16(),
|
||||
(str.size()) * sizeof(QChar), SQLITE_TRANSIENT);
|
||||
break; }
|
||||
}
|
||||
break; }
|
||||
case QVariant::ByteArray: {
|
||||
auto ba = value.toByteArray();
|
||||
res = sqlite3_bind_text(_stmt, pos, ba.constData(), ba.size(), SQLITE_TRANSIENT);
|
||||
break;
|
||||
}
|
||||
default: {
|
||||
QString str = value.toString();
|
||||
// SQLITE_TRANSIENT makes sure that sqlite buffers the data
|
||||
res = sqlite3_bind_text16(_stmt, pos, str.utf16(),
|
||||
(str.size()) * sizeof(QChar), SQLITE_TRANSIENT);
|
||||
break; }
|
||||
}
|
||||
if (res != SQLITE_OK) {
|
||||
qDebug() << Q_FUNC_INFO << "ERROR" << value << res;
|
||||
}
|
||||
ASSERT( res == SQLITE_OK );
|
||||
Q_ASSERT( res == SQLITE_OK );
|
||||
}
|
||||
|
||||
bool SqlQuery::nullValue(int index)
|
||||
|
||||
@@ -28,6 +28,8 @@
|
||||
|
||||
namespace OCC {
|
||||
|
||||
class PropagatorJob;
|
||||
|
||||
/**
|
||||
* @brief The ProgressInfo class
|
||||
* @ingroup libsync
|
||||
@@ -250,7 +252,9 @@ signals:
|
||||
/**
|
||||
* @brief: the item was completed by a job
|
||||
*/
|
||||
void itemCompleted(const QString &folder, const SyncFileItemPtr & item);
|
||||
void itemCompleted(const QString &folder,
|
||||
const SyncFileItem & item,
|
||||
const PropagatorJob & job);
|
||||
|
||||
protected:
|
||||
void setProgressInfo(const QString& folder, const ProgressInfo& progress);
|
||||
|
||||
@@ -23,7 +23,6 @@
|
||||
#include "filesystem.h"
|
||||
#include "propagatorjobs.h"
|
||||
#include "checksums.h"
|
||||
#include "asserts.h"
|
||||
|
||||
#include <json.h>
|
||||
#include <QNetworkAccessManager>
|
||||
@@ -442,7 +441,7 @@ void PropagateDownloadFile::slotGetFinished()
|
||||
propagator()->_activeJobList.removeOne(this);
|
||||
|
||||
GETFileJob *job = qobject_cast<GETFileJob *>(sender());
|
||||
ASSERT(job);
|
||||
Q_ASSERT(job);
|
||||
|
||||
qDebug() << Q_FUNC_INFO << job->reply()->request().url() << "FINISHED WITH STATUS"
|
||||
<< job->reply()->error()
|
||||
@@ -521,6 +520,7 @@ void PropagateDownloadFile::slotGetFinished()
|
||||
// so make sure we have the up-to-date time
|
||||
_item->_modtime = job->lastModified();
|
||||
}
|
||||
_item->_requestDuration = job->duration();
|
||||
_item->_responseTimeStamp = job->responseTimestamp();
|
||||
|
||||
_tmpFile.close();
|
||||
|
||||
@@ -115,7 +115,7 @@ public:
|
||||
qint64 committedDiskSpace() const Q_DECL_OVERRIDE;
|
||||
|
||||
// We think it might finish quickly because it is a small file.
|
||||
bool isLikelyFinishedQuickly() Q_DECL_OVERRIDE { return _item->_size < 100*1024; }
|
||||
bool isLikelyFinishedQuickly() Q_DECL_OVERRIDE { return _item->_size < propagator()->smallFileSize(); }
|
||||
|
||||
/**
|
||||
* Whether an existing folder with the same name may be deleted before
|
||||
|
||||
@@ -0,0 +1,158 @@
|
||||
/*
|
||||
* Copyright (C) by Piotr Mrowczynski <piotr@owncloud.com>
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation; either version 2 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful, but
|
||||
* WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
|
||||
* or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
|
||||
* for more details.
|
||||
*/
|
||||
|
||||
#include "owncloudpropagator.h"
|
||||
|
||||
namespace OCC {
|
||||
|
||||
|
||||
qint64 PropagateFiles::committedDiskSpace() const
|
||||
{
|
||||
qint64 needed = 0;
|
||||
foreach (PropagatorJob* job, _subJobs) {
|
||||
needed += job->committedDiskSpace();
|
||||
}
|
||||
return needed;
|
||||
}
|
||||
|
||||
void PropagateFiles::append(const SyncFileItemPtr &item)
|
||||
{
|
||||
_totalItems++;
|
||||
if(item->_size <= propagator()->smallFileSize()){
|
||||
_syncDBItems.append(item);
|
||||
} else {
|
||||
_syncDataItems.append(item);
|
||||
}
|
||||
}
|
||||
|
||||
bool PropagateFiles::scheduleNextJob()
|
||||
{
|
||||
if (_state == Finished) {
|
||||
return false;
|
||||
}
|
||||
|
||||
if (_state == NotYetStarted) {
|
||||
_state = Running;
|
||||
|
||||
if (isEmpty()) {
|
||||
finalize();
|
||||
return true;
|
||||
}
|
||||
_subJobs.reserve(_totalItems);
|
||||
}
|
||||
|
||||
if (_state == Running) {
|
||||
// This will ensure that all other jobs in the earlier PropagateDirectory are finished, so we can start with data transfers
|
||||
if (propagator()->runningAtRootJob() != 1){
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
// cache the value of first unfinished subjob
|
||||
int i = _firstUnfinishedSubJob;
|
||||
int subJobsCount = _subJobs.count();
|
||||
while (i < subJobsCount && _subJobs.at(i)->_state == Finished) {
|
||||
_firstUnfinishedSubJob = ++i;
|
||||
}
|
||||
for (int i = _firstUnfinishedSubJob; i < subJobsCount; ++i) {
|
||||
if (_subJobs.at(i)->_state == Finished) {
|
||||
continue;
|
||||
}
|
||||
|
||||
if (possiblyRunNextJob(_subJobs.at(i))) {
|
||||
return true;
|
||||
}
|
||||
|
||||
Q_ASSERT(_subJobs.at(i)->_state == Running);
|
||||
}
|
||||
|
||||
return scheduleNextItem();
|
||||
}
|
||||
|
||||
bool PropagateFiles::scheduleNewJob(QVector<SyncFileItemPtr> &syncJobs){
|
||||
// This function is used to schedule new job and lazily create job from sync items
|
||||
Q_ASSERT(!syncJobs.isEmpty());
|
||||
const SyncFileItemPtr &item = syncJobs.takeFirst();
|
||||
PropagateItemJob* job = propagator()->createJob(item);
|
||||
_subJobs.append(job);
|
||||
return possiblyRunNextJob(job);
|
||||
}
|
||||
|
||||
bool PropagateFiles::scheduleNextItem()
|
||||
{
|
||||
/// This function holds the whole bookkeeping/data-transfers balance logic
|
||||
|
||||
bool syncDBItemsEmpty = _syncDBItems.isEmpty();
|
||||
bool syncDataItemsEmpty = _syncDataItems.isEmpty();
|
||||
|
||||
if (syncDBItemsEmpty && !syncDataItemsEmpty){
|
||||
// There are no more DB jobs, ensure to maximally parallelise Data Transfers now
|
||||
return scheduleNewJob(_syncDataItems);
|
||||
} else if (!syncDBItemsEmpty && syncDataItemsEmpty){
|
||||
// There are no more data transfer jobs, ensure to maximally parallelise DB jobs now
|
||||
return scheduleNewJob(_syncDBItems);
|
||||
} else if (!syncDBItemsEmpty && !syncDataItemsEmpty){
|
||||
// Both queues have items, ensure bookkeeping and data transfer balance
|
||||
if (_activeDataJobsNow < 2){
|
||||
// By default, we have max 3 connections available for bigger files
|
||||
// On the other hand, we have max 6 for isLikelyToFinishQuickly files (also small files)
|
||||
// It makes sense to use 2 queues for bigger data transfers, and leave the remaining 1-4 for faster operations
|
||||
return scheduleNewJob(_syncDataItems);
|
||||
} else {
|
||||
return scheduleNewJob(_syncDBItems);
|
||||
}
|
||||
}
|
||||
|
||||
// This means that we have no more file-items to sync -> finish
|
||||
return false;
|
||||
}
|
||||
|
||||
void PropagateFiles::slotSubJobFinished(SyncFileItem::Status status)
|
||||
{
|
||||
if (status == SyncFileItem::FatalError) {
|
||||
abort();
|
||||
_state = Finished;
|
||||
emit finished(status);
|
||||
return;
|
||||
} else if (status == SyncFileItem::NormalError || status == SyncFileItem::SoftError) {
|
||||
_hasError = status;
|
||||
}
|
||||
|
||||
PropagateItemJob *job = qobject_cast<PropagateItemJob *>(sender());
|
||||
if(job->_item->_size <= propagator()->smallFileSize()){
|
||||
_activeDBJobsNow--;
|
||||
} else {
|
||||
_activeDataJobsNow--;
|
||||
}
|
||||
Q_ASSERT(job);
|
||||
|
||||
_jobsFinished++;
|
||||
|
||||
// We finished processing all the jobs
|
||||
// check if we finished
|
||||
if (_jobsFinished >= _totalItems) {
|
||||
Q_ASSERT(!_activeDBJobsNow && !_activeDataJobsNow); // how can we be finished if there are still jobs running now
|
||||
finalize();
|
||||
} else {
|
||||
emit ready();
|
||||
}
|
||||
}
|
||||
|
||||
void PropagateFiles::finalize()
|
||||
{
|
||||
_state = Finished;
|
||||
emit finished(_hasError == SyncFileItem::NoStatus ? SyncFileItem::Success : _hasError);
|
||||
}
|
||||
|
||||
}
|
||||
@@ -15,7 +15,6 @@
|
||||
#include "propagateremotedelete.h"
|
||||
#include "owncloudpropagator_p.h"
|
||||
#include "account.h"
|
||||
#include "asserts.h"
|
||||
|
||||
namespace OCC {
|
||||
|
||||
@@ -82,7 +81,7 @@ void PropagateRemoteDelete::slotDeleteJobFinished()
|
||||
{
|
||||
propagator()->_activeJobList.removeOne(this);
|
||||
|
||||
ASSERT(_job);
|
||||
Q_ASSERT(_job);
|
||||
|
||||
qDebug() << Q_FUNC_INFO << _job->reply()->request().url() << "FINISHED WITH STATUS"
|
||||
<< _job->reply()->error()
|
||||
@@ -105,6 +104,7 @@ void PropagateRemoteDelete::slotDeleteJobFinished()
|
||||
return;
|
||||
}
|
||||
|
||||
_item->_requestDuration = _job->duration();
|
||||
_item->_responseTimeStamp = _job->responseTimestamp();
|
||||
|
||||
// A 404 reply is also considered a success here: We want to make sure
|
||||
|
||||
@@ -17,7 +17,6 @@
|
||||
#include "account.h"
|
||||
#include "syncjournalfilerecord.h"
|
||||
#include "propagateremotedelete.h"
|
||||
#include "asserts.h"
|
||||
#include <QFile>
|
||||
|
||||
namespace OCC {
|
||||
@@ -71,7 +70,7 @@ void PropagateRemoteMkdir::slotMkcolJobFinished()
|
||||
{
|
||||
propagator()->_activeJobList.removeOne(this);
|
||||
|
||||
ASSERT(_job);
|
||||
Q_ASSERT(_job);
|
||||
|
||||
qDebug() << Q_FUNC_INFO << _job->reply()->request().url() << "FINISHED WITH STATUS"
|
||||
<< _job->reply()->error()
|
||||
@@ -100,6 +99,7 @@ void PropagateRemoteMkdir::slotMkcolJobFinished()
|
||||
return;
|
||||
}
|
||||
|
||||
_item->_requestDuration = _job->duration();
|
||||
_item->_responseTimeStamp = _job->responseTimestamp();
|
||||
_item->_fileId = _job->reply()->rawHeader("OC-FileId");
|
||||
|
||||
|
||||
@@ -18,7 +18,6 @@
|
||||
#include "account.h"
|
||||
#include "syncjournalfilerecord.h"
|
||||
#include "filesystem.h"
|
||||
#include "asserts.h"
|
||||
#include <QFile>
|
||||
#include <QStringList>
|
||||
#include <QDir>
|
||||
@@ -124,7 +123,7 @@ void PropagateRemoteMove::slotMoveJobFinished()
|
||||
{
|
||||
propagator()->_activeJobList.removeOne(this);
|
||||
|
||||
ASSERT(_job);
|
||||
Q_ASSERT(_job);
|
||||
|
||||
qDebug() << Q_FUNC_INFO << _job->reply()->request().url() << "FINISHED WITH STATUS"
|
||||
<< _job->reply()->error()
|
||||
@@ -146,6 +145,7 @@ void PropagateRemoteMove::slotMoveJobFinished()
|
||||
return;
|
||||
}
|
||||
|
||||
_item->_requestDuration = _job->duration();
|
||||
_item->_responseTimeStamp = _job->responseTimestamp();
|
||||
|
||||
if (_item->_httpErrorCode != 201 ) {
|
||||
@@ -208,8 +208,8 @@ bool PropagateRemoteMove::adjustSelectiveSync(SyncJournalDb *journal, const QStr
|
||||
return false;
|
||||
|
||||
bool changed = false;
|
||||
ASSERT(!from_.endsWith(QLatin1String("/")));
|
||||
ASSERT(!to_.endsWith(QLatin1String("/")));
|
||||
Q_ASSERT(!from_.endsWith(QLatin1String("/")));
|
||||
Q_ASSERT(!to_.endsWith(QLatin1String("/")));
|
||||
QString from = from_ + QLatin1String("/");
|
||||
QString to = to_ + QLatin1String("/");
|
||||
|
||||
|
||||
@@ -25,7 +25,6 @@
|
||||
#include "checksums.h"
|
||||
#include "syncengine.h"
|
||||
#include "propagateremotedelete.h"
|
||||
#include "asserts.h"
|
||||
|
||||
#include <json.h>
|
||||
#include <QNetworkAccessManager>
|
||||
@@ -225,9 +224,7 @@ void PropagateUploadFileCommon::slotComputeContentChecksum()
|
||||
// change during the checksum calculation
|
||||
_item->_modtime = FileSystem::getModTime(filePath);
|
||||
|
||||
#ifdef WITH_TESTING
|
||||
_stopWatch.start();
|
||||
#endif
|
||||
|
||||
QByteArray checksumType = contentChecksumType();
|
||||
|
||||
@@ -254,10 +251,8 @@ void PropagateUploadFileCommon::slotComputeTransmissionChecksum(const QByteArray
|
||||
_item->_contentChecksum = contentChecksum;
|
||||
_item->_contentChecksumType = contentChecksumType;
|
||||
|
||||
#ifdef WITH_TESTING
|
||||
_stopWatch.addLapTime(QLatin1String("ContentChecksum"));
|
||||
_stopWatch.start();
|
||||
#endif
|
||||
|
||||
// Reuse the content checksum as the transmission checksum if possible
|
||||
const auto supportedTransmissionChecksums =
|
||||
@@ -304,9 +299,7 @@ void PropagateUploadFileCommon::slotStartUpload(const QByteArray& transmissionCh
|
||||
done(SyncFileItem::SoftError, tr("File Removed"));
|
||||
return;
|
||||
}
|
||||
#ifdef WITH_TESTING
|
||||
_stopWatch.addLapTime(QLatin1String("TransmissionChecksum"));
|
||||
#endif
|
||||
|
||||
time_t prevModtime = _item->_modtime; // the _item value was set in PropagateUploadFile::start()
|
||||
// but a potential checksum calculation could have taken some time during which the file could
|
||||
@@ -376,7 +369,7 @@ bool UploadDevice::prepareAndOpen(const QString& fileName, qint64 start, qint64
|
||||
|
||||
|
||||
qint64 UploadDevice::writeData(const char* , qint64 ) {
|
||||
ASSERT(false, "write to read only device");
|
||||
Q_ASSERT(!"write to read only device");
|
||||
return 0;
|
||||
}
|
||||
|
||||
@@ -487,7 +480,7 @@ void PropagateUploadFileCommon::startPollJob(const QString& path)
|
||||
void PropagateUploadFileCommon::slotPollFinished()
|
||||
{
|
||||
PollJob *job = qobject_cast<PollJob *>(sender());
|
||||
ASSERT(job);
|
||||
Q_ASSERT(job);
|
||||
|
||||
propagator()->_activeJobList.removeOne(this);
|
||||
|
||||
@@ -576,6 +569,7 @@ QMap<QByteArray, QByteArray> PropagateUploadFileCommon::headers()
|
||||
|
||||
void PropagateUploadFileCommon::finalize()
|
||||
{
|
||||
_item->_requestDuration = _duration.elapsed();
|
||||
_finished = true;
|
||||
|
||||
if (!propagator()->_journal->setFileRecord(SyncJournalFileRecord(*_item, propagator()->getFilePath(_item->_file)))) {
|
||||
|
||||
@@ -183,14 +183,13 @@ class PropagateUploadFileCommon : public PropagateItemJob {
|
||||
Q_OBJECT
|
||||
|
||||
protected:
|
||||
QElapsedTimer _duration;
|
||||
QVector<AbstractNetworkJob*> _jobs; /// network jobs that are currently in transit
|
||||
bool _finished BITFIELD(1); /// Tells that all the jobs have been finished
|
||||
bool _deleteExisting BITFIELD(1);
|
||||
bool _finished; /// Tells that all the jobs have been finished
|
||||
bool _deleteExisting;
|
||||
|
||||
// measure the performance of checksum calc and upload
|
||||
#ifdef WITH_TESTING
|
||||
Utility::StopWatch _stopWatch;
|
||||
#endif
|
||||
|
||||
QByteArray _transmissionChecksum;
|
||||
QByteArray _transmissionChecksumType;
|
||||
@@ -210,7 +209,7 @@ public:
|
||||
|
||||
void start() Q_DECL_OVERRIDE;
|
||||
|
||||
bool isLikelyFinishedQuickly() Q_DECL_OVERRIDE { return _item->_size < 100*1024; }
|
||||
bool isLikelyFinishedQuickly() Q_DECL_OVERRIDE { return _item->_size < propagator()->smallFileSize(); }
|
||||
|
||||
private slots:
|
||||
void slotComputeContentChecksum();
|
||||
|
||||
@@ -25,7 +25,7 @@
|
||||
#include "syncengine.h"
|
||||
#include "propagateremotemove.h"
|
||||
#include "propagateremotedelete.h"
|
||||
#include "asserts.h"
|
||||
|
||||
|
||||
#include <QNetworkAccessManager>
|
||||
#include <QFileInfo>
|
||||
@@ -80,6 +80,7 @@ QUrl PropagateUploadFileNG::chunkUrl(int chunk)
|
||||
|
||||
void PropagateUploadFileNG::doStartUpload()
|
||||
{
|
||||
_duration.start();
|
||||
propagator()->_activeJobList.append(this);
|
||||
|
||||
const SyncJournalDb::UploadInfo progressInfo = propagator()->_journal->getUploadInfo(_item->_file);
|
||||
@@ -97,12 +98,6 @@ void PropagateUploadFileNG::doStartUpload()
|
||||
this, SLOT(slotPropfindIterate(QString,QMap<QString,QString>)));
|
||||
job->start();
|
||||
return;
|
||||
} else if (progressInfo._valid) {
|
||||
// The upload info is stale. remove the stale chunks on the server
|
||||
_transferId = progressInfo._transferid;
|
||||
// Fire and forget. Any error will be ignored.
|
||||
(new DeleteJob(propagator()->account(), chunkUrl(), this))->start();
|
||||
// startNewUpload will reset the _transferId and the UploadInfo in the db.
|
||||
}
|
||||
|
||||
startNewUpload();
|
||||
@@ -188,7 +183,7 @@ void PropagateUploadFileNG::slotPropfindFinishedWithError()
|
||||
void PropagateUploadFileNG::slotDeleteJobFinished()
|
||||
{
|
||||
auto job = qobject_cast<DeleteJob *>(sender());
|
||||
ASSERT(job);
|
||||
Q_ASSERT(job);
|
||||
_jobs.remove(_jobs.indexOf(job));
|
||||
|
||||
QNetworkReply::NetworkError err = job->reply()->error();
|
||||
@@ -220,7 +215,7 @@ void PropagateUploadFileNG::slotDeleteJobFinished()
|
||||
|
||||
void PropagateUploadFileNG::startNewUpload()
|
||||
{
|
||||
ASSERT(propagator()->_activeJobList.count(this) == 1);
|
||||
Q_ASSERT(propagator()->_activeJobList.count(this) == 1);
|
||||
_transferId = qrand() ^ _item->_modtime ^ (_item->_size << 16) ^ qHash(_item->_file);
|
||||
_sent = 0;
|
||||
_currentChunk = 0;
|
||||
@@ -270,12 +265,11 @@ void PropagateUploadFileNG::startNextChunk()
|
||||
return;
|
||||
|
||||
quint64 fileSize = _item->_size;
|
||||
ENFORCE(fileSize >= _sent, "Sent data exceeds file size");
|
||||
|
||||
Q_ASSERT(fileSize >= _sent);
|
||||
quint64 currentChunkSize = qMin(chunkSize(), fileSize - _sent);
|
||||
|
||||
if (currentChunkSize == 0) {
|
||||
ASSERT(_jobs.isEmpty());
|
||||
Q_ASSERT(_jobs.isEmpty()); // There should be no running job anymore
|
||||
_finished = true;
|
||||
// Finish with a MOVE
|
||||
QString destination = QDir::cleanPath(propagator()->account()->url().path() + QLatin1Char('/')
|
||||
@@ -344,8 +338,7 @@ void PropagateUploadFileNG::startNextChunk()
|
||||
void PropagateUploadFileNG::slotPutFinished()
|
||||
{
|
||||
PUTFileJob *job = qobject_cast<PUTFileJob *>(sender());
|
||||
ASSERT(job);
|
||||
|
||||
Q_ASSERT(job);
|
||||
slotJobDestroyed(job); // remove it from the _jobs list
|
||||
|
||||
qDebug() << job->reply()->request().url() << "FINISHED WITH STATUS"
|
||||
@@ -393,7 +386,7 @@ void PropagateUploadFileNG::slotPutFinished()
|
||||
return;
|
||||
}
|
||||
|
||||
ENFORCE(_sent <= _item->_size, "can't send more than size");
|
||||
Q_ASSERT(_sent <= _item->_size);
|
||||
bool finished = _sent == _item->_size;
|
||||
|
||||
// Check if the file still exists
|
||||
@@ -485,16 +478,14 @@ void PropagateUploadFileNG::slotMoveJobFinished()
|
||||
}
|
||||
_item->_responseTimeStamp = job->responseTimestamp();
|
||||
|
||||
#ifdef WITH_TESTING
|
||||
// performance logging
|
||||
quint64 duration = _stopWatch.stop();
|
||||
_item->_requestDuration = _stopWatch.stop();
|
||||
qDebug() << "*==* duration UPLOAD" << _item->_size
|
||||
<< _stopWatch.durationOfLap(QLatin1String("ContentChecksum"))
|
||||
<< _stopWatch.durationOfLap(QLatin1String("TransmissionChecksum"))
|
||||
<< duration;
|
||||
<< _item->_requestDuration;
|
||||
// The job might stay alive for the whole sync, release this tiny bit of memory.
|
||||
_stopWatch.reset();
|
||||
#endif
|
||||
finalize();
|
||||
}
|
||||
|
||||
|
||||
@@ -25,7 +25,6 @@
|
||||
#include "checksums.h"
|
||||
#include "syncengine.h"
|
||||
#include "propagateremotedelete.h"
|
||||
#include "asserts.h"
|
||||
|
||||
#include <json.h>
|
||||
#include <QNetworkAccessManager>
|
||||
@@ -50,6 +49,7 @@ void PropagateUploadFileV1::doStartUpload()
|
||||
}
|
||||
|
||||
_currentChunk = 0;
|
||||
_duration.start();
|
||||
|
||||
emit progress(*_item, 0);
|
||||
startNextChunk();
|
||||
@@ -172,8 +172,7 @@ void PropagateUploadFileV1::startNextChunk()
|
||||
void PropagateUploadFileV1::slotPutFinished()
|
||||
{
|
||||
PUTFileJob *job = qobject_cast<PUTFileJob *>(sender());
|
||||
ASSERT(job);
|
||||
|
||||
Q_ASSERT(job);
|
||||
slotJobDestroyed(job); // remove it from the _jobs list
|
||||
|
||||
qDebug() << Q_FUNC_INFO << job->reply()->request().url() << "FINISHED WITH STATUS"
|
||||
@@ -341,16 +340,14 @@ void PropagateUploadFileV1::slotPutFinished()
|
||||
done(SyncFileItem::SoftError, "Server does not support X-OC-MTime");
|
||||
}
|
||||
|
||||
#ifdef WITH_TESTING
|
||||
// performance logging
|
||||
quint64 duration = _stopWatch.stop();
|
||||
_item->_requestDuration = _stopWatch.stop();
|
||||
qDebug() << "*==* duration UPLOAD" << _item->_size
|
||||
<< _stopWatch.durationOfLap(QLatin1String("ContentChecksum"))
|
||||
<< _stopWatch.durationOfLap(QLatin1String("TransmissionChecksum"))
|
||||
<< duration;
|
||||
<< _item->_requestDuration;
|
||||
// The job might stay alive for the whole sync, release this tiny bit of memory.
|
||||
_stopWatch.reset();
|
||||
#endif
|
||||
|
||||
finalize();
|
||||
}
|
||||
|
||||
@@ -23,8 +23,6 @@
|
||||
#include "syncfilestatus.h"
|
||||
#include "csync_private.h"
|
||||
#include "filesystem.h"
|
||||
#include "propagateremotedelete.h"
|
||||
#include "asserts.h"
|
||||
|
||||
#ifdef Q_OS_WIN
|
||||
#include <windows.h>
|
||||
@@ -73,18 +71,18 @@ SyncEngine::SyncEngine(AccountPtr account, const QString& localPath,
|
||||
, _backInTimeFiles(0)
|
||||
, _uploadLimit(0)
|
||||
, _downloadLimit(0)
|
||||
, _newBigFolderSizeLimit(-1)
|
||||
, _checksum_hook(journal)
|
||||
, _anotherSyncNeeded(NoFollowUpSync)
|
||||
{
|
||||
qRegisterMetaType<SyncFileItem>("SyncFileItem");
|
||||
qRegisterMetaType<SyncFileItemPtr>("SyncFileItemPtr");
|
||||
qRegisterMetaType<SyncFileItem::Status>("SyncFileItem::Status");
|
||||
qRegisterMetaType<SyncFileStatus>("SyncFileStatus");
|
||||
qRegisterMetaType<SyncFileItemVector>("SyncFileItemVector");
|
||||
qRegisterMetaType<SyncFileItem::Direction>("SyncFileItem::Direction");
|
||||
|
||||
// Everything in the SyncEngine expects a trailing slash for the localPath.
|
||||
ASSERT(localPath.endsWith(QLatin1Char('/')));
|
||||
Q_ASSERT(localPath.endsWith(QLatin1Char('/')));
|
||||
|
||||
csync_create(&_csync_ctx, localPath.toUtf8().data());
|
||||
|
||||
@@ -268,11 +266,11 @@ bool SyncEngine::checkErrorBlacklisting( SyncFileItem &item )
|
||||
return true;
|
||||
}
|
||||
|
||||
void SyncEngine::deleteStaleDownloadInfos(const SyncFileItemVector &syncItems)
|
||||
void SyncEngine::deleteStaleDownloadInfos()
|
||||
{
|
||||
// Find all downloadinfo paths that we want to preserve.
|
||||
QSet<QString> download_file_paths;
|
||||
foreach(const SyncFileItemPtr &it, syncItems) {
|
||||
foreach(const SyncFileItemPtr &it, _syncedItems) {
|
||||
if (it->_direction == SyncFileItem::Down
|
||||
&& it->_type == SyncFileItem::File)
|
||||
{
|
||||
@@ -290,11 +288,11 @@ void SyncEngine::deleteStaleDownloadInfos(const SyncFileItemVector &syncItems)
|
||||
}
|
||||
}
|
||||
|
||||
void SyncEngine::deleteStaleUploadInfos(const SyncFileItemVector &syncItems)
|
||||
void SyncEngine::deleteStaleUploadInfos()
|
||||
{
|
||||
// Find all blacklisted paths that we want to preserve.
|
||||
QSet<QString> upload_file_paths;
|
||||
foreach(const SyncFileItemPtr &it, syncItems) {
|
||||
foreach(const SyncFileItemPtr &it, _syncedItems) {
|
||||
if (it->_direction == SyncFileItem::Up
|
||||
&& it->_type == SyncFileItem::File)
|
||||
{
|
||||
@@ -303,23 +301,14 @@ void SyncEngine::deleteStaleUploadInfos(const SyncFileItemVector &syncItems)
|
||||
}
|
||||
|
||||
// Delete from journal.
|
||||
auto ids = _journal->deleteStaleUploadInfos(upload_file_paths);
|
||||
|
||||
// Delete the stales chunk on the server.
|
||||
if (account()->capabilities().chunkingNg()) {
|
||||
foreach (uint transferId, ids) {
|
||||
QUrl url = Utility::concatUrlPath(account()->url(), QLatin1String("remote.php/dav/uploads/")
|
||||
+ account()->davUser() + QLatin1Char('/') + QString::number(transferId));
|
||||
(new DeleteJob(account(), url, this))->start();
|
||||
}
|
||||
}
|
||||
_journal->deleteStaleUploadInfos(upload_file_paths);
|
||||
}
|
||||
|
||||
void SyncEngine::deleteStaleErrorBlacklistEntries(const SyncFileItemVector &syncItems)
|
||||
void SyncEngine::deleteStaleErrorBlacklistEntries()
|
||||
{
|
||||
// Find all blacklisted paths that we want to preserve.
|
||||
QSet<QString> blacklist_file_paths;
|
||||
foreach(const SyncFileItemPtr &it, syncItems) {
|
||||
foreach(const SyncFileItemPtr &it, _syncedItems) {
|
||||
if (it->_hasBlacklistEntry)
|
||||
blacklist_file_paths.insert(it->_file);
|
||||
}
|
||||
@@ -354,7 +343,7 @@ int SyncEngine::treewalkFile( TREE_WALK_FILE *file, bool remote )
|
||||
|
||||
QTextCodec::ConverterState utf8State;
|
||||
static QTextCodec *codec = QTextCodec::codecForName("UTF-8");
|
||||
ASSERT(codec);
|
||||
Q_ASSERT(codec);
|
||||
QString fileUtf8 = codec->toUnicode(file->path, qstrlen(file->path), &utf8State);
|
||||
QString renameTarget;
|
||||
QString key = fileUtf8;
|
||||
@@ -390,11 +379,9 @@ int SyncEngine::treewalkFile( TREE_WALK_FILE *file, bool remote )
|
||||
item->_modtime = file->modtime;
|
||||
} else {
|
||||
if (instruction != CSYNC_INSTRUCTION_NONE) {
|
||||
qWarning() << "ERROR: Instruction" << item->_instruction << "vs" << instruction << "for" << fileUtf8;
|
||||
ASSERT(false);
|
||||
// Set instruction to NONE for safety.
|
||||
file->instruction = item->_instruction = instruction = CSYNC_INSTRUCTION_NONE;
|
||||
return -1; // should lead to treewalk error
|
||||
qDebug() << "ERROR: Instruction" << item->_instruction << "vs" << instruction << "for" << fileUtf8;
|
||||
Q_ASSERT(!"Instructions are both unequal NONE");
|
||||
return -1;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -409,8 +396,6 @@ int SyncEngine::treewalkFile( TREE_WALK_FILE *file, bool remote )
|
||||
}
|
||||
if (file->remotePerm && file->remotePerm[0]) {
|
||||
item->_remotePerm = QByteArray(file->remotePerm);
|
||||
if (remote)
|
||||
_remotePerms[item->_file] = item->_remotePerm;
|
||||
}
|
||||
|
||||
/* The flag "serverHasIgnoredFiles" is true if item in question is a directory
|
||||
@@ -441,6 +426,10 @@ int SyncEngine::treewalkFile( TREE_WALK_FILE *file, bool remote )
|
||||
_seenFiles.insert(renameTarget);
|
||||
}
|
||||
|
||||
if (remote && file->remotePerm && file->remotePerm[0]) {
|
||||
_remotePerms[item->_file] = file->remotePerm;
|
||||
}
|
||||
|
||||
switch(file->error_status) {
|
||||
case CSYNC_STATUS_OK:
|
||||
break;
|
||||
@@ -502,7 +491,7 @@ int SyncEngine::treewalkFile( TREE_WALK_FILE *file, bool remote )
|
||||
item->_status = SyncFileItem::SoftError;
|
||||
break;
|
||||
default:
|
||||
ASSERT(false, "Non handled error-status");
|
||||
Q_ASSERT("Non handled error-status");
|
||||
/* No error string */
|
||||
}
|
||||
|
||||
@@ -653,6 +642,12 @@ int SyncEngine::treewalkFile( TREE_WALK_FILE *file, bool remote )
|
||||
|
||||
_needsUpdate = true;
|
||||
|
||||
item->log._etag = file->etag;
|
||||
item->log._fileId = file->file_id;
|
||||
item->log._instruction = file->instruction;
|
||||
item->log._modtime = file->modtime;
|
||||
item->log._size = file->size;
|
||||
|
||||
item->log._other_etag = file->other.etag;
|
||||
item->log._other_fileId = file->other.file_id;
|
||||
item->log._other_instruction = file->other.instruction;
|
||||
@@ -712,11 +707,8 @@ void SyncEngine::startSync()
|
||||
}
|
||||
}
|
||||
|
||||
if (s_anySyncRunning || _syncRunning) {
|
||||
ASSERT(false);
|
||||
return;
|
||||
}
|
||||
|
||||
Q_ASSERT(!s_anySyncRunning);
|
||||
Q_ASSERT(!_syncRunning);
|
||||
s_anySyncRunning = true;
|
||||
_syncRunning = true;
|
||||
_anotherSyncNeeded = NoFollowUpSync;
|
||||
@@ -751,6 +743,7 @@ void SyncEngine::startSync()
|
||||
qDebug() << "Could not determine free space available at" << _localPath;
|
||||
}
|
||||
|
||||
_syncedItems.clear();
|
||||
_syncItemMap.clear();
|
||||
_needsUpdate = false;
|
||||
|
||||
@@ -837,14 +830,14 @@ void SyncEngine::startSync()
|
||||
return;
|
||||
}
|
||||
|
||||
discoveryJob->_syncOptions = _syncOptions;
|
||||
discoveryJob->_newBigFolderSizeLimit = _newBigFolderSizeLimit;
|
||||
discoveryJob->moveToThread(&_thread);
|
||||
connect(discoveryJob, SIGNAL(finished(int)), this, SLOT(slotDiscoveryJobFinished(int)));
|
||||
connect(discoveryJob, SIGNAL(folderDiscovered(bool,QString)),
|
||||
this, SIGNAL(folderDiscovered(bool,QString)));
|
||||
|
||||
connect(discoveryJob, SIGNAL(newBigFolder(QString,bool)),
|
||||
this, SIGNAL(newBigFolder(QString,bool)));
|
||||
connect(discoveryJob, SIGNAL(newBigFolder(QString)),
|
||||
this, SIGNAL(newBigFolder(QString)));
|
||||
|
||||
|
||||
// This is used for the DiscoveryJob to be able to request the main thread/
|
||||
@@ -897,8 +890,6 @@ void SyncEngine::slotDiscoveryJobFinished(int discoveryResult)
|
||||
_hasForwardInTimeFiles = false;
|
||||
_backInTimeFiles = 0;
|
||||
bool walkOk = true;
|
||||
_remotePerms.clear();
|
||||
_remotePerms.reserve(c_rbtree_size(_csync_ctx->remote.tree));
|
||||
_seenFiles.clear();
|
||||
_temporarilyUnavailablePaths.clear();
|
||||
_renamedFolders.clear();
|
||||
@@ -920,12 +911,12 @@ void SyncEngine::slotDiscoveryJobFinished(int discoveryResult)
|
||||
csync_commit(_csync_ctx);
|
||||
|
||||
// The map was used for merging trees, convert it to a list:
|
||||
SyncFileItemVector syncItems = _syncItemMap.values().toVector();
|
||||
_syncedItems = _syncItemMap.values().toVector();
|
||||
_syncItemMap.clear(); // free memory
|
||||
|
||||
// Adjust the paths for the renames.
|
||||
for (SyncFileItemVector::iterator it = syncItems.begin();
|
||||
it != syncItems.end(); ++it) {
|
||||
for (SyncFileItemVector::iterator it = _syncedItems.begin();
|
||||
it != _syncedItems.end(); ++it) {
|
||||
(*it)->_file = adjustRenamedPath((*it)->_file);
|
||||
}
|
||||
|
||||
@@ -933,7 +924,7 @@ void SyncEngine::slotDiscoveryJobFinished(int discoveryResult)
|
||||
if (_account->serverVersionInt() < 0x080100) {
|
||||
// Server version older than 8.1 don't support these character in filename.
|
||||
static const QRegExp invalidCharRx("[\\\\:?*\"<>|]");
|
||||
for (auto it = syncItems.begin(); it != syncItems.end(); ++it) {
|
||||
for (auto it = _syncedItems.begin(); it != _syncedItems.end(); ++it) {
|
||||
if ((*it)->_direction == SyncFileItem::Up &&
|
||||
(*it)->destination().contains(invalidCharRx)) {
|
||||
(*it)->_errorString = tr("File name contains at least one invalid character");
|
||||
@@ -945,7 +936,7 @@ void SyncEngine::slotDiscoveryJobFinished(int discoveryResult)
|
||||
if (!_hasNoneFiles && _hasRemoveFile) {
|
||||
qDebug() << Q_FUNC_INFO << "All the files are going to be changed, asking the user";
|
||||
bool cancel = false;
|
||||
emit aboutToRemoveAllFiles(syncItems.first()->_direction, &cancel);
|
||||
emit aboutToRemoveAllFiles(_syncedItems.first()->_direction, &cancel);
|
||||
if (cancel) {
|
||||
qDebug() << Q_FUNC_INFO << "Abort sync";
|
||||
finalize(false);
|
||||
@@ -960,7 +951,7 @@ void SyncEngine::slotDiscoveryJobFinished(int discoveryResult)
|
||||
if (!databaseFingerprint.isNull()
|
||||
&& _discoveryMainThread->_dataFingerprint != databaseFingerprint) {
|
||||
qDebug() << "data fingerprint changed, assume restore from backup" << databaseFingerprint << _discoveryMainThread->_dataFingerprint;
|
||||
restoreOldFiles(syncItems);
|
||||
restoreOldFiles();
|
||||
} else if (!_hasForwardInTimeFiles && _backInTimeFiles >= 2 && _account->serverVersionInt() < 0x090100) {
|
||||
// The server before ownCloud 9.1 did not have the data-fingerprint property. So in that
|
||||
// case we use heuristics to detect restored backup. This is disabled with newer version
|
||||
@@ -970,18 +961,18 @@ void SyncEngine::slotDiscoveryJobFinished(int discoveryResult)
|
||||
bool restore = false;
|
||||
emit aboutToRestoreBackup(&restore);
|
||||
if (restore) {
|
||||
restoreOldFiles(syncItems);
|
||||
restoreOldFiles();
|
||||
}
|
||||
}
|
||||
|
||||
// Sort items per destination
|
||||
std::sort(syncItems.begin(), syncItems.end());
|
||||
std::sort(_syncedItems.begin(), _syncedItems.end());
|
||||
|
||||
// make sure everything is allowed
|
||||
checkForPermission(syncItems);
|
||||
checkForPermission();
|
||||
|
||||
// To announce the beginning of the sync
|
||||
emit aboutToPropagate(syncItems);
|
||||
emit aboutToPropagate(_syncedItems);
|
||||
// it's important to do this before ProgressInfo::start(), to announce start of new sync
|
||||
emit transmissionProgress(*_progressInfo);
|
||||
_progressInfo->startEstimateUpdates();
|
||||
@@ -1003,8 +994,8 @@ void SyncEngine::slotDiscoveryJobFinished(int discoveryResult)
|
||||
|
||||
_propagator = QSharedPointer<OwncloudPropagator>(
|
||||
new OwncloudPropagator (_account, _localPath, _remotePath, _journal));
|
||||
connect(_propagator.data(), SIGNAL(itemCompleted(const SyncFileItemPtr &)),
|
||||
this, SLOT(slotItemCompleted(const SyncFileItemPtr &)));
|
||||
connect(_propagator.data(), SIGNAL(itemCompleted(const SyncFileItem &, const PropagatorJob &)),
|
||||
this, SLOT(slotItemCompleted(const SyncFileItem &, const PropagatorJob &)));
|
||||
connect(_propagator.data(), SIGNAL(progress(const SyncFileItem &,quint64)),
|
||||
this, SLOT(slotProgress(const SyncFileItem &,quint64)));
|
||||
connect(_propagator.data(), SIGNAL(finished(bool)), this, SLOT(slotFinished(bool)), Qt::QueuedConnection);
|
||||
@@ -1014,16 +1005,16 @@ void SyncEngine::slotDiscoveryJobFinished(int discoveryResult)
|
||||
// apply the network limits to the propagator
|
||||
setNetworkLimits(_uploadLimit, _downloadLimit);
|
||||
|
||||
deleteStaleDownloadInfos(syncItems);
|
||||
deleteStaleUploadInfos(syncItems);
|
||||
deleteStaleErrorBlacklistEntries(syncItems);
|
||||
deleteStaleDownloadInfos();
|
||||
deleteStaleUploadInfos();
|
||||
deleteStaleErrorBlacklistEntries();
|
||||
_journal->commit("post stale entry removal");
|
||||
|
||||
// Emit the started signal only after the propagator has been set up.
|
||||
if (_needsUpdate)
|
||||
emit(started());
|
||||
|
||||
_propagator->start(syncItems);
|
||||
_propagator->start(_syncedItems);
|
||||
|
||||
qDebug() << "<<#### Post-Reconcile end #################################################### " << _stopWatch.addLapTime(QLatin1String("Post-Reconcile Finished"));
|
||||
}
|
||||
@@ -1060,19 +1051,19 @@ void SyncEngine::setNetworkLimits(int upload, int download)
|
||||
}
|
||||
}
|
||||
|
||||
void SyncEngine::slotItemCompleted(const SyncFileItemPtr &item)
|
||||
void SyncEngine::slotItemCompleted(const SyncFileItem &item, const PropagatorJob &job)
|
||||
{
|
||||
const char * instruction_str = csync_instruction_str(item->_instruction);
|
||||
qDebug() << Q_FUNC_INFO << item->_file << instruction_str << item->_status << item->_errorString;
|
||||
const char * instruction_str = csync_instruction_str(item._instruction);
|
||||
qDebug() << Q_FUNC_INFO << item._file << instruction_str << item._status << item._errorString;
|
||||
|
||||
_progressInfo->setProgressComplete(*item);
|
||||
_progressInfo->setProgressComplete(item);
|
||||
|
||||
if (item->_status == SyncFileItem::FatalError) {
|
||||
emit csyncError(item->_errorString);
|
||||
if (item._status == SyncFileItem::FatalError) {
|
||||
emit csyncError(item._errorString);
|
||||
}
|
||||
|
||||
emit transmissionProgress(*_progressInfo);
|
||||
emit itemCompleted(item);
|
||||
emit itemCompleted(item, job);
|
||||
}
|
||||
|
||||
void SyncEngine::slotFinished(bool success)
|
||||
@@ -1096,6 +1087,7 @@ void SyncEngine::slotFinished(bool success)
|
||||
// files needed propagation
|
||||
emit transmissionProgress(*_progressInfo);
|
||||
|
||||
emit treeWalkResult(_syncedItems);
|
||||
finalize(success);
|
||||
}
|
||||
|
||||
@@ -1116,10 +1108,6 @@ void SyncEngine::finalize(bool success)
|
||||
|
||||
// Delete the propagator only after emitting the signal.
|
||||
_propagator.clear();
|
||||
_remotePerms.clear();
|
||||
_seenFiles.clear();
|
||||
_temporarilyUnavailablePaths.clear();
|
||||
_renamedFolders.clear();
|
||||
|
||||
_clearTouchedFilesTimer.start();
|
||||
}
|
||||
@@ -1149,13 +1137,13 @@ QString SyncEngine::adjustRenamedPath(const QString& original)
|
||||
* Make sure that we are allowed to do what we do by checking the permissions and the selective sync list
|
||||
*
|
||||
*/
|
||||
void SyncEngine::checkForPermission(SyncFileItemVector &syncItems)
|
||||
void SyncEngine::checkForPermission()
|
||||
{
|
||||
bool selectiveListOk;
|
||||
auto selectiveSyncBlackList = _journal->getSelectiveSyncList(SyncJournalDb::SelectiveSyncBlackList, &selectiveListOk);
|
||||
std::sort(selectiveSyncBlackList.begin(), selectiveSyncBlackList.end());
|
||||
|
||||
for (SyncFileItemVector::iterator it = syncItems.begin(); it != syncItems.end(); ++it) {
|
||||
for (SyncFileItemVector::iterator it = _syncedItems.begin(); it != _syncedItems.end(); ++it) {
|
||||
if ((*it)->_direction != SyncFileItem::Up) {
|
||||
// Currently we only check server-side permissions
|
||||
continue;
|
||||
@@ -1172,7 +1160,7 @@ void SyncEngine::checkForPermission(SyncFileItemVector &syncItems)
|
||||
(*it)->_errorString = tr("Ignored because of the \"choose what to sync\" blacklist");
|
||||
|
||||
if ((*it)->_isDirectory) {
|
||||
for (SyncFileItemVector::iterator it_next = it + 1; it_next != syncItems.end() && (*it_next)->_file.startsWith(path); ++it_next) {
|
||||
for (SyncFileItemVector::iterator it_next = it + 1; it_next != _syncedItems.end() && (*it_next)->_file.startsWith(path); ++it_next) {
|
||||
it = it_next;
|
||||
(*it)->_instruction = CSYNC_INSTRUCTION_IGNORE;
|
||||
(*it)->_status = SyncFileItem::FileIgnored;
|
||||
@@ -1197,7 +1185,7 @@ void SyncEngine::checkForPermission(SyncFileItemVector &syncItems)
|
||||
(*it)->_status = SyncFileItem::NormalError;
|
||||
(*it)->_errorString = tr("Not allowed because you don't have permission to add subfolders to that folder");
|
||||
|
||||
for (SyncFileItemVector::iterator it_next = it + 1; it_next != syncItems.end() && (*it_next)->destination().startsWith(path); ++it_next) {
|
||||
for (SyncFileItemVector::iterator it_next = it + 1; it_next != _syncedItems.end() && (*it_next)->destination().startsWith(path); ++it_next) {
|
||||
it = it_next;
|
||||
if ((*it)->_instruction == CSYNC_INSTRUCTION_RENAME) {
|
||||
// The file was most likely moved in this directory.
|
||||
@@ -1257,7 +1245,7 @@ void SyncEngine::checkForPermission(SyncFileItemVector &syncItems)
|
||||
if ((*it)->_isDirectory) {
|
||||
// restore all sub items
|
||||
for (SyncFileItemVector::iterator it_next = it + 1;
|
||||
it_next != syncItems.end() && (*it_next)->_file.startsWith(path); ++it_next) {
|
||||
it_next != _syncedItems.end() && (*it_next)->_file.startsWith(path); ++it_next) {
|
||||
it = it_next;
|
||||
|
||||
if ((*it)->_instruction != CSYNC_INSTRUCTION_REMOVE) {
|
||||
@@ -1283,12 +1271,12 @@ void SyncEngine::checkForPermission(SyncFileItemVector &syncItems)
|
||||
// underneath, propagator sees that.
|
||||
if( (*it)->_isDirectory ) {
|
||||
// put a more descriptive message if a top level share dir really is removed.
|
||||
if( it == syncItems.begin() || !(path.startsWith((*(it-1))->_file)) ) {
|
||||
if( it == _syncedItems.begin() || !(path.startsWith((*(it-1))->_file)) ) {
|
||||
(*it)->_errorString = tr("Local files and share folder removed.");
|
||||
}
|
||||
|
||||
for (SyncFileItemVector::iterator it_next = it + 1;
|
||||
it_next != syncItems.end() && (*it_next)->_file.startsWith(path); ++it_next) {
|
||||
it_next != _syncedItems.end() && (*it_next)->_file.startsWith(path); ++it_next) {
|
||||
it = it_next;
|
||||
}
|
||||
}
|
||||
@@ -1367,7 +1355,7 @@ void SyncEngine::checkForPermission(SyncFileItemVector &syncItems)
|
||||
|
||||
if ((*it)->_isDirectory) {
|
||||
for (SyncFileItemVector::iterator it_next = it + 1;
|
||||
it_next != syncItems.end() && (*it_next)->destination().startsWith(path); ++it_next) {
|
||||
it_next != _syncedItems.end() && (*it_next)->destination().startsWith(path); ++it_next) {
|
||||
it = it_next;
|
||||
(*it)->_instruction = CSYNC_INSTRUCTION_ERROR;
|
||||
(*it)->_status = SyncFileItem::NormalError;
|
||||
@@ -1396,7 +1384,7 @@ QByteArray SyncEngine::getPermissions(const QString& file) const
|
||||
return _remotePerms.value(file);
|
||||
}
|
||||
|
||||
void SyncEngine::restoreOldFiles(SyncFileItemVector &syncItems)
|
||||
void SyncEngine::restoreOldFiles()
|
||||
{
|
||||
/* When the server is trying to send us lots of file in the past, this means that a backup
|
||||
was restored in the server. In that case, we should not simply overwrite the newer file
|
||||
@@ -1404,7 +1392,7 @@ void SyncEngine::restoreOldFiles(SyncFileItemVector &syncItems)
|
||||
upload the client file. But we still downloaded the old file in a conflict file just in case
|
||||
*/
|
||||
|
||||
for (auto it = syncItems.begin(); it != syncItems.end(); ++it) {
|
||||
for (auto it = _syncedItems.begin(); it != _syncedItems.end(); ++it) {
|
||||
if ((*it)->_direction != SyncFileItem::Down)
|
||||
continue;
|
||||
|
||||
|
||||
+22
-10
@@ -47,6 +47,7 @@ namespace OCC {
|
||||
class SyncJournalFileRecord;
|
||||
class SyncJournalDb;
|
||||
class OwncloudPropagator;
|
||||
class PropagatorJob;
|
||||
|
||||
enum AnotherSyncNeeded
|
||||
{
|
||||
@@ -77,7 +78,10 @@ public:
|
||||
|
||||
bool isSyncRunning() const { return _syncRunning; }
|
||||
|
||||
void setSyncOptions(const SyncOptions &options) { _syncOptions = options; }
|
||||
/* Set the maximum size a folder can have without asking for confirmation
|
||||
* -1 means infinite
|
||||
*/
|
||||
void setNewBigFolderSizeLimit(qint64 limit) { _newBigFolderSizeLimit = limit; }
|
||||
bool ignoreHiddenFiles() const { return _csync_ctx->ignore_hidden_files; }
|
||||
void setIgnoreHiddenFiles(bool ignore) { _csync_ctx->ignore_hidden_files = ignore; }
|
||||
|
||||
@@ -118,7 +122,10 @@ signals:
|
||||
void aboutToPropagate(SyncFileItemVector&);
|
||||
|
||||
// after each item completed by a job (successful or not)
|
||||
void itemCompleted(const SyncFileItemPtr&);
|
||||
void itemCompleted(const SyncFileItem&, const PropagatorJob&);
|
||||
|
||||
// after sync is done
|
||||
void treeWalkResult(const SyncFileItemVector&);
|
||||
|
||||
void transmissionProgress( const ProgressInfo& progress );
|
||||
|
||||
@@ -139,7 +146,7 @@ signals:
|
||||
void aboutToRestoreBackup(bool *restore);
|
||||
|
||||
// A new folder was discovered and was not synced because of the confirmation feature
|
||||
void newBigFolder(const QString &folder, bool isExternal);
|
||||
void newBigFolder(const QString &folder);
|
||||
|
||||
/** Emitted when propagation has problems with a locked file.
|
||||
*
|
||||
@@ -149,7 +156,7 @@ signals:
|
||||
|
||||
private slots:
|
||||
void slotRootEtagReceived(const QString &);
|
||||
void slotItemCompleted(const SyncFileItemPtr& item);
|
||||
void slotItemCompleted(const SyncFileItem& item, const PropagatorJob & job);
|
||||
void slotFinished(bool success);
|
||||
void slotProgress(const SyncFileItem& item, quint64 curent);
|
||||
void slotDiscoveryJobFinished(int updateResult);
|
||||
@@ -173,13 +180,13 @@ private:
|
||||
|
||||
// Cleans up unnecessary downloadinfo entries in the journal as well
|
||||
// as their temporary files.
|
||||
void deleteStaleDownloadInfos(const SyncFileItemVector &syncItems);
|
||||
void deleteStaleDownloadInfos();
|
||||
|
||||
// Removes stale uploadinfos from the journal.
|
||||
void deleteStaleUploadInfos(const SyncFileItemVector &syncItems);
|
||||
void deleteStaleUploadInfos();
|
||||
|
||||
// Removes stale error blacklist entries from the journal.
|
||||
void deleteStaleErrorBlacklistEntries(const SyncFileItemVector &syncItems);
|
||||
void deleteStaleErrorBlacklistEntries();
|
||||
|
||||
// cleanup and emit the finished signal
|
||||
void finalize(bool success);
|
||||
@@ -189,6 +196,10 @@ private:
|
||||
// Must only be acessed during update and reconcile
|
||||
QMap<QString, SyncFileItemPtr> _syncItemMap;
|
||||
|
||||
// should be called _syncItems (present tense). It's the items from the _syncItemMap but
|
||||
// sorted and re-adjusted based on permissions.
|
||||
SyncFileItemVector _syncedItems;
|
||||
|
||||
AccountPtr _account;
|
||||
CSYNC *_csync_ctx;
|
||||
bool _needsUpdate;
|
||||
@@ -230,13 +241,13 @@ private:
|
||||
* check if we are allowed to propagate everything, and if we are not, adjust the instructions
|
||||
* to recover
|
||||
*/
|
||||
void checkForPermission(SyncFileItemVector &syncItems);
|
||||
void checkForPermission();
|
||||
QByteArray getPermissions(const QString& file) const;
|
||||
|
||||
/**
|
||||
* Instead of downloading files from the server, upload the files to the server
|
||||
*/
|
||||
void restoreOldFiles(SyncFileItemVector &syncItems);
|
||||
void restoreOldFiles();
|
||||
|
||||
bool _hasNoneFiles; // true if there is at least one file which was not changed on the server
|
||||
bool _hasRemoveFile; // true if there is at leasr one file with instruction REMOVE
|
||||
@@ -246,7 +257,8 @@ private:
|
||||
|
||||
int _uploadLimit;
|
||||
int _downloadLimit;
|
||||
SyncOptions _syncOptions;
|
||||
/* maximum size a folder can have without asking for confirmation: -1 means infinite */
|
||||
qint64 _newBigFolderSizeLimit;
|
||||
|
||||
// hash containing the permissions on the remote directory
|
||||
QHash<QString, QByteArray> _remotePerms;
|
||||
|
||||
@@ -68,7 +68,7 @@ public:
|
||||
_serverHasIgnoredFiles(false), _hasBlacklistEntry(false),
|
||||
_errorMayBeBlacklisted(false), _status(NoStatus),
|
||||
_isRestoration(false),
|
||||
_httpErrorCode(0), _affectedItems(1),
|
||||
_httpErrorCode(0), _requestDuration(0), _affectedItems(1),
|
||||
_instruction(CSYNC_INSTRUCTION_NONE), _modtime(0), _size(0), _inode(0)
|
||||
{
|
||||
}
|
||||
@@ -160,6 +160,7 @@ public:
|
||||
quint16 _httpErrorCode;
|
||||
QString _errorString; // Contains a string only in case of error
|
||||
QByteArray _responseTimeStamp;
|
||||
quint64 _requestDuration;
|
||||
quint32 _affectedItems; // the number of affected items by the operation on this item.
|
||||
// usually this value is 1, but for removes on dirs, it might be much higher.
|
||||
|
||||
@@ -178,10 +179,15 @@ public:
|
||||
QString _directDownloadCookies;
|
||||
|
||||
struct {
|
||||
quint64 _size;
|
||||
time_t _modtime;
|
||||
QByteArray _etag;
|
||||
QByteArray _fileId;
|
||||
quint64 _other_size;
|
||||
time_t _other_modtime;
|
||||
QByteArray _other_etag;
|
||||
QByteArray _other_fileId;
|
||||
enum csync_instructions_e _instruction BITFIELD(16);
|
||||
enum csync_instructions_e _other_instruction BITFIELD(16);
|
||||
} log;
|
||||
};
|
||||
@@ -196,6 +202,5 @@ typedef QVector<SyncFileItemPtr> SyncFileItemVector;
|
||||
}
|
||||
|
||||
Q_DECLARE_METATYPE(OCC::SyncFileItem)
|
||||
Q_DECLARE_METATYPE(OCC::SyncFileItemPtr)
|
||||
|
||||
#endif // SYNCFILEITEM_H
|
||||
|
||||
@@ -17,7 +17,6 @@
|
||||
#include "syncengine.h"
|
||||
#include "syncjournaldb.h"
|
||||
#include "syncjournalfilerecord.h"
|
||||
#include "asserts.h"
|
||||
|
||||
namespace OCC {
|
||||
|
||||
@@ -78,8 +77,8 @@ SyncFileStatusTracker::SyncFileStatusTracker(SyncEngine *syncEngine)
|
||||
{
|
||||
connect(syncEngine, SIGNAL(aboutToPropagate(SyncFileItemVector&)),
|
||||
SLOT(slotAboutToPropagate(SyncFileItemVector&)));
|
||||
connect(syncEngine, SIGNAL(itemCompleted(const SyncFileItemPtr&)),
|
||||
SLOT(slotItemCompleted(const SyncFileItemPtr&)));
|
||||
connect(syncEngine, SIGNAL(itemCompleted(const SyncFileItem&, const PropagatorJob&)),
|
||||
SLOT(slotItemCompleted(const SyncFileItem&)));
|
||||
connect(syncEngine, SIGNAL(finished(bool)), SLOT(slotSyncFinished()));
|
||||
connect(syncEngine, SIGNAL(started()), SLOT(slotSyncEngineRunningChanged()));
|
||||
connect(syncEngine, SIGNAL(finished(bool)), SLOT(slotSyncEngineRunningChanged()));
|
||||
@@ -87,7 +86,7 @@ SyncFileStatusTracker::SyncFileStatusTracker(SyncEngine *syncEngine)
|
||||
|
||||
SyncFileStatus SyncFileStatusTracker::fileStatus(const QString& relativePath)
|
||||
{
|
||||
ASSERT(!relativePath.endsWith(QLatin1Char('/')));
|
||||
Q_ASSERT(!relativePath.endsWith(QLatin1Char('/')));
|
||||
|
||||
if (relativePath.isEmpty()) {
|
||||
// This is the root sync folder, it doesn't have an entry in the database and won't be walked by csync, so resolve manually.
|
||||
@@ -122,8 +121,8 @@ SyncFileStatus SyncFileStatusTracker::fileStatus(const QString& relativePath)
|
||||
void SyncFileStatusTracker::slotPathTouched(const QString& fileName)
|
||||
{
|
||||
QString folderPath = _syncEngine->localPath();
|
||||
Q_ASSERT(fileName.startsWith(folderPath));
|
||||
|
||||
ASSERT(fileName.startsWith(folderPath));
|
||||
QString localPath = fileName.mid(folderPath.size());
|
||||
_dirtyPaths.insert(localPath);
|
||||
|
||||
@@ -142,7 +141,7 @@ void SyncFileStatusTracker::incSyncCountAndEmitStatusChanged(const QString &rela
|
||||
|
||||
// We passed from OK to SYNC, increment the parent to keep it marked as
|
||||
// SYNC while we propagate ourselves and our own children.
|
||||
ASSERT(!relativePath.endsWith('/'));
|
||||
Q_ASSERT(!relativePath.endsWith('/'));
|
||||
int lastSlashIndex = relativePath.lastIndexOf('/');
|
||||
if (lastSlashIndex != -1)
|
||||
incSyncCountAndEmitStatusChanged(relativePath.left(lastSlashIndex), UnknownShared);
|
||||
@@ -164,7 +163,7 @@ void SyncFileStatusTracker::decSyncCountAndEmitStatusChanged(const QString &rela
|
||||
emit fileStatusChanged(getSystemDestination(relativePath), status);
|
||||
|
||||
// We passed from SYNC to OK, decrement our parent.
|
||||
ASSERT(!relativePath.endsWith('/'));
|
||||
Q_ASSERT(!relativePath.endsWith('/'));
|
||||
int lastSlashIndex = relativePath.lastIndexOf('/');
|
||||
if (lastSlashIndex != -1)
|
||||
decSyncCountAndEmitStatusChanged(relativePath.left(lastSlashIndex), UnknownShared);
|
||||
@@ -175,7 +174,7 @@ void SyncFileStatusTracker::decSyncCountAndEmitStatusChanged(const QString &rela
|
||||
|
||||
void SyncFileStatusTracker::slotAboutToPropagate(SyncFileItemVector& items)
|
||||
{
|
||||
ASSERT(_syncCount.isEmpty());
|
||||
Q_ASSERT(_syncCount.isEmpty());
|
||||
|
||||
std::map<QString, SyncFileStatus::SyncFileStatusTag> oldProblems;
|
||||
std::swap(_syncProblems, oldProblems);
|
||||
@@ -224,28 +223,28 @@ void SyncFileStatusTracker::slotAboutToPropagate(SyncFileItemVector& items)
|
||||
}
|
||||
}
|
||||
|
||||
void SyncFileStatusTracker::slotItemCompleted(const SyncFileItemPtr &item)
|
||||
void SyncFileStatusTracker::slotItemCompleted(const SyncFileItem &item)
|
||||
{
|
||||
// qDebug() << Q_FUNC_INFO << item.destination() << item._status << item._instruction;
|
||||
|
||||
if (showErrorInSocketApi(*item)) {
|
||||
_syncProblems[item->_file] = SyncFileStatus::StatusError;
|
||||
invalidateParentPaths(item->destination());
|
||||
} else if (showWarningInSocketApi(*item)) {
|
||||
_syncProblems[item->_file] = SyncFileStatus::StatusWarning;
|
||||
if (showErrorInSocketApi(item)) {
|
||||
_syncProblems[item._file] = SyncFileStatus::StatusError;
|
||||
invalidateParentPaths(item.destination());
|
||||
} else if (showWarningInSocketApi(item)) {
|
||||
_syncProblems[item._file] = SyncFileStatus::StatusWarning;
|
||||
} else {
|
||||
_syncProblems.erase(item->_file);
|
||||
_syncProblems.erase(item._file);
|
||||
}
|
||||
|
||||
SharedFlag sharedFlag = item->_remotePerm.contains("S") ? Shared : NotShared;
|
||||
if (item->_instruction != CSYNC_INSTRUCTION_NONE
|
||||
&& item->_instruction != CSYNC_INSTRUCTION_UPDATE_METADATA
|
||||
&& item->_instruction != CSYNC_INSTRUCTION_IGNORE
|
||||
&& item->_instruction != CSYNC_INSTRUCTION_ERROR) {
|
||||
SharedFlag sharedFlag = item._remotePerm.contains("S") ? Shared : NotShared;
|
||||
if (item._instruction != CSYNC_INSTRUCTION_NONE
|
||||
&& item._instruction != CSYNC_INSTRUCTION_UPDATE_METADATA
|
||||
&& item._instruction != CSYNC_INSTRUCTION_IGNORE
|
||||
&& item._instruction != CSYNC_INSTRUCTION_ERROR) {
|
||||
// decSyncCount calls *must* be symetric with incSyncCount calls in slotAboutToPropagate
|
||||
decSyncCountAndEmitStatusChanged(item->destination(), sharedFlag);
|
||||
decSyncCountAndEmitStatusChanged(item.destination(), sharedFlag);
|
||||
} else {
|
||||
emit fileStatusChanged(getSystemDestination(item->destination()), resolveSyncAndErrorStatus(item->destination(), sharedFlag));
|
||||
emit fileStatusChanged(getSystemDestination(item.destination()), resolveSyncAndErrorStatus(item.destination(), sharedFlag));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -278,8 +277,8 @@ SyncFileStatus SyncFileStatusTracker::resolveSyncAndErrorStatus(const QString &r
|
||||
status.set(problemStatus);
|
||||
}
|
||||
|
||||
ASSERT(sharedFlag != UnknownShared,
|
||||
"The shared status needs to have been fetched from a SyncFileItem or the DB at this point.");
|
||||
// The shared status needs to have been fetched from a SyncFileItem or the DB at this point.
|
||||
Q_ASSERT(sharedFlag != UnknownShared);
|
||||
if (sharedFlag == Shared)
|
||||
status.setSharedWithMe(true);
|
||||
|
||||
|
||||
@@ -46,7 +46,7 @@ signals:
|
||||
|
||||
private slots:
|
||||
void slotAboutToPropagate(SyncFileItemVector& items);
|
||||
void slotItemCompleted(const SyncFileItemPtr& item);
|
||||
void slotItemCompleted(const SyncFileItem& item);
|
||||
void slotSyncFinished();
|
||||
void slotSyncEngineRunningChanged();
|
||||
|
||||
|
||||
@@ -27,7 +27,6 @@
|
||||
#include "utility.h"
|
||||
#include "version.h"
|
||||
#include "filesystem.h"
|
||||
#include "asserts.h"
|
||||
|
||||
#include "../../csync/src/std/c_jhash.h"
|
||||
|
||||
@@ -179,7 +178,7 @@ bool SyncJournalDb::sqlFail( const QString& log, const SqlQuery& query )
|
||||
{
|
||||
commitTransaction();
|
||||
qWarning() << "SQL Error" << log << query.error();
|
||||
ASSERT(false);
|
||||
Q_ASSERT(!"SQL ERROR");
|
||||
_db.close();
|
||||
return false;
|
||||
}
|
||||
@@ -1371,22 +1370,21 @@ void SyncJournalDb::setUploadInfo(const QString& file, const SyncJournalDb::Uplo
|
||||
}
|
||||
}
|
||||
|
||||
QVector<uint> SyncJournalDb::deleteStaleUploadInfos(const QSet<QString> &keep)
|
||||
bool SyncJournalDb::deleteStaleUploadInfos(const QSet<QString> &keep)
|
||||
{
|
||||
QMutexLocker locker(&_mutex);
|
||||
QVector<uint> ids;
|
||||
|
||||
if (!checkConnect()) {
|
||||
return ids;
|
||||
return false;
|
||||
}
|
||||
|
||||
SqlQuery query(_db);
|
||||
query.prepare("SELECT path,transferid FROM uploadinfo");
|
||||
query.prepare("SELECT path FROM uploadinfo");
|
||||
|
||||
if (!query.exec()) {
|
||||
QString err = query.error();
|
||||
qDebug() << "Error creating prepared statement: " << query.lastQuery() << ", Error:" << err;
|
||||
return ids;
|
||||
return false;
|
||||
}
|
||||
|
||||
QStringList superfluousPaths;
|
||||
@@ -1395,12 +1393,10 @@ QVector<uint> SyncJournalDb::deleteStaleUploadInfos(const QSet<QString> &keep)
|
||||
const QString file = query.stringValue(0);
|
||||
if (!keep.contains(file)) {
|
||||
superfluousPaths.append(file);
|
||||
ids.append(query.intValue(1));
|
||||
}
|
||||
}
|
||||
|
||||
deleteBatch(*_deleteUploadInfoQuery, superfluousPaths, "uploadinfo");
|
||||
return ids;
|
||||
return deleteBatch(*_deleteUploadInfoQuery, superfluousPaths, "uploadinfo");
|
||||
}
|
||||
|
||||
SyncJournalErrorBlacklistRecord SyncJournalDb::errorBlacklistEntry( const QString& file )
|
||||
@@ -1608,7 +1604,7 @@ void SyncJournalDb::setPollInfo(const SyncJournalDb::PollInfo& info)
|
||||
QStringList SyncJournalDb::getSelectiveSyncList(SyncJournalDb::SelectiveSyncListType type, bool *ok )
|
||||
{
|
||||
QStringList result;
|
||||
ASSERT(ok);
|
||||
Q_ASSERT(ok);
|
||||
|
||||
QMutexLocker locker(&_mutex);
|
||||
if( !checkConnect() ) {
|
||||
|
||||
@@ -105,8 +105,7 @@ public:
|
||||
|
||||
UploadInfo getUploadInfo(const QString &file);
|
||||
void setUploadInfo(const QString &file, const UploadInfo &i);
|
||||
// Return the list of transfer ids that were removed.
|
||||
QVector<uint> deleteStaleUploadInfos(const QSet<QString>& keep);
|
||||
bool deleteStaleUploadInfos(const QSet<QString>& keep);
|
||||
|
||||
SyncJournalErrorBlacklistRecord errorBlacklistEntry( const QString& );
|
||||
bool deleteStaleErrorBlacklistEntries(const QSet<QString>& keep);
|
||||
|
||||
@@ -13,22 +13,19 @@
|
||||
*/
|
||||
|
||||
#include "syncresult.h"
|
||||
#include "progressdispatcher.h"
|
||||
|
||||
namespace OCC
|
||||
{
|
||||
|
||||
SyncResult::SyncResult()
|
||||
: _status( Undefined )
|
||||
, _foundFilesNotSynced(false)
|
||||
, _folderStructureWasChanged(false)
|
||||
, _numNewItems(0)
|
||||
, _numRemovedItems(0)
|
||||
, _numUpdatedItems(0)
|
||||
, _numRenamedItems(0)
|
||||
, _numConflictItems(0)
|
||||
, _numErrorItems(0)
|
||||
: _status( Undefined ),
|
||||
_warnCount(0)
|
||||
{
|
||||
}
|
||||
|
||||
SyncResult::SyncResult(SyncResult::Status status )
|
||||
: _status(status),
|
||||
_warnCount(0)
|
||||
{
|
||||
}
|
||||
|
||||
@@ -37,11 +34,6 @@ SyncResult::Status SyncResult::status() const
|
||||
return _status;
|
||||
}
|
||||
|
||||
void SyncResult::reset()
|
||||
{
|
||||
*this = SyncResult();
|
||||
}
|
||||
|
||||
QString SyncResult::statusString() const
|
||||
{
|
||||
QString re;
|
||||
@@ -88,17 +80,42 @@ void SyncResult::setStatus( Status stat )
|
||||
_syncTime = QDateTime::currentDateTime();
|
||||
}
|
||||
|
||||
void SyncResult::setSyncFileItemVector( const SyncFileItemVector& items )
|
||||
{
|
||||
_syncItems = items;
|
||||
}
|
||||
|
||||
SyncFileItemVector SyncResult::syncFileItemVector() const
|
||||
{
|
||||
return _syncItems;
|
||||
}
|
||||
|
||||
QDateTime SyncResult::syncTime() const
|
||||
{
|
||||
return _syncTime;
|
||||
}
|
||||
|
||||
void SyncResult::setWarnCount(int wc)
|
||||
{
|
||||
_warnCount = wc;
|
||||
}
|
||||
|
||||
int SyncResult::warnCount() const
|
||||
{
|
||||
return _warnCount;
|
||||
}
|
||||
|
||||
void SyncResult::setErrorStrings( const QStringList& list )
|
||||
{
|
||||
_errors = list;
|
||||
}
|
||||
|
||||
QStringList SyncResult::errorStrings() const
|
||||
{
|
||||
return _errors;
|
||||
}
|
||||
|
||||
void SyncResult::appendErrorString( const QString& err )
|
||||
void SyncResult::setErrorString( const QString& err )
|
||||
{
|
||||
_errors.append( err );
|
||||
}
|
||||
@@ -124,68 +141,8 @@ QString SyncResult::folder() const
|
||||
return _folder;
|
||||
}
|
||||
|
||||
void SyncResult::processCompletedItem(const SyncFileItemPtr &item)
|
||||
SyncResult::~SyncResult()
|
||||
{
|
||||
if (Progress::isWarningKind(item->_status)) {
|
||||
// Count any error conditions, error strings will have priority anyway.
|
||||
_foundFilesNotSynced = true;
|
||||
}
|
||||
|
||||
if (item->_isDirectory && (item->_instruction == CSYNC_INSTRUCTION_NEW
|
||||
|| item->_instruction == CSYNC_INSTRUCTION_TYPE_CHANGE
|
||||
|| item->_instruction == CSYNC_INSTRUCTION_REMOVE
|
||||
|| item->_instruction == CSYNC_INSTRUCTION_RENAME)) {
|
||||
_folderStructureWasChanged = true;
|
||||
}
|
||||
|
||||
// Process the item to the gui
|
||||
if( item->_status == SyncFileItem::FatalError || item->_status == SyncFileItem::NormalError ) {
|
||||
//: this displays an error string (%2) for a file %1
|
||||
appendErrorString( QObject::tr("%1: %2").arg(item->_file, item->_errorString) );
|
||||
_numErrorItems++;
|
||||
if (!_firstItemError) {
|
||||
_firstItemError = item;
|
||||
}
|
||||
} else if( item->_status == SyncFileItem::Conflict ) {
|
||||
_numConflictItems++;
|
||||
if (!_firstConflictItem) {
|
||||
_firstConflictItem = item;
|
||||
}
|
||||
} else {
|
||||
if (!item->hasErrorStatus() && item->_status != SyncFileItem::FileIgnored && item->_direction == SyncFileItem::Down) {
|
||||
switch (item->_instruction) {
|
||||
case CSYNC_INSTRUCTION_NEW:
|
||||
case CSYNC_INSTRUCTION_TYPE_CHANGE:
|
||||
_numNewItems++;
|
||||
if (!_firstItemNew)
|
||||
_firstItemNew = item;
|
||||
break;
|
||||
case CSYNC_INSTRUCTION_REMOVE:
|
||||
_numRemovedItems++;
|
||||
if (!_firstItemDeleted)
|
||||
_firstItemDeleted = item;
|
||||
break;
|
||||
case CSYNC_INSTRUCTION_SYNC:
|
||||
_numUpdatedItems++;
|
||||
if (!_firstItemUpdated)
|
||||
_firstItemUpdated = item;
|
||||
break;
|
||||
case CSYNC_INSTRUCTION_RENAME:
|
||||
if (!_firstItemRenamed) {
|
||||
_firstItemRenamed = item;
|
||||
}
|
||||
_numRenamedItems++;
|
||||
break;
|
||||
default:
|
||||
// nothing.
|
||||
break;
|
||||
}
|
||||
} else if( item->_direction == SyncFileItem::None ) {
|
||||
if( item->_instruction == CSYNC_INSTRUCTION_IGNORE ) {
|
||||
_foundFilesNotSynced = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
+11
-39
@@ -47,13 +47,20 @@ public:
|
||||
};
|
||||
|
||||
SyncResult();
|
||||
void reset();
|
||||
|
||||
void appendErrorString( const QString& );
|
||||
SyncResult( Status status );
|
||||
~SyncResult();
|
||||
void setErrorString( const QString& );
|
||||
void setErrorStrings( const QStringList& );
|
||||
QString errorString() const;
|
||||
QStringList errorStrings() const;
|
||||
int warnCount() const;
|
||||
void setWarnCount(int wc);
|
||||
void clearErrors();
|
||||
|
||||
// handle a list of changed items.
|
||||
void setSyncFileItemVector( const SyncFileItemVector& );
|
||||
SyncFileItemVector syncFileItemVector() const;
|
||||
|
||||
void setStatus( Status );
|
||||
Status status() const;
|
||||
QString statusString() const;
|
||||
@@ -61,25 +68,6 @@ public:
|
||||
void setFolder(const QString& folder);
|
||||
QString folder() const;
|
||||
|
||||
bool foundFilesNotSynced() const { return _foundFilesNotSynced; }
|
||||
bool folderStructureWasChanged() const { return _folderStructureWasChanged; }
|
||||
|
||||
int numNewItems() const { return _numNewItems; }
|
||||
int numRemovedItems() const { return _numRemovedItems; }
|
||||
int numUpdatedItems() const { return _numUpdatedItems; }
|
||||
int numRenamedItems() const { return _numRenamedItems; }
|
||||
int numConflictItems() const { return _numConflictItems; }
|
||||
int numErrorItems() const { return _numErrorItems; }
|
||||
|
||||
const SyncFileItemPtr& firstItemNew() const { return _firstItemNew; }
|
||||
const SyncFileItemPtr& firstItemDeleted() const { return _firstItemDeleted; }
|
||||
const SyncFileItemPtr& firstItemUpdated() const { return _firstItemUpdated; }
|
||||
const SyncFileItemPtr& firstItemRenamed() const { return _firstItemRenamed; }
|
||||
const SyncFileItemPtr& firstConflictItem() const { return _firstConflictItem; }
|
||||
const SyncFileItemPtr& firstItemError() const { return _firstItemError; }
|
||||
|
||||
void processCompletedItem(const SyncFileItemPtr &item);
|
||||
|
||||
private:
|
||||
Status _status;
|
||||
SyncFileItemVector _syncItems;
|
||||
@@ -89,23 +77,7 @@ private:
|
||||
* when the sync tool support this...
|
||||
*/
|
||||
QStringList _errors;
|
||||
bool _foundFilesNotSynced;
|
||||
bool _folderStructureWasChanged;
|
||||
|
||||
// count new, removed and updated items
|
||||
int _numNewItems;
|
||||
int _numRemovedItems;
|
||||
int _numUpdatedItems;
|
||||
int _numRenamedItems;
|
||||
int _numConflictItems;
|
||||
int _numErrorItems;
|
||||
|
||||
SyncFileItemPtr _firstItemNew;
|
||||
SyncFileItemPtr _firstItemDeleted;
|
||||
SyncFileItemPtr _firstItemUpdated;
|
||||
SyncFileItemPtr _firstItemRenamed;
|
||||
SyncFileItemPtr _firstConflictItem;
|
||||
SyncFileItemPtr _firstItemError;
|
||||
int _warnCount;
|
||||
};
|
||||
|
||||
}
|
||||
|
||||
+1
-12
@@ -275,15 +275,6 @@ qint64 Theme::newBigFolderSizeLimit() const
|
||||
return 500;
|
||||
}
|
||||
|
||||
bool Theme::wizardHideExternalStorageConfirmationCheckbox() const
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
bool Theme::wizardHideFolderSizeLimitCheckbox() const
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
QString Theme::gitSHA1() const
|
||||
{
|
||||
@@ -421,7 +412,7 @@ QPixmap Theme::wizardHeaderBanner() const
|
||||
if (!c.isValid())
|
||||
return QPixmap();
|
||||
|
||||
QPixmap pix(QSize(750, 78));
|
||||
QPixmap pix(QSize(600, 78));
|
||||
pix.fill(wizardHeaderBackgroundColor());
|
||||
return pix;
|
||||
}
|
||||
@@ -487,6 +478,4 @@ QString Theme::quotaBaseFolder() const
|
||||
{
|
||||
return QLatin1String("/");
|
||||
}
|
||||
|
||||
|
||||
} // end namespace client
|
||||
|
||||
@@ -219,17 +219,6 @@ public:
|
||||
**/
|
||||
virtual qint64 newBigFolderSizeLimit() const;
|
||||
|
||||
/**
|
||||
* Hide the checkbox that says "Ask for confirmation before synchronizing folders larger than X MB"
|
||||
* in the account wizard
|
||||
*/
|
||||
virtual bool wizardHideFolderSizeLimitCheckbox() const;
|
||||
/**
|
||||
* Hide the checkbox that says "Ask for confirmation before synchronizing external storages"
|
||||
* in the account wizard
|
||||
*/
|
||||
virtual bool wizardHideExternalStorageConfirmationCheckbox() const;
|
||||
|
||||
/**
|
||||
* Alternative path on the server that provides access to the webdav capabilities
|
||||
*
|
||||
@@ -313,7 +302,6 @@ public:
|
||||
*/
|
||||
virtual QString quotaBaseFolder() const;
|
||||
|
||||
|
||||
protected:
|
||||
#ifndef TOKEN_AUTH_ONLY
|
||||
QIcon themeIcon(const QString& name, bool sysTray = false, bool sysTrayMenuVisible = false) const;
|
||||
|
||||
@@ -2,6 +2,7 @@ include_directories(${CMAKE_BINARY_DIR}/csync ${CMAKE_BINARY_DIR}/csync/src ${CM
|
||||
include_directories(${CMAKE_SOURCE_DIR}/csync/src/)
|
||||
include_directories(${CMAKE_SOURCE_DIR}/csync/src/std ${CMAKE_SOURCE_DIR}/src)
|
||||
include_directories(${CMAKE_SOURCE_DIR}/src/3rdparty/qtokenizer)
|
||||
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fno-rtti")
|
||||
|
||||
include(QtVersionAbstraction)
|
||||
setup_qt()
|
||||
@@ -49,7 +50,6 @@ if(HAVE_QT5 AND NOT BUILD_WITH_QT4)
|
||||
owncloud_add_test(SyncFileStatusTracker "syncenginetestutils.h")
|
||||
owncloud_add_test(ChunkingNg "syncenginetestutils.h")
|
||||
owncloud_add_test(UploadReset "syncenginetestutils.h")
|
||||
owncloud_add_benchmark(LargeSync "syncenginetestutils.h")
|
||||
endif(HAVE_QT5 AND NOT BUILD_WITH_QT4)
|
||||
|
||||
SET(FolderMan_SRC ../src/gui/folderman.cpp)
|
||||
|
||||
@@ -1,43 +0,0 @@
|
||||
/*
|
||||
* This software is in the public domain, furnished "as is", without technical
|
||||
* support, and with no warranty, express or implied, as to its usefulness for
|
||||
* any purpose.
|
||||
*
|
||||
*/
|
||||
|
||||
#include "syncenginetestutils.h"
|
||||
#include <syncengine.h>
|
||||
|
||||
using namespace OCC;
|
||||
|
||||
int numDirs = 0;
|
||||
int numFiles = 0;
|
||||
|
||||
template<int filesPerDir, int dirPerDir, int maxDepth>
|
||||
void addBunchOfFiles(int depth, const QString &path, FileModifier &fi) {
|
||||
for (int fileNum = 1; fileNum <= filesPerDir; ++fileNum) {
|
||||
QString name = QStringLiteral("file") + QString::number(fileNum);
|
||||
fi.insert(path.isEmpty() ? name : path + "/" + name);
|
||||
numFiles++;
|
||||
}
|
||||
if (depth >= maxDepth)
|
||||
return;
|
||||
for (char dirNum = 1; dirNum <= dirPerDir; ++dirNum) {
|
||||
QString name = QStringLiteral("dir") + QString::number(dirNum);
|
||||
QString subPath = path.isEmpty() ? name : path + "/" + name;
|
||||
fi.mkdir(subPath);
|
||||
numDirs++;
|
||||
addBunchOfFiles<filesPerDir, dirPerDir, maxDepth>(depth + 1, subPath, fi);
|
||||
}
|
||||
}
|
||||
|
||||
int main(int argc, char *argv[])
|
||||
{
|
||||
QCoreApplication app(argc, argv);
|
||||
FakeFolder fakeFolder{FileInfo{}};
|
||||
addBunchOfFiles<10, 8, 4>(0, "", fakeFolder.localModifier());
|
||||
|
||||
qDebug() << "NUMFILES" << numFiles;
|
||||
qDebug() << "NUMDIRS" << numDirs;
|
||||
return fakeFolder.syncOnce() ? 0 : -1;
|
||||
}
|
||||
@@ -24,30 +24,3 @@ macro(owncloud_add_test test_class additional_cpp)
|
||||
add_definitions(-DOWNCLOUD_BIN_PATH=${CMAKE_BINARY_DIR}/bin)
|
||||
add_test(NAME ${OWNCLOUD_TEST_CLASS}Test COMMAND ${OWNCLOUD_TEST_CLASS}Test)
|
||||
endmacro()
|
||||
|
||||
macro(owncloud_add_benchmark test_class additional_cpp)
|
||||
include_directories(${CMAKE_CURRENT_SOURCE_DIR}
|
||||
${QT_INCLUDES}
|
||||
"${PROJECT_SOURCE_DIR}/src/gui"
|
||||
"${PROJECT_SOURCE_DIR}/src/libsync"
|
||||
"${CMAKE_BINARY_DIR}/src/libsync"
|
||||
"${CMAKE_CURRENT_BINARY_DIR}"
|
||||
)
|
||||
|
||||
set(CMAKE_AUTOMOC TRUE)
|
||||
set(OWNCLOUD_TEST_CLASS ${test_class})
|
||||
string(TOLOWER "${OWNCLOUD_TEST_CLASS}" OWNCLOUD_TEST_CLASS_LOWERCASE)
|
||||
|
||||
add_executable(${OWNCLOUD_TEST_CLASS}Bench benchmarks/bench${OWNCLOUD_TEST_CLASS_LOWERCASE}.cpp ${additional_cpp})
|
||||
qt5_use_modules(${OWNCLOUD_TEST_CLASS}Bench Test Sql Xml Network)
|
||||
|
||||
target_link_libraries(${OWNCLOUD_TEST_CLASS}Bench
|
||||
updater
|
||||
${APPLICATION_EXECUTABLE}sync
|
||||
${QT_QTTEST_LIBRARY}
|
||||
${QT_QTCORE_LIBRARY}
|
||||
)
|
||||
|
||||
add_definitions(-DOWNCLOUD_TEST)
|
||||
add_definitions(-DOWNCLOUD_BIN_PATH=${CMAKE_BINARY_DIR}/bin)
|
||||
endmacro()
|
||||
|
||||
@@ -226,7 +226,7 @@ public:
|
||||
etag = file->etag;
|
||||
return file;
|
||||
}
|
||||
return 0;
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
FileInfo *createDir(const QString &relativePath) {
|
||||
@@ -267,15 +267,6 @@ public:
|
||||
return (parentPath.isEmpty() ? QString() : (parentPath + '/')) + name;
|
||||
}
|
||||
|
||||
void fixupParentPathRecursively() {
|
||||
auto p = path();
|
||||
for (auto it = children.begin(); it != children.end(); ++it) {
|
||||
Q_ASSERT(it.key() == it->name);
|
||||
it->parentPath = p;
|
||||
it->fixupParentPathRecursively();
|
||||
}
|
||||
}
|
||||
|
||||
QString name;
|
||||
bool isDir = true;
|
||||
bool isShared = false;
|
||||
@@ -294,6 +285,15 @@ private:
|
||||
return find(pathComponents, true);
|
||||
}
|
||||
|
||||
void fixupParentPathRecursively() {
|
||||
auto p = path();
|
||||
for (auto it = children.begin(); it != children.end(); ++it) {
|
||||
Q_ASSERT(it.key() == it->name);
|
||||
it->parentPath = p;
|
||||
it->fixupParentPathRecursively();
|
||||
}
|
||||
}
|
||||
|
||||
friend inline QDebug operator<<(QDebug dbg, const FileInfo& fi) {
|
||||
return dbg << "{ " << fi.path() << ": " << fi.children;
|
||||
}
|
||||
@@ -315,10 +315,7 @@ public:
|
||||
QString fileName = getFilePathFromUrl(request.url());
|
||||
Q_ASSERT(!fileName.isNull()); // for root, it should be empty
|
||||
const FileInfo *fileInfo = remoteRootFileInfo.find(fileName);
|
||||
if (!fileInfo) {
|
||||
QMetaObject::invokeMethod(this, "respond404", Qt::QueuedConnection);
|
||||
return;
|
||||
}
|
||||
Q_ASSERT(fileInfo);
|
||||
QString prefix = request.url().path().left(request.url().path().size() - fileName.size());
|
||||
|
||||
// Don't care about the request and just return a full propfind
|
||||
@@ -378,13 +375,6 @@ public:
|
||||
emit finished();
|
||||
}
|
||||
|
||||
Q_INVOKABLE void respond404() {
|
||||
setAttribute(QNetworkRequest::HttpStatusCodeAttribute, 404);
|
||||
setError(InternalServerError, "Not Found");
|
||||
emit metaDataChanged();
|
||||
emit finished();
|
||||
}
|
||||
|
||||
void abort() override { }
|
||||
|
||||
qint64 bytesAvailable() const override { return payload.size() + QIODevice::bytesAvailable(); }
|
||||
@@ -534,8 +524,7 @@ class FakeGetReply : public QNetworkReply
|
||||
Q_OBJECT
|
||||
public:
|
||||
const FileInfo *fileInfo;
|
||||
char payload;
|
||||
int size;
|
||||
QByteArray payload;
|
||||
|
||||
FakeGetReply(FileInfo &remoteRootFileInfo, QNetworkAccessManager::Operation op, const QNetworkRequest &request, QObject *parent)
|
||||
: QNetworkReply{parent} {
|
||||
@@ -551,9 +540,8 @@ public:
|
||||
}
|
||||
|
||||
Q_INVOKABLE void respond() {
|
||||
payload = fileInfo->contentChar;
|
||||
size = fileInfo->size;
|
||||
setHeader(QNetworkRequest::ContentLengthHeader, size);
|
||||
payload.fill(fileInfo->contentChar, fileInfo->size);
|
||||
setHeader(QNetworkRequest::ContentLengthHeader, payload.size());
|
||||
setAttribute(QNetworkRequest::HttpStatusCodeAttribute, 200);
|
||||
setRawHeader("OC-ETag", fileInfo->etag.toLatin1());
|
||||
setRawHeader("ETag", fileInfo->etag.toLatin1());
|
||||
@@ -565,12 +553,12 @@ public:
|
||||
}
|
||||
|
||||
void abort() override { }
|
||||
qint64 bytesAvailable() const override { return size + QIODevice::bytesAvailable(); }
|
||||
qint64 bytesAvailable() const override { return payload.size() + QIODevice::bytesAvailable(); }
|
||||
|
||||
qint64 readData(char *data, qint64 maxlen) override {
|
||||
qint64 len = std::min(qint64{size}, maxlen);
|
||||
std::fill_n(data, len, payload);
|
||||
size -= len;
|
||||
qint64 len = std::min(qint64{payload.size()}, maxlen);
|
||||
strncpy(data, payload.constData(), len);
|
||||
payload.remove(0, len);
|
||||
return len;
|
||||
}
|
||||
};
|
||||
@@ -598,7 +586,7 @@ public:
|
||||
Q_ASSERT(sourceFolder->isDir);
|
||||
int count = 0;
|
||||
int size = 0;
|
||||
char payload = '\0';
|
||||
char payload = '*';
|
||||
|
||||
do {
|
||||
QString chunkName = QString::number(count).rightJustified(8, '0');
|
||||
@@ -608,7 +596,6 @@ public:
|
||||
Q_ASSERT(!x.isDir);
|
||||
Q_ASSERT(x.size > 0); // There should not be empty chunks
|
||||
size += x.size;
|
||||
Q_ASSERT(!payload || payload == x.contentChar);
|
||||
payload = x.contentChar;
|
||||
++count;
|
||||
} while(true);
|
||||
@@ -620,12 +607,7 @@ public:
|
||||
Q_ASSERT(!fileName.isEmpty());
|
||||
|
||||
if ((fileInfo = remoteRootFileInfo.find(fileName))) {
|
||||
QVERIFY(request.hasRawHeader("If")); // The client should put this header
|
||||
if (request.rawHeader("If") != QByteArray("<" + request.rawHeader("Destination") +
|
||||
"> ([\"" + fileInfo->etag.toLatin1() + "\"])")) {
|
||||
QMetaObject::invokeMethod(this, "respondPreconditionFailed", Qt::QueuedConnection);
|
||||
return;
|
||||
}
|
||||
QCOMPARE(request.rawHeader("If"), QByteArray("<" + request.rawHeader("Destination") + "> ([\"" + fileInfo->etag.toLatin1() + "\"])"));
|
||||
fileInfo->size = size;
|
||||
fileInfo->contentChar = payload;
|
||||
} else {
|
||||
@@ -650,13 +632,6 @@ public:
|
||||
emit finished();
|
||||
}
|
||||
|
||||
Q_INVOKABLE void respondPreconditionFailed() {
|
||||
setAttribute(QNetworkRequest::HttpStatusCodeAttribute, 412);
|
||||
setError(InternalServerError, "Precondition Failed");
|
||||
emit metaDataChanged();
|
||||
emit finished();
|
||||
}
|
||||
|
||||
void abort() override { }
|
||||
qint64 readData(char *, qint64) override { return 0; }
|
||||
};
|
||||
@@ -791,7 +766,6 @@ public:
|
||||
QDir rootDir{_tempDir.path()};
|
||||
FileInfo rootTemplate;
|
||||
fromDisk(rootDir, rootTemplate);
|
||||
rootTemplate.fixupParentPathRecursively();
|
||||
return rootTemplate;
|
||||
}
|
||||
|
||||
@@ -818,15 +792,15 @@ public:
|
||||
}
|
||||
|
||||
void execUntilItemCompleted(const QString &relativePath) {
|
||||
QSignalSpy spy(_syncEngine.get(), SIGNAL(itemCompleted(const SyncFileItemPtr &)));
|
||||
QSignalSpy spy(_syncEngine.get(), SIGNAL(itemCompleted(const SyncFileItem &, const PropagatorJob &)));
|
||||
QElapsedTimer t;
|
||||
t.start();
|
||||
while (t.elapsed() < 5000) {
|
||||
spy.clear();
|
||||
QVERIFY(spy.wait());
|
||||
for(const QList<QVariant> &args : spy) {
|
||||
auto item = args[0].value<OCC::SyncFileItemPtr>();
|
||||
if (item->destination() == relativePath)
|
||||
auto item = args[0].value<OCC::SyncFileItem>();
|
||||
if (item.destination() == relativePath)
|
||||
return;
|
||||
}
|
||||
}
|
||||
@@ -835,7 +809,7 @@ public:
|
||||
|
||||
bool execUntilFinished() {
|
||||
QSignalSpy spy(_syncEngine.get(), SIGNAL(finished(bool)));
|
||||
bool ok = spy.wait(3600000);
|
||||
bool ok = spy.wait(60000);
|
||||
Q_ASSERT(ok && "Sync timed out");
|
||||
return spy[0][0].toBool();
|
||||
}
|
||||
@@ -868,8 +842,8 @@ private:
|
||||
if (diskChild.isDir()) {
|
||||
QDir subDir = dir;
|
||||
subDir.cd(diskChild.fileName());
|
||||
FileInfo &subFi = templateFi.children[diskChild.fileName()] = FileInfo{diskChild.fileName()};
|
||||
fromDisk(subDir, subFi);
|
||||
templateFi.children.insert(diskChild.fileName(), FileInfo{diskChild.fileName()});
|
||||
fromDisk(subDir, templateFi.children.last());
|
||||
} else {
|
||||
QFile f{diskChild.filePath()};
|
||||
f.open(QFile::ReadOnly);
|
||||
|
||||
+24
-189
@@ -11,36 +11,6 @@
|
||||
|
||||
using namespace OCC;
|
||||
|
||||
/* Upload a 1/3 of a file of given size.
|
||||
* fakeFolder needs to be synchronized */
|
||||
static void partialUpload(FakeFolder &fakeFolder, const QString &name, int size)
|
||||
{
|
||||
QCOMPARE(fakeFolder.currentLocalState(), fakeFolder.currentRemoteState());
|
||||
QCOMPARE(fakeFolder.uploadState().children.count(), 0); // The state should be clean
|
||||
|
||||
fakeFolder.localModifier().insert(name, size);
|
||||
// Abort when the upload is at 1/3
|
||||
int sizeWhenAbort = -1;
|
||||
auto con = QObject::connect(&fakeFolder.syncEngine(), &SyncEngine::transmissionProgress,
|
||||
[&](const ProgressInfo &progress) {
|
||||
if (progress.completedSize() > (progress.totalSize() /3 )) {
|
||||
sizeWhenAbort = progress.completedSize();
|
||||
fakeFolder.syncEngine().abort();
|
||||
}
|
||||
});
|
||||
|
||||
QVERIFY(!fakeFolder.syncOnce()); // there should have been an error
|
||||
QObject::disconnect(con);
|
||||
QVERIFY(sizeWhenAbort > 0);
|
||||
QVERIFY(sizeWhenAbort < size);
|
||||
|
||||
QCOMPARE(fakeFolder.uploadState().children.count(), 1); // the transfer was done with chunking
|
||||
auto upStateChildren = fakeFolder.uploadState().children.first().children;
|
||||
QCOMPARE(sizeWhenAbort, std::accumulate(upStateChildren.cbegin(), upStateChildren.cend(), 0,
|
||||
[](int s, const FileInfo &i) { return s + i.size; }));
|
||||
}
|
||||
|
||||
|
||||
class TestChunkingNG : public QObject
|
||||
{
|
||||
Q_OBJECT
|
||||
@@ -70,173 +40,38 @@ private slots:
|
||||
FakeFolder fakeFolder{FileInfo::A12_B12_C12_S12()};
|
||||
fakeFolder.syncEngine().account()->setCapabilities({ { "dav", QVariantMap{ {"chunking", "1.0"} } } });
|
||||
const int size = 300 * 1000 * 1000; // 300 MB
|
||||
partialUpload(fakeFolder, "A/a0", size);
|
||||
QCOMPARE(fakeFolder.uploadState().children.count(), 1);
|
||||
auto chunkingId = fakeFolder.uploadState().children.first().name;
|
||||
fakeFolder.localModifier().insert("A/a0", size);
|
||||
|
||||
// Abort when the upload is at 1/3
|
||||
int sizeWhenAbort = -1;
|
||||
auto con = QObject::connect(&fakeFolder.syncEngine(), &SyncEngine::transmissionProgress,
|
||||
[&](const ProgressInfo &progress) {
|
||||
if (progress.completedSize() > (progress.totalSize() /3 )) {
|
||||
sizeWhenAbort = progress.completedSize();
|
||||
fakeFolder.syncEngine().abort();
|
||||
}
|
||||
});
|
||||
|
||||
QVERIFY(!fakeFolder.syncOnce()); // there should have been an error
|
||||
QObject::disconnect(con);
|
||||
QVERIFY(sizeWhenAbort > 0);
|
||||
QVERIFY(sizeWhenAbort < size);
|
||||
QCOMPARE(fakeFolder.uploadState().children.count(), 1); // the transfer was done with chunking
|
||||
auto upStateChildren = fakeFolder.uploadState().children.first().children;
|
||||
QCOMPARE(sizeWhenAbort, std::accumulate(upStateChildren.cbegin(), upStateChildren.cend(), 0,
|
||||
[](int s, const FileInfo &i) { return s + i.size; }));
|
||||
|
||||
|
||||
// Add a fake file to make sure it gets deleted
|
||||
fakeFolder.uploadState().children.first().insert("10000", size);
|
||||
QVERIFY(fakeFolder.syncOnce());
|
||||
|
||||
|
||||
|
||||
QCOMPARE(fakeFolder.currentLocalState(), fakeFolder.currentRemoteState());
|
||||
QCOMPARE(fakeFolder.uploadState().children.count(), 1); // The same chunk id was re-used
|
||||
QCOMPARE(fakeFolder.currentRemoteState().find("A/a0")->size, size);
|
||||
// The same chunk id was re-used
|
||||
QCOMPARE(fakeFolder.uploadState().children.count(), 1);
|
||||
QCOMPARE(fakeFolder.uploadState().children.first().name, chunkingId);
|
||||
}
|
||||
|
||||
// We modify the file locally after it has been partially uploaded
|
||||
void testRemoveStale1() {
|
||||
|
||||
FakeFolder fakeFolder{FileInfo::A12_B12_C12_S12()};
|
||||
fakeFolder.syncEngine().account()->setCapabilities({ { "dav", QVariantMap{ {"chunking", "1.0"} } } });
|
||||
const int size = 300 * 1000 * 1000; // 300 MB
|
||||
partialUpload(fakeFolder, "A/a0", size);
|
||||
QCOMPARE(fakeFolder.uploadState().children.count(), 1);
|
||||
auto chunkingId = fakeFolder.uploadState().children.first().name;
|
||||
|
||||
|
||||
fakeFolder.localModifier().setContents("A/a0", 'B');
|
||||
fakeFolder.localModifier().appendByte("A/a0");
|
||||
|
||||
QVERIFY(fakeFolder.syncOnce());
|
||||
|
||||
QCOMPARE(fakeFolder.currentLocalState(), fakeFolder.currentRemoteState());
|
||||
QCOMPARE(fakeFolder.currentRemoteState().find("A/a0")->size, size + 1);
|
||||
// A different chunk id was used, and the previous one is removed
|
||||
QCOMPARE(fakeFolder.uploadState().children.count(), 1);
|
||||
QVERIFY(fakeFolder.uploadState().children.first().name != chunkingId);
|
||||
}
|
||||
|
||||
// We remove the file locally after it has been partially uploaded
|
||||
void testRemoveStale2() {
|
||||
|
||||
FakeFolder fakeFolder{FileInfo::A12_B12_C12_S12()};
|
||||
fakeFolder.syncEngine().account()->setCapabilities({ { "dav", QVariantMap{ {"chunking", "1.0"} } } });
|
||||
const int size = 300 * 1000 * 1000; // 300 MB
|
||||
partialUpload(fakeFolder, "A/a0", size);
|
||||
QCOMPARE(fakeFolder.uploadState().children.count(), 1);
|
||||
|
||||
fakeFolder.localModifier().remove("A/a0");
|
||||
|
||||
QVERIFY(fakeFolder.syncOnce());
|
||||
QCOMPARE(fakeFolder.uploadState().children.count(), 0);
|
||||
}
|
||||
|
||||
|
||||
void testCreateConflictWhileSyncing() {
|
||||
FakeFolder fakeFolder{FileInfo::A12_B12_C12_S12()};
|
||||
fakeFolder.syncEngine().account()->setCapabilities({ { "dav", QVariantMap{ {"chunking", "1.0"} } } });
|
||||
const int size = 150 * 1000 * 1000; // 150 MB
|
||||
|
||||
// Put a file on the server and download it.
|
||||
fakeFolder.remoteModifier().insert("A/a0", size);
|
||||
QVERIFY(fakeFolder.syncOnce());
|
||||
QCOMPARE(fakeFolder.currentLocalState(), fakeFolder.currentRemoteState());
|
||||
|
||||
// Modify the file localy and start the upload
|
||||
fakeFolder.localModifier().setContents("A/a0", 'B');
|
||||
fakeFolder.localModifier().appendByte("A/a0");
|
||||
|
||||
// But in the middle of the sync, modify the file on the server
|
||||
QMetaObject::Connection con = QObject::connect(&fakeFolder.syncEngine(), &SyncEngine::transmissionProgress,
|
||||
[&](const ProgressInfo &progress) {
|
||||
if (progress.completedSize() > (progress.totalSize() / 2 )) {
|
||||
fakeFolder.remoteModifier().setContents("A/a0", 'C');
|
||||
QObject::disconnect(con);
|
||||
}
|
||||
});
|
||||
|
||||
QVERIFY(!fakeFolder.syncOnce());
|
||||
// There was a precondition failed error, this means wen need to sync again
|
||||
QCOMPARE(fakeFolder.syncEngine().isAnotherSyncNeeded(), ImmediateFollowUp);
|
||||
|
||||
QCOMPARE(fakeFolder.uploadState().children.count(), 1); // We did not clean the chunks at this point
|
||||
|
||||
// Now we will download the server file and create a conflict
|
||||
QVERIFY(fakeFolder.syncOnce());
|
||||
auto localState = fakeFolder.currentLocalState();
|
||||
|
||||
// A0 is the one from the server
|
||||
QCOMPARE(localState.find("A/a0")->size, size);
|
||||
QCOMPARE(localState.find("A/a0")->contentChar, 'C');
|
||||
|
||||
// There is a conflict file with our version
|
||||
auto &stateAChildren = localState.find("A")->children;
|
||||
auto it = std::find_if(stateAChildren.cbegin(), stateAChildren.cend(), [&](const FileInfo &fi) {
|
||||
return fi.name.startsWith("a0_conflict");
|
||||
});
|
||||
QVERIFY(it != stateAChildren.cend());
|
||||
QCOMPARE(it->contentChar, 'B');
|
||||
QCOMPARE(it->size, size+1);
|
||||
|
||||
// Remove the conflict file so the comparison works!
|
||||
fakeFolder.localModifier().remove("A/" + it->name);
|
||||
|
||||
QCOMPARE(fakeFolder.currentLocalState(), fakeFolder.currentRemoteState());
|
||||
|
||||
QCOMPARE(fakeFolder.uploadState().children.count(), 0); // The last sync cleaned the chunks
|
||||
}
|
||||
|
||||
void testModifyLocalFileWhileUploading() {
|
||||
|
||||
FakeFolder fakeFolder{FileInfo::A12_B12_C12_S12()};
|
||||
fakeFolder.syncEngine().account()->setCapabilities({ { "dav", QVariantMap{ {"chunking", "1.0"} } } });
|
||||
const int size = 150 * 1000 * 1000; // 150 MB
|
||||
|
||||
fakeFolder.localModifier().insert("A/a0", size);
|
||||
|
||||
// middle of the sync, modify the file
|
||||
QMetaObject::Connection con = QObject::connect(&fakeFolder.syncEngine(), &SyncEngine::transmissionProgress,
|
||||
[&](const ProgressInfo &progress) {
|
||||
if (progress.completedSize() > (progress.totalSize() / 2 )) {
|
||||
fakeFolder.localModifier().setContents("A/a0", 'B');
|
||||
fakeFolder.localModifier().appendByte("A/a0");
|
||||
QObject::disconnect(con);
|
||||
}
|
||||
});
|
||||
|
||||
QVERIFY(!fakeFolder.syncOnce());
|
||||
|
||||
// There should be a followup sync
|
||||
QCOMPARE(fakeFolder.syncEngine().isAnotherSyncNeeded(), ImmediateFollowUp);
|
||||
|
||||
QCOMPARE(fakeFolder.uploadState().children.count(), 1); // We did not clean the chunks at this point
|
||||
auto chunkingId = fakeFolder.uploadState().children.first().name;
|
||||
|
||||
// Now we make a new sync which should upload the file for good.
|
||||
QVERIFY(fakeFolder.syncOnce());
|
||||
|
||||
QCOMPARE(fakeFolder.currentLocalState(), fakeFolder.currentRemoteState());
|
||||
QCOMPARE(fakeFolder.currentRemoteState().find("A/a0")->size, size+1);
|
||||
|
||||
// A different chunk id was used, and the previous one is removed
|
||||
QCOMPARE(fakeFolder.uploadState().children.count(), 1);
|
||||
QVERIFY(fakeFolder.uploadState().children.first().name != chunkingId);
|
||||
}
|
||||
|
||||
|
||||
void testResumeServerDeletedChunks() {
|
||||
|
||||
FakeFolder fakeFolder{FileInfo::A12_B12_C12_S12()};
|
||||
fakeFolder.syncEngine().account()->setCapabilities({ { "dav", QVariantMap{ {"chunking", "1.0"} } } });
|
||||
const int size = 300 * 1000 * 1000; // 300 MB
|
||||
partialUpload(fakeFolder, "A/a0", size);
|
||||
QCOMPARE(fakeFolder.uploadState().children.count(), 1);
|
||||
auto chunkingId = fakeFolder.uploadState().children.first().name;
|
||||
|
||||
// Delete the chunks on the server
|
||||
fakeFolder.uploadState().children.clear();
|
||||
QVERIFY(fakeFolder.syncOnce());
|
||||
|
||||
QCOMPARE(fakeFolder.currentLocalState(), fakeFolder.currentRemoteState());
|
||||
QCOMPARE(fakeFolder.currentRemoteState().find("A/a0")->size, size);
|
||||
|
||||
// A different chunk id was used
|
||||
QCOMPARE(fakeFolder.uploadState().children.count(), 1);
|
||||
QVERIFY(fakeFolder.uploadState().children.first().name != chunkingId);
|
||||
}
|
||||
|
||||
};
|
||||
|
||||
QTEST_GUILESS_MAIN(TestChunkingNG)
|
||||
|
||||
+13
-24
@@ -14,8 +14,8 @@ using namespace OCC;
|
||||
bool itemDidComplete(const QSignalSpy &spy, const QString &path)
|
||||
{
|
||||
for(const QList<QVariant> &args : spy) {
|
||||
auto item = args[0].value<SyncFileItemPtr>();
|
||||
if (item->destination() == path)
|
||||
SyncFileItem item = args[0].value<SyncFileItem>();
|
||||
if (item.destination() == path)
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
@@ -24,9 +24,9 @@ bool itemDidComplete(const QSignalSpy &spy, const QString &path)
|
||||
bool itemDidCompleteSuccessfully(const QSignalSpy &spy, const QString &path)
|
||||
{
|
||||
for(const QList<QVariant> &args : spy) {
|
||||
auto item = args[0].value<SyncFileItemPtr>();
|
||||
if (item->destination() == path)
|
||||
return item->_status == SyncFileItem::Success;
|
||||
SyncFileItem item = args[0].value<SyncFileItem>();
|
||||
if (item.destination() == path)
|
||||
return item._status == SyncFileItem::Success;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
@@ -38,7 +38,7 @@ class TestSyncEngine : public QObject
|
||||
private slots:
|
||||
void testFileDownload() {
|
||||
FakeFolder fakeFolder{FileInfo::A12_B12_C12_S12()};
|
||||
QSignalSpy completeSpy(&fakeFolder.syncEngine(), SIGNAL(itemCompleted(const SyncFileItemPtr &)));
|
||||
QSignalSpy completeSpy(&fakeFolder.syncEngine(), SIGNAL(itemCompleted(const SyncFileItem &, const PropagatorJob &)));
|
||||
fakeFolder.remoteModifier().insert("A/a0");
|
||||
fakeFolder.syncOnce();
|
||||
QVERIFY(itemDidCompleteSuccessfully(completeSpy, "A/a0"));
|
||||
@@ -47,7 +47,7 @@ private slots:
|
||||
|
||||
void testFileUpload() {
|
||||
FakeFolder fakeFolder{FileInfo::A12_B12_C12_S12()};
|
||||
QSignalSpy completeSpy(&fakeFolder.syncEngine(), SIGNAL(itemCompleted(const SyncFileItemPtr &)));
|
||||
QSignalSpy completeSpy(&fakeFolder.syncEngine(), SIGNAL(itemCompleted(const SyncFileItem &, const PropagatorJob &)));
|
||||
fakeFolder.localModifier().insert("A/a0");
|
||||
fakeFolder.syncOnce();
|
||||
QVERIFY(itemDidCompleteSuccessfully(completeSpy, "A/a0"));
|
||||
@@ -56,7 +56,7 @@ private slots:
|
||||
|
||||
void testDirDownload() {
|
||||
FakeFolder fakeFolder{FileInfo::A12_B12_C12_S12()};
|
||||
QSignalSpy completeSpy(&fakeFolder.syncEngine(), SIGNAL(itemCompleted(const SyncFileItemPtr &)));
|
||||
QSignalSpy completeSpy(&fakeFolder.syncEngine(), SIGNAL(itemCompleted(const SyncFileItem &, const PropagatorJob &)));
|
||||
fakeFolder.remoteModifier().mkdir("Y");
|
||||
fakeFolder.remoteModifier().mkdir("Z");
|
||||
fakeFolder.remoteModifier().insert("Z/d0");
|
||||
@@ -69,7 +69,7 @@ private slots:
|
||||
|
||||
void testDirUpload() {
|
||||
FakeFolder fakeFolder{FileInfo::A12_B12_C12_S12()};
|
||||
QSignalSpy completeSpy(&fakeFolder.syncEngine(), SIGNAL(itemCompleted(const SyncFileItemPtr &)));
|
||||
QSignalSpy completeSpy(&fakeFolder.syncEngine(), SIGNAL(itemCompleted(const SyncFileItem &, const PropagatorJob &)));
|
||||
fakeFolder.localModifier().mkdir("Y");
|
||||
fakeFolder.localModifier().mkdir("Z");
|
||||
fakeFolder.localModifier().insert("Z/d0");
|
||||
@@ -82,7 +82,7 @@ private slots:
|
||||
|
||||
void testLocalDelete() {
|
||||
FakeFolder fakeFolder{FileInfo::A12_B12_C12_S12()};
|
||||
QSignalSpy completeSpy(&fakeFolder.syncEngine(), SIGNAL(itemCompleted(const SyncFileItemPtr &)));
|
||||
QSignalSpy completeSpy(&fakeFolder.syncEngine(), SIGNAL(itemCompleted(const SyncFileItem &, const PropagatorJob &)));
|
||||
fakeFolder.remoteModifier().remove("A/a1");
|
||||
fakeFolder.syncOnce();
|
||||
QVERIFY(itemDidCompleteSuccessfully(completeSpy, "A/a1"));
|
||||
@@ -91,7 +91,7 @@ private slots:
|
||||
|
||||
void testRemoteDelete() {
|
||||
FakeFolder fakeFolder{FileInfo::A12_B12_C12_S12()};
|
||||
QSignalSpy completeSpy(&fakeFolder.syncEngine(), SIGNAL(itemCompleted(const SyncFileItemPtr &)));
|
||||
QSignalSpy completeSpy(&fakeFolder.syncEngine(), SIGNAL(itemCompleted(const SyncFileItem &, const PropagatorJob &)));
|
||||
fakeFolder.localModifier().remove("A/a1");
|
||||
fakeFolder.syncOnce();
|
||||
QVERIFY(itemDidCompleteSuccessfully(completeSpy, "A/a1"));
|
||||
@@ -107,7 +107,7 @@ private slots:
|
||||
// fakeFolder.syncOnce();
|
||||
fakeFolder.syncOnce();
|
||||
|
||||
QSignalSpy completeSpy(&fakeFolder.syncEngine(), SIGNAL(itemCompleted(const SyncFileItemPtr &)));
|
||||
QSignalSpy completeSpy(&fakeFolder.syncEngine(), SIGNAL(itemCompleted(const SyncFileItem &, const PropagatorJob &)));
|
||||
// Touch the file without changing the content, shouldn't upload
|
||||
fakeFolder.localModifier().setContents("a1.eml", 'A');
|
||||
// Change the content/size
|
||||
@@ -204,7 +204,7 @@ private slots:
|
||||
QCOMPARE(fakeFolder.currentLocalState(), remoteState);
|
||||
|
||||
expectedServerState = fakeFolder.currentRemoteState();
|
||||
QSignalSpy completeSpy(&fakeFolder.syncEngine(), SIGNAL(itemCompleted(const SyncFileItemPtr &)));
|
||||
QSignalSpy completeSpy(&fakeFolder.syncEngine(), SIGNAL(itemCompleted(const SyncFileItem &, const PropagatorJob &)));
|
||||
fakeFolder.syncOnce(); // This sync should do nothing
|
||||
QCOMPARE(completeSpy.count(), 0);
|
||||
|
||||
@@ -213,17 +213,6 @@ private slots:
|
||||
}
|
||||
}
|
||||
|
||||
void abortAfterFailedMkdir() {
|
||||
FakeFolder fakeFolder{FileInfo{}};
|
||||
QSignalSpy finishedSpy(&fakeFolder.syncEngine(), SIGNAL(finished(bool)));
|
||||
fakeFolder.serverErrorPaths().append("NewFolder");
|
||||
fakeFolder.localModifier().mkdir("NewFolder");
|
||||
// This should be aborted and would otherwise fail in FileInfo::create.
|
||||
fakeFolder.localModifier().insert("NewFolder/NewFile");
|
||||
fakeFolder.syncOnce();
|
||||
QCOMPARE(finishedSpy.size(), 1);
|
||||
QCOMPARE(finishedSpy.first().first().toBool(), false);
|
||||
}
|
||||
};
|
||||
|
||||
QTEST_GUILESS_MAIN(TestSyncEngine)
|
||||
|
||||
+251
-275
Diferenças do arquivo suprimidas por serem muito extensas
Carregar Diff
+251
-275
Diferenças do arquivo suprimidas por serem muito extensas
Carregar Diff
+250
-277
Diferenças do arquivo suprimidas por serem muito extensas
Carregar Diff
+258
-282
Diferenças do arquivo suprimidas por serem muito extensas
Carregar Diff
+247
-272
Diferenças do arquivo suprimidas por serem muito extensas
Carregar Diff
Alguns arquivos não foram exibidos porque demasiados arquivos foram alterados neste diff Mostrar Mais
Referência em uma Nova Issue
Bloquear um usuário