Comparar commits
1 Commits
| Autor | SHA1 | Data | |
|---|---|---|---|
| 9db86ad9be |
+3
-2
@@ -7,8 +7,6 @@ endif()
|
||||
|
||||
project(client)
|
||||
|
||||
set(BIN_OUTPUT_DIRECTORY "${CMAKE_BINARY_DIR}/bin")
|
||||
|
||||
set(OEM_THEME_DIR "" CACHE STRING "Define directory containing a custom theme")
|
||||
if ( EXISTS ${OEM_THEME_DIR}/OEM.cmake )
|
||||
include ( ${OEM_THEME_DIR}/OEM.cmake )
|
||||
@@ -60,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)
|
||||
|
||||
externo
+1
-1
@@ -39,7 +39,7 @@ node('CLIENT') {
|
||||
|
||||
|
||||
stage 'Win32'
|
||||
def win32 = docker.image('guruz/docker-owncloud-client-win32:latest')
|
||||
def win32 = docker.image('deepdiver/docker-owncloud-client-win32:latest')
|
||||
win32.pull() // make sure we have the latest available from Docker Hub
|
||||
win32.inside {
|
||||
sh '''
|
||||
|
||||
@@ -9,7 +9,7 @@ ENV REFRESHED_AT 20160421
|
||||
|
||||
RUN zypper --non-interactive --gpg-auto-import-keys refresh
|
||||
RUN zypper --non-interactive --gpg-auto-import-keys ar http://download.opensuse.org/repositories/windows:/mingw/openSUSE_42.1/windows:mingw.repo
|
||||
RUN zypper --non-interactive --gpg-auto-import-keys ar http://download.opensuse.org/repositories/isv:ownCloud:toolchains:mingw:win32:2.3/openSUSE_Leap_42.1/isv:ownCloud:toolchains:mingw:win32:2.3.repo
|
||||
RUN zypper --non-interactive --gpg-auto-import-keys ar http://download.opensuse.org/repositories/isv:ownCloud:toolchains:mingw:win32:2.2/openSUSE_Leap_42.1/isv:ownCloud:toolchains:mingw:win32:2.2.repo
|
||||
RUN zypper --non-interactive --gpg-auto-import-keys install cmake make mingw32-cross-binutils mingw32-cross-cpp mingw32-cross-gcc \
|
||||
mingw32-cross-gcc-c++ mingw32-cross-pkg-config mingw32-filesystem \
|
||||
mingw32-headers mingw32-runtime site-config mingw32-libwebp \
|
||||
|
||||
@@ -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 "Установлено"
|
||||
|
||||
@@ -28,6 +28,7 @@ include(ConfigureChecks.cmake)
|
||||
|
||||
|
||||
set(SOURCE_DIR ${CMAKE_SOURCE_DIR})
|
||||
set(BIN_OUTPUT_DIRECTORY "${CMAKE_BINARY_DIR}/bin")
|
||||
|
||||
include_directories(${CMAKE_CURRENT_BINARY_DIR})
|
||||
|
||||
|
||||
@@ -207,7 +207,7 @@ __attribute__ ((packed))
|
||||
#endif
|
||||
;
|
||||
|
||||
OCSYNC_EXPORT void csync_file_stat_free(csync_file_stat_t *st);
|
||||
void csync_file_stat_free(csync_file_stat_t *st);
|
||||
|
||||
/*
|
||||
* context for the treewalk function
|
||||
|
||||
@@ -56,15 +56,17 @@ int csync_get_statedb_exists(CSYNC *ctx);
|
||||
*
|
||||
* @return 0 on success, less than 0 if an error occurred with errno set.
|
||||
*/
|
||||
OCSYNC_EXPORT int csync_statedb_load(CSYNC *ctx, const char *statedb, sqlite3 **pdb);
|
||||
int csync_statedb_load(CSYNC *ctx, const char *statedb, sqlite3 **pdb);
|
||||
|
||||
OCSYNC_EXPORT int csync_statedb_close(CSYNC *ctx);
|
||||
int csync_statedb_close(CSYNC *ctx);
|
||||
|
||||
OCSYNC_EXPORT csync_file_stat_t *csync_statedb_get_stat_by_hash(CSYNC *ctx, uint64_t phash);
|
||||
csync_file_stat_t *csync_statedb_get_stat_by_hash(CSYNC *ctx, uint64_t phash);
|
||||
|
||||
OCSYNC_EXPORT csync_file_stat_t *csync_statedb_get_stat_by_inode(CSYNC *ctx, uint64_t inode);
|
||||
csync_file_stat_t *csync_statedb_get_stat_by_inode(CSYNC *ctx, uint64_t inode);
|
||||
|
||||
OCSYNC_EXPORT csync_file_stat_t *csync_statedb_get_stat_by_file_id(CSYNC *ctx, const char *file_id);
|
||||
csync_file_stat_t *csync_statedb_get_stat_by_file_id(CSYNC *ctx, const char *file_id);
|
||||
|
||||
char *csync_statedb_get_etag(CSYNC *ctx, uint64_t jHash);
|
||||
|
||||
/**
|
||||
* @brief Query all files metadata inside and below a path.
|
||||
|
||||
+5
-10
@@ -132,16 +132,11 @@ changed and no synchronization occurs.
|
||||
In the event a file has changed on both the local and the remote repository
|
||||
since the last sync run, it can not easily be decided which version of the file
|
||||
is the one that should be used. However, changes to any side will not be lost. Instead,
|
||||
a *conflict case* is created. The client resolves this conflict by renaming the
|
||||
local file, appending a conflict label and timestamp, and saving the remote file
|
||||
under the original file name.
|
||||
|
||||
Example: Assume there is a conflict in message.txt because its contents have
|
||||
changed both locally and remotely since the last sync run. The local file with
|
||||
the local changes will be renamed to message_conflict-20160101-153110.txt and
|
||||
the remote file will be downloaded and saved as message.txt.
|
||||
|
||||
Conflict files are always created on the client and never on the server.
|
||||
a *conflict case* is created. The client resolves this conflict by creating a
|
||||
conflict file of the older of the two files and saving the newer file under the
|
||||
original file name. Conflict files are always created on the client and never
|
||||
on the server. The conflict file uses the same name as the original file, but
|
||||
is appended with the timestamp of the conflict detection.
|
||||
|
||||
|
||||
.. _ignored-files-label:
|
||||
|
||||
+8
-77
@@ -661,66 +661,6 @@ X-GNOME-Autostart-Delay=3
|
||||
# Translations
|
||||
|
||||
|
||||
# Translations
|
||||
|
||||
|
||||
# Translations
|
||||
|
||||
|
||||
# Translations
|
||||
|
||||
|
||||
# Translations
|
||||
|
||||
|
||||
# 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
|
||||
@@ -746,9 +686,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
|
||||
@@ -762,13 +700,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
|
||||
@@ -777,10 +712,6 @@ Comment[he]=@APPLICATION_NAME@ לקוח סנכון שולחן עבודה
|
||||
GenericName[he]=סנכון תיקייה
|
||||
Name[he]=@APPLICATION_NAME@ לקוח סנכרון שולחן עבודה
|
||||
Icon[he]=@APPLICATION_EXECUTABLE@
|
||||
Comment[ia]=@APPLICATION_NAME@ cliente de synchronisation pro scriptorio
|
||||
GenericName[ia]=Synchronisar Dossier
|
||||
Name[ia]=@APPLICATION_NAME@ cliente de synchronisation pro scriptorio
|
||||
Icon[ia]=@APPLICATION_EXECUTABLE@
|
||||
Comment[id]=Klien sinkronisasi desktop @APPLICATION_NAME@
|
||||
GenericName[id]=Folder Sync
|
||||
Name[id]=Klien sync desktop @APPLICATION_NAME@
|
||||
@@ -808,10 +739,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,7 @@
|
||||
# TODO: OSX and LIB_ONLY seem to require this to go to binary dir only
|
||||
if(NOT TOKEN_AUTH_ONLY)
|
||||
endif()
|
||||
set(BIN_OUTPUT_DIRECTORY "${CMAKE_BINARY_DIR}/bin")
|
||||
|
||||
set(synclib_NAME ${APPLICATION_EXECUTABLE}sync)
|
||||
|
||||
|
||||
@@ -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;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -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();
|
||||
|
||||
|
||||
@@ -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);
|
||||
|
||||
|
||||
@@ -53,6 +53,7 @@ Folder::Folder(const FolderDefinition& definition,
|
||||
, _accountState(accountState)
|
||||
, _definition(definition)
|
||||
, _csyncUnavail(false)
|
||||
, _wipeDb(false)
|
||||
, _proxyDirty(true)
|
||||
, _lastSyncDuration(0)
|
||||
, _consecutiveFailingSyncs(0)
|
||||
@@ -908,7 +909,7 @@ void Folder::slotAboutToRemoveAllFiles(SyncFileItem::Direction dir, bool *cancel
|
||||
}
|
||||
*cancel = msgBox.clickedButton() == keepBtn;
|
||||
if (*cancel) {
|
||||
journalDb()->clearFileTable();
|
||||
wipe();
|
||||
_lastEtag.clear();
|
||||
slotScheduleThisFolder();
|
||||
}
|
||||
|
||||
@@ -324,6 +324,7 @@ private:
|
||||
SyncResult _syncResult;
|
||||
QScopedPointer<SyncEngine> _engine;
|
||||
bool _csyncUnavail;
|
||||
bool _wipeDb;
|
||||
bool _proxyDirty;
|
||||
QPointer<RequestEtagJob> _requestEtagJob;
|
||||
QString _lastEtag;
|
||||
|
||||
@@ -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;
|
||||
}
|
||||
|
||||
@@ -464,7 +462,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 {
|
||||
|
||||
@@ -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"
|
||||
@@ -481,14 +480,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;
|
||||
}
|
||||
@@ -577,7 +576,7 @@ void FolderStatusModel::slotGatherPermissions(const QString &href, const QMap<QS
|
||||
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.");
|
||||
Q_ASSERT(!href.endsWith(QLatin1Char('/'))); // LsColXMLParser::parse removes the trailing slash before calling us.
|
||||
permissionMap[href] = *it;
|
||||
job->setProperty(propertyPermissionMap, permissionMap);
|
||||
}
|
||||
@@ -585,7 +584,7 @@ void FolderStatusModel::slotGatherPermissions(const QString &href, const QMap<QS
|
||||
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) {
|
||||
@@ -716,7 +715,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 +730,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();
|
||||
@@ -1136,7 +1135,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) {
|
||||
|
||||
@@ -38,8 +38,7 @@ namespace OCC {
|
||||
|
||||
GeneralSettings::GeneralSettings(QWidget *parent) :
|
||||
QWidget(parent),
|
||||
_ui(new Ui::GeneralSettings),
|
||||
_currentlyLoading(false)
|
||||
_ui(new Ui::GeneralSettings)
|
||||
{
|
||||
_ui->setupUi(this);
|
||||
|
||||
@@ -105,12 +104,7 @@ 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());
|
||||
|
||||
@@ -52,7 +52,7 @@ private:
|
||||
Ui::GeneralSettings *_ui;
|
||||
QPointer<IgnoreListEditor> _ignoreEditor;
|
||||
QPointer<SyncLogDialog> _syncLogDialog;
|
||||
bool _currentlyLoading;
|
||||
bool _currentlyLoading = false;
|
||||
};
|
||||
|
||||
|
||||
|
||||
@@ -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() );
|
||||
|
||||
@@ -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()) {
|
||||
|
||||
@@ -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})
|
||||
|
||||
@@ -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);
|
||||
}
|
||||
|
||||
|
||||
@@ -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
|
||||
@@ -17,7 +17,6 @@
|
||||
#include "configfile.h"
|
||||
#include "theme.h"
|
||||
#include "utility.h"
|
||||
#include "asserts.h"
|
||||
|
||||
#include "creds/abstractcredentials.h"
|
||||
|
||||
@@ -140,7 +139,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 +158,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 +171,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 +230,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 +241,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()
|
||||
|
||||
@@ -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,17 +13,14 @@
|
||||
*/
|
||||
|
||||
#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 "account.h"
|
||||
#include <QFileInfo>
|
||||
#include "theme.h"
|
||||
#include <cstring>
|
||||
|
||||
|
||||
@@ -247,7 +244,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)
|
||||
{
|
||||
}
|
||||
|
||||
@@ -373,7 +370,7 @@ void DiscoverySingleDirectoryJob::directoryListingIteratedSlot(QString file, con
|
||||
/* 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),
|
||||
std::replace(std::begin(file_stat->remotePerm), std::end(file_stat->remotePerm),
|
||||
'M', 'm');
|
||||
}
|
||||
|
||||
|
||||
@@ -35,12 +35,11 @@ class Account;
|
||||
*/
|
||||
|
||||
struct SyncOptions {
|
||||
SyncOptions() : _newBigFolderSizeLimit(-1), _confirmExternalStorage(false) {}
|
||||
/** Maximum size (in Bytes) a folder can have without asking for confirmation.
|
||||
* -1 means infinite */
|
||||
qint64 _newBigFolderSizeLimit;
|
||||
qint64 _newBigFolderSizeLimit = -1;
|
||||
/** If a confirmation should be asked for external storages */
|
||||
bool _confirmExternalStorage;
|
||||
bool _confirmExternalStorage = false;
|
||||
};
|
||||
|
||||
|
||||
@@ -118,7 +117,7 @@ private:
|
||||
// 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;
|
||||
bool _isExternalStorage = false;
|
||||
QPointer<LsColJob> _lsColJob;
|
||||
|
||||
public:
|
||||
|
||||
@@ -84,7 +84,7 @@ QString OWNCLOUDSYNC_EXPORT longWinPath( const QString& inpath );
|
||||
*/
|
||||
time_t OWNCLOUDSYNC_EXPORT getModTime(const QString& filename);
|
||||
|
||||
bool OWNCLOUDSYNC_EXPORT setModTime(const QString &filename, time_t modTime);
|
||||
bool setModTime(const QString &filename, time_t modTime);
|
||||
|
||||
/**
|
||||
* @brief Get the size for a file
|
||||
|
||||
@@ -25,7 +25,6 @@
|
||||
#include "configfile.h"
|
||||
#include "utility.h"
|
||||
#include "account.h"
|
||||
#include "asserts.h"
|
||||
#include <json.h>
|
||||
|
||||
#ifdef Q_OS_WIN
|
||||
@@ -639,7 +638,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) {
|
||||
@@ -655,17 +654,16 @@ 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.take();
|
||||
_firstJob.reset();
|
||||
} else {
|
||||
int i = _subJobs.indexOf(subJob);
|
||||
ASSERT(i >= 0);
|
||||
Q_ASSERT(i >= 0);
|
||||
_subJobs.remove(i);
|
||||
}
|
||||
|
||||
@@ -761,7 +759,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();
|
||||
|
||||
@@ -227,7 +227,7 @@ public:
|
||||
private slots:
|
||||
bool possiblyRunNextJob(PropagatorJob *next) {
|
||||
if (next->_state == NotYetStarted) {
|
||||
connect(next, SIGNAL(finished(SyncFileItem::Status)), this, SLOT(slotSubJobFinished(SyncFileItem::Status)));
|
||||
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(progress(const SyncFileItem &,quint64)), this, SIGNAL(progress(const SyncFileItem &,quint64)));
|
||||
connect(next, SIGNAL(ready()), this, SIGNAL(ready()));
|
||||
|
||||
+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)
|
||||
|
||||
@@ -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()
|
||||
|
||||
@@ -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()
|
||||
|
||||
@@ -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()
|
||||
|
||||
@@ -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()
|
||||
@@ -208,8 +207,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>
|
||||
@@ -376,7 +375,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 +486,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);
|
||||
|
||||
|
||||
@@ -25,7 +25,7 @@
|
||||
#include "syncengine.h"
|
||||
#include "propagateremotemove.h"
|
||||
#include "propagateremotedelete.h"
|
||||
#include "asserts.h"
|
||||
|
||||
|
||||
#include <QNetworkAccessManager>
|
||||
#include <QFileInfo>
|
||||
@@ -188,7 +188,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 +220,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 +270,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 +343,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 +391,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
|
||||
|
||||
@@ -25,7 +25,6 @@
|
||||
#include "checksums.h"
|
||||
#include "syncengine.h"
|
||||
#include "propagateremotedelete.h"
|
||||
#include "asserts.h"
|
||||
|
||||
#include <json.h>
|
||||
#include <QNetworkAccessManager>
|
||||
@@ -172,8 +171,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"
|
||||
|
||||
@@ -24,7 +24,6 @@
|
||||
#include "csync_private.h"
|
||||
#include "filesystem.h"
|
||||
#include "propagateremotedelete.h"
|
||||
#include "asserts.h"
|
||||
|
||||
#ifdef Q_OS_WIN
|
||||
#include <windows.h>
|
||||
@@ -84,7 +83,7 @@ SyncEngine::SyncEngine(AccountPtr account, const QString& localPath,
|
||||
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());
|
||||
|
||||
@@ -354,7 +353,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 +389,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;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -502,7 +499,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 */
|
||||
}
|
||||
|
||||
@@ -712,11 +709,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;
|
||||
@@ -898,7 +892,6 @@ void SyncEngine::slotDiscoveryJobFinished(int discoveryResult)
|
||||
_backInTimeFiles = 0;
|
||||
bool walkOk = true;
|
||||
_remotePerms.clear();
|
||||
_remotePerms.reserve(c_rbtree_size(_csync_ctx->remote.tree));
|
||||
_seenFiles.clear();
|
||||
_temporarilyUnavailablePaths.clear();
|
||||
_renamedFolders.clear();
|
||||
|
||||
@@ -17,7 +17,6 @@
|
||||
#include "syncengine.h"
|
||||
#include "syncjournaldb.h"
|
||||
#include "syncjournalfilerecord.h"
|
||||
#include "asserts.h"
|
||||
|
||||
namespace OCC {
|
||||
|
||||
@@ -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);
|
||||
@@ -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);
|
||||
|
||||
|
||||
@@ -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;
|
||||
}
|
||||
@@ -1608,7 +1607,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() ) {
|
||||
@@ -1836,17 +1835,6 @@ void SyncJournalDb::setDataFingerprint(const QByteArray &dataFingerprint)
|
||||
}
|
||||
}
|
||||
|
||||
void SyncJournalDb::clearFileTable()
|
||||
{
|
||||
SqlQuery query(_db);
|
||||
query.prepare("DELETE FROM metadata;");
|
||||
if (!query.exec()) {
|
||||
qWarning() << "SQL error in clearFileTable" << query.error();
|
||||
} else {
|
||||
qDebug() << query.lastQuery() << "(" << query.numRowsAffected() << " rows)";
|
||||
}
|
||||
}
|
||||
|
||||
void SyncJournalDb::commit(const QString& context, bool startTrans)
|
||||
{
|
||||
QMutexLocker lock(&_mutex);
|
||||
|
||||
@@ -173,13 +173,6 @@ public:
|
||||
void setDataFingerprint(const QByteArray &dataFingerprint);
|
||||
QByteArray dataFingerprint();
|
||||
|
||||
/**
|
||||
* Delete any file entry. This will force the next sync to re-sync everything as if it was new,
|
||||
* restoring everyfile on every remote. If a file is there both on the client and server side,
|
||||
* it will be a conflict that will be automatically resolved if the file is the same.
|
||||
*/
|
||||
void clearFileTable();
|
||||
|
||||
private:
|
||||
bool updateDatabaseStructure();
|
||||
bool updateMetadataTableStructure();
|
||||
|
||||
@@ -273,13 +273,14 @@ void Utility::usleep(int usec)
|
||||
|
||||
bool Utility::fsCasePreserving()
|
||||
{
|
||||
#ifndef WITH_TESTING
|
||||
QByteArray env = qgetenv("OWNCLOUD_TEST_CASE_PRESERVING");
|
||||
if (!env.isEmpty())
|
||||
return env.toInt();
|
||||
#endif
|
||||
|
||||
return isWindows() || isMac();
|
||||
bool re = false;
|
||||
if( isWindows() || isMac() ) {
|
||||
re = true;
|
||||
} else {
|
||||
bool isTest = qgetenv("OWNCLOUD_TEST_CASE_PRESERVING").toInt();
|
||||
re = isTest;
|
||||
}
|
||||
return re;
|
||||
}
|
||||
|
||||
bool Utility::fileNamesEqual( const QString& fn1, const QString& fn2)
|
||||
|
||||
+15
-9
@@ -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()
|
||||
@@ -9,6 +10,7 @@ setup_qt()
|
||||
include(owncloud_add_test.cmake)
|
||||
|
||||
owncloud_add_test(OwncloudPropagator "")
|
||||
owncloud_add_test(Utility "")
|
||||
owncloud_add_test(Updater "")
|
||||
|
||||
SET(FolderWatcher_SRC ../src/gui/folderwatcher.cpp)
|
||||
@@ -23,30 +25,31 @@ IF( APPLE )
|
||||
list(APPEND FolderWatcher_SRC ../src/gui/folderwatcher_mac.cpp)
|
||||
list(APPEND FolderWatcher_SRC ../src/gui/socketapisocket_mac.mm)
|
||||
ENDIF()
|
||||
|
||||
owncloud_add_test(FolderWatcher "${FolderWatcher_SRC}")
|
||||
if( UNIX AND NOT APPLE )
|
||||
if(HAVE_QT5 AND NOT BUILD_WITH_QT4)
|
||||
owncloud_add_test(InotifyWatcher "${FolderWatcher_SRC}")
|
||||
endif(HAVE_QT5 AND NOT BUILD_WITH_QT4)
|
||||
endif(UNIX AND NOT APPLE)
|
||||
|
||||
owncloud_add_test(CSyncSqlite "")
|
||||
owncloud_add_test(NetrcParser ../src/cmd/netrcparser.cpp)
|
||||
owncloud_add_test(OwnSql "")
|
||||
owncloud_add_test(SyncJournalDB "")
|
||||
owncloud_add_test(SyncFileItem "")
|
||||
owncloud_add_test(ConcatUrl "")
|
||||
|
||||
owncloud_add_test(XmlParse "")
|
||||
owncloud_add_test(FileSystem "")
|
||||
owncloud_add_test(ChecksumValidator "")
|
||||
|
||||
owncloud_add_test(ExcludedFiles "")
|
||||
if(HAVE_QT5 AND NOT BUILD_WITH_QT4)
|
||||
owncloud_add_test(FileSystem "")
|
||||
owncloud_add_test(Utility "")
|
||||
owncloud_add_test(SyncEngine "syncenginetestutils.h")
|
||||
owncloud_add_test(SyncFileStatusTracker "syncenginetestutils.h")
|
||||
owncloud_add_test(ChunkingNg "syncenginetestutils.h")
|
||||
owncloud_add_test(UploadReset "syncenginetestutils.h")
|
||||
owncloud_add_test(AllFilesDeleted "syncenginetestutils.h")
|
||||
owncloud_add_test(FolderWatcher "${FolderWatcher_SRC}")
|
||||
|
||||
if( UNIX AND NOT APPLE )
|
||||
owncloud_add_test(InotifyWatcher "${FolderWatcher_SRC}")
|
||||
endif(UNIX AND NOT APPLE)
|
||||
|
||||
owncloud_add_benchmark(LargeSync "syncenginetestutils.h")
|
||||
endif(HAVE_QT5 AND NOT BUILD_WITH_QT4)
|
||||
|
||||
@@ -58,5 +61,8 @@ list(APPEND FolderMan_SRC ../src/gui/syncrunfilelog.cpp )
|
||||
list(APPEND FolderMan_SRC ../src/gui/lockwatcher.cpp )
|
||||
list(APPEND FolderMan_SRC ${FolderWatcher_SRC})
|
||||
list(APPEND FolderMan_SRC stub.cpp )
|
||||
#include_directories(${QTKEYCHAIN_INCLUDE_DIR})
|
||||
#include_directories(${CMAKE_BINARY_DIR}/src/gui)
|
||||
#include_directories(${CMAKE_SOURCE_DIR}/src/3rdparty/qjson)
|
||||
owncloud_add_test(FolderMan "${FolderMan_SRC}")
|
||||
|
||||
|
||||
@@ -12,7 +12,6 @@ macro(owncloud_add_test test_class additional_cpp)
|
||||
|
||||
add_executable(${OWNCLOUD_TEST_CLASS}Test test${OWNCLOUD_TEST_CLASS_LOWERCASE}.cpp ${additional_cpp})
|
||||
qt5_use_modules(${OWNCLOUD_TEST_CLASS}Test Test Sql Xml Network)
|
||||
set_target_properties(${OWNCLOUD_TEST_CLASS}Test PROPERTIES RUNTIME_OUTPUT_DIRECTORY ${BIN_OUTPUT_DIRECTORY})
|
||||
|
||||
target_link_libraries(${OWNCLOUD_TEST_CLASS}Test
|
||||
updater
|
||||
@@ -41,7 +40,6 @@ macro(owncloud_add_benchmark test_class additional_cpp)
|
||||
|
||||
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)
|
||||
set_target_properties(${OWNCLOUD_TEST_CLASS}Bench PROPERTIES RUNTIME_OUTPUT_DIRECTORY ${BIN_OUTPUT_DIRECTORY})
|
||||
|
||||
target_link_libraries(${OWNCLOUD_TEST_CLASS}Bench
|
||||
updater
|
||||
|
||||
@@ -226,7 +226,7 @@ public:
|
||||
etag = file->etag;
|
||||
return file;
|
||||
}
|
||||
return 0;
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
FileInfo *createDir(const QString &relativePath) {
|
||||
@@ -345,7 +345,7 @@ public:
|
||||
} else
|
||||
xml.writeEmptyElement(davUri, QStringLiteral("resourcetype"));
|
||||
|
||||
auto gmtDate = fileInfo.lastModified.toTimeZone(QTimeZone(0));
|
||||
auto gmtDate = fileInfo.lastModified.toTimeZone(QTimeZone("GMT"));
|
||||
auto stringDate = gmtDate.toString("ddd, dd MMM yyyy HH:mm:ss 'GMT'");
|
||||
xml.writeTextElement(davUri, QStringLiteral("getlastmodified"), stringDate);
|
||||
xml.writeTextElement(davUri, QStringLiteral("getcontentlength"), QString::number(fileInfo.size));
|
||||
|
||||
@@ -1,118 +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 <QtTest>
|
||||
#include "syncenginetestutils.h"
|
||||
#include <syncengine.h>
|
||||
|
||||
using namespace OCC;
|
||||
|
||||
/*
|
||||
* This test ensure that the SyncEngine::aboutToRemoveAllFiles is correctly called and that when
|
||||
* we the user choose to remove all files SyncJournalDb::clearFileTable makes works as expected
|
||||
*/
|
||||
class TestAllFilesDeleted : public QObject
|
||||
{
|
||||
Q_OBJECT
|
||||
|
||||
private slots:
|
||||
|
||||
void testAllFilesDeletedKeep_data()
|
||||
{
|
||||
QTest::addColumn<bool>("deleteOnRemote");
|
||||
QTest::newRow("local") << false;
|
||||
QTest::newRow("remote") << true;
|
||||
|
||||
}
|
||||
|
||||
/*
|
||||
* In this test, all files are deleted in the client, or the server, and we simulate
|
||||
* that the users press "keep"
|
||||
*/
|
||||
void testAllFilesDeletedKeep()
|
||||
{
|
||||
QFETCH(bool, deleteOnRemote);
|
||||
FakeFolder fakeFolder{FileInfo::A12_B12_C12_S12()};
|
||||
|
||||
//Just set a blacklist so we can check it is still there. This directory does not exists but
|
||||
// that does not matter for our purposes.
|
||||
QStringList selectiveSyncBlackList = { "Q/" };
|
||||
fakeFolder.syncEngine().journal()->setSelectiveSyncList(SyncJournalDb::SelectiveSyncBlackList,
|
||||
selectiveSyncBlackList);
|
||||
|
||||
auto initialState = fakeFolder.currentLocalState();
|
||||
int aboutToRemoveAllFilesCalled = 0;
|
||||
QObject::connect(&fakeFolder.syncEngine(), &SyncEngine::aboutToRemoveAllFiles,
|
||||
[&](SyncFileItem::Direction dir, bool *cancel) {
|
||||
QCOMPARE(aboutToRemoveAllFilesCalled, 0);
|
||||
aboutToRemoveAllFilesCalled++;
|
||||
QCOMPARE(dir, deleteOnRemote ? SyncFileItem::Down : SyncFileItem::Up);
|
||||
*cancel = true;
|
||||
fakeFolder.syncEngine().journal()->clearFileTable(); // That's what Folder is doing
|
||||
});
|
||||
|
||||
auto &modifier = deleteOnRemote ? fakeFolder.remoteModifier() : fakeFolder.localModifier();
|
||||
for (const auto &s : fakeFolder.currentRemoteState().children.keys())
|
||||
modifier.remove(s);
|
||||
|
||||
QVERIFY(!fakeFolder.syncOnce()); // Should fail because we cancel the sync
|
||||
QCOMPARE(aboutToRemoveAllFilesCalled, 1);
|
||||
|
||||
// Next sync should recover all files
|
||||
QVERIFY(fakeFolder.syncOnce());
|
||||
QCOMPARE(fakeFolder.currentLocalState(), initialState);
|
||||
QCOMPARE(fakeFolder.currentRemoteState(), initialState);
|
||||
|
||||
// The selective sync blacklist should be not have been deleted.
|
||||
bool ok = true;
|
||||
QCOMPARE(fakeFolder.syncEngine().journal()->getSelectiveSyncList(SyncJournalDb::SelectiveSyncBlackList, &ok),
|
||||
selectiveSyncBlackList);
|
||||
}
|
||||
|
||||
void testAllFilesDeletedDelete_data()
|
||||
{
|
||||
testAllFilesDeletedKeep_data();
|
||||
}
|
||||
|
||||
/*
|
||||
* This test is like the previous one but we simulate that the user presses "delete"
|
||||
*/
|
||||
void testAllFilesDeletedDelete()
|
||||
{
|
||||
QFETCH(bool, deleteOnRemote);
|
||||
FakeFolder fakeFolder{FileInfo::A12_B12_C12_S12()};
|
||||
|
||||
int aboutToRemoveAllFilesCalled = 0;
|
||||
QObject::connect(&fakeFolder.syncEngine(), &SyncEngine::aboutToRemoveAllFiles,
|
||||
[&](SyncFileItem::Direction dir, bool *cancel) {
|
||||
QCOMPARE(aboutToRemoveAllFilesCalled, 0);
|
||||
aboutToRemoveAllFilesCalled++;
|
||||
QCOMPARE(dir, deleteOnRemote ? SyncFileItem::Down : SyncFileItem::Up);
|
||||
*cancel = false;
|
||||
});
|
||||
|
||||
auto &modifier = deleteOnRemote ? fakeFolder.remoteModifier() : fakeFolder.localModifier();
|
||||
for (const auto &s : fakeFolder.currentRemoteState().children.keys())
|
||||
modifier.remove(s);
|
||||
|
||||
QVERIFY(fakeFolder.syncOnce()); // Should succeed, and all files must then be deleted
|
||||
|
||||
QCOMPARE(fakeFolder.currentLocalState(), fakeFolder.currentRemoteState());
|
||||
QCOMPARE(fakeFolder.currentLocalState().children.count(), 0);
|
||||
|
||||
// Try another sync to be sure.
|
||||
|
||||
QVERIFY(fakeFolder.syncOnce()); // Should succeed (doing nothing)
|
||||
QCOMPARE(aboutToRemoveAllFilesCalled, 1); // should not have been called.
|
||||
|
||||
QCOMPARE(fakeFolder.currentLocalState(), fakeFolder.currentRemoteState());
|
||||
QCOMPARE(fakeFolder.currentLocalState().children.count(), 0);
|
||||
}
|
||||
};
|
||||
|
||||
QTEST_GUILESS_MAIN(TestAllFilesDeleted)
|
||||
#include "testallfilesdeleted.moc"
|
||||
@@ -55,6 +55,7 @@ using namespace OCC;
|
||||
private slots:
|
||||
|
||||
void initTestCase() {
|
||||
qDebug() << Q_FUNC_INFO;
|
||||
_root = QDir::tempPath() + "/" + "test_" + QString::number(qrand());
|
||||
QDir rootDir(_root);
|
||||
|
||||
@@ -64,9 +65,7 @@ using namespace OCC;
|
||||
}
|
||||
|
||||
void testUploadChecksummingAdler() {
|
||||
#ifndef ZLIB_FOUND
|
||||
QSKIP("ZLIB not found.", SkipSingle);
|
||||
#else
|
||||
|
||||
ComputeChecksum *vali = new ComputeChecksum(this);
|
||||
_expectedType = "Adler32";
|
||||
vali->setChecksumType(_expectedType);
|
||||
@@ -82,7 +81,6 @@ using namespace OCC;
|
||||
loop.exec();
|
||||
|
||||
delete vali;
|
||||
#endif
|
||||
}
|
||||
|
||||
void testUploadChecksummingMd5() {
|
||||
@@ -121,9 +119,7 @@ using namespace OCC;
|
||||
}
|
||||
|
||||
void testDownloadChecksummingAdler() {
|
||||
#ifndef ZLIB_FOUND
|
||||
QSKIP("ZLIB not found.", SkipSingle);
|
||||
#else
|
||||
|
||||
QByteArray adler = checkSumAdlerC;
|
||||
adler.append(":");
|
||||
adler.append(FileSystem::calcAdler32( _testfile ));
|
||||
@@ -147,7 +143,6 @@ using namespace OCC;
|
||||
QTRY_VERIFY(_errorSeen);
|
||||
|
||||
delete vali;
|
||||
#endif
|
||||
}
|
||||
|
||||
|
||||
|
||||
@@ -11,7 +11,9 @@
|
||||
|
||||
using namespace OCC;
|
||||
|
||||
#define EXCLUDE_LIST_FILE SOURCEDIR"/../sync-exclude.lst"
|
||||
#define STR_(X) #X
|
||||
#define STR(X) STR_(X)
|
||||
#define BIN_PATH STR(OWNCLOUD_BIN_PATH)
|
||||
|
||||
class TestExcludedFiles: public QObject
|
||||
{
|
||||
@@ -29,7 +31,9 @@ private slots:
|
||||
QVERIFY(!excluded.isExcluded("/a/.b", "/a", keepHidden));
|
||||
QVERIFY(excluded.isExcluded("/a/.b", "/a", excludeHidden));
|
||||
|
||||
excluded.addExcludeFilePath(EXCLUDE_LIST_FILE);
|
||||
QString path(BIN_PATH);
|
||||
path.append("/sync-exclude.lst");
|
||||
excluded.addExcludeFilePath(path);
|
||||
excluded.reloadExcludes();
|
||||
|
||||
QVERIFY(!excluded.isExcluded("/a/b", "/a", keepHidden));
|
||||
|
||||
+38
-23
@@ -17,7 +17,7 @@ class TestFileSystem : public QObject
|
||||
{
|
||||
Q_OBJECT
|
||||
|
||||
QTemporaryDir _root;
|
||||
QString _root;
|
||||
|
||||
|
||||
QByteArray shellSum( const QByteArray& cmd, const QString& file )
|
||||
@@ -38,36 +38,51 @@ class TestFileSystem : public QObject
|
||||
}
|
||||
|
||||
private slots:
|
||||
void initTestCase() {
|
||||
qsrand(QTime::currentTime().msec());
|
||||
|
||||
QString subdir("test_"+QString::number(qrand()));
|
||||
_root = QDir::tempPath() + "/" + subdir;
|
||||
|
||||
QDir dir("/tmp");
|
||||
dir.mkdir(subdir);
|
||||
qDebug() << "creating test directory " << _root;
|
||||
}
|
||||
|
||||
void cleanupTestCase()
|
||||
{
|
||||
if( !_root.isEmpty() )
|
||||
system(QString("rm -rf "+_root).toUtf8());
|
||||
}
|
||||
|
||||
void testMd5Calc()
|
||||
{
|
||||
QString file( _root.path() + "/file_a.bin");
|
||||
QVERIFY(writeRandomFile(file));
|
||||
QFileInfo fi(file);
|
||||
QVERIFY(fi.exists());
|
||||
QByteArray sum = calcMd5(file);
|
||||
QString file( _root+"/file_a.bin");
|
||||
writeRandomFile(file);
|
||||
QFileInfo fi(file);
|
||||
QVERIFY(fi.exists());
|
||||
QByteArray sum = calcMd5(file);
|
||||
|
||||
QByteArray sSum = shellSum("md5sum", file);
|
||||
if (sSum.isEmpty())
|
||||
QSKIP("Couldn't execute md5sum to calculate checksum, executable missing?", SkipSingle);
|
||||
|
||||
QVERIFY(!sum.isEmpty());
|
||||
QCOMPARE(sSum, sum);
|
||||
QByteArray sSum = shellSum("/usr/bin/md5sum", file);
|
||||
qDebug() << "calculated" << sum << "versus md5sum:"<< sSum;
|
||||
QVERIFY(!sSum.isEmpty());
|
||||
QVERIFY(!sum.isEmpty());
|
||||
QVERIFY(sSum == sum );
|
||||
}
|
||||
|
||||
void testSha1Calc()
|
||||
{
|
||||
QString file( _root.path() + "/file_b.bin");
|
||||
writeRandomFile(file);
|
||||
QFileInfo fi(file);
|
||||
QVERIFY(fi.exists());
|
||||
QByteArray sum = calcSha1(file);
|
||||
QString file( _root+"/file_b.bin");
|
||||
writeRandomFile(file);
|
||||
QFileInfo fi(file);
|
||||
QVERIFY(fi.exists());
|
||||
QByteArray sum = calcSha1(file);
|
||||
|
||||
QByteArray sSum = shellSum("sha1sum", file);
|
||||
if (sSum.isEmpty())
|
||||
QSKIP("Couldn't execute sha1sum to calculate checksum, executable missing?", SkipSingle);
|
||||
|
||||
QVERIFY(!sum.isEmpty());
|
||||
QCOMPARE(sSum, sum);
|
||||
QByteArray sSum = shellSum("/usr/bin/sha1sum", file);
|
||||
qDebug() << "calculated" << sum << "versus sha1sum:"<< sSum;
|
||||
QVERIFY(!sSum.isEmpty());
|
||||
QVERIFY(!sum.isEmpty());
|
||||
QVERIFY(sSum == sum );
|
||||
}
|
||||
|
||||
};
|
||||
|
||||
+32
-33
@@ -63,7 +63,6 @@ private slots:
|
||||
f.open(QFile::WriteOnly);
|
||||
f.write("hello");
|
||||
}
|
||||
QString dirPath = dir2.canonicalPath();
|
||||
|
||||
AccountPtr account = Account::create();
|
||||
QUrl url("http://example.de");
|
||||
@@ -74,22 +73,22 @@ private slots:
|
||||
AccountStatePtr newAccountState(new AccountState(account));
|
||||
FolderMan *folderman = FolderMan::instance();
|
||||
QCOMPARE(folderman, &_fm);
|
||||
QVERIFY(folderman->addFolder(newAccountState.data(), folderDefinition(dirPath + "/sub/ownCloud1")));
|
||||
QVERIFY(folderman->addFolder(newAccountState.data(), folderDefinition(dirPath + "/ownCloud2")));
|
||||
QVERIFY(folderman->addFolder(newAccountState.data(), folderDefinition(dir.path() + "/sub/ownCloud1")));
|
||||
QVERIFY(folderman->addFolder(newAccountState.data(), folderDefinition(dir.path() + "/ownCloud2")));
|
||||
|
||||
|
||||
// those should be allowed
|
||||
// QString FolderMan::checkPathValidityForNewFolder(const QString& path, const QUrl &serverUrl, bool forNewDirectory)
|
||||
|
||||
QCOMPARE(folderman->checkPathValidityForNewFolder(dirPath + "/sub/free"), QString());
|
||||
QCOMPARE(folderman->checkPathValidityForNewFolder(dirPath + "/free2/"), QString());
|
||||
QCOMPARE(folderman->checkPathValidityForNewFolder(dir.path() + "/sub/free"), QString());
|
||||
QCOMPARE(folderman->checkPathValidityForNewFolder(dir.path() + "/free2/"), QString());
|
||||
// Not an existing directory -> Ok
|
||||
QCOMPARE(folderman->checkPathValidityForNewFolder(dirPath + "/sub/bliblablu"), QString());
|
||||
QCOMPARE(folderman->checkPathValidityForNewFolder(dirPath + "/sub/free/bliblablu"), QString());
|
||||
// QCOMPARE(folderman->checkPathValidityForNewFolder(dirPath + "/sub/bliblablu/some/more"), QString());
|
||||
QCOMPARE(folderman->checkPathValidityForNewFolder(dir.path() + "/sub/bliblablu"), QString());
|
||||
QCOMPARE(folderman->checkPathValidityForNewFolder(dir.path() + "/sub/free/bliblablu"), QString());
|
||||
QCOMPARE(folderman->checkPathValidityForNewFolder(dir.path() + "/sub/bliblablu/some/more"), QString());
|
||||
|
||||
// A file -> Error
|
||||
QVERIFY(!folderman->checkPathValidityForNewFolder(dirPath + "/sub/file.txt").isNull());
|
||||
QVERIFY(!folderman->checkPathValidityForNewFolder(dir.path() + "/sub/file.txt").isNull());
|
||||
|
||||
// There are folders configured in those folders, url needs to be taken into account: -> ERROR
|
||||
QUrl url2(url);
|
||||
@@ -97,51 +96,51 @@ private slots:
|
||||
url2.setUserName(user);
|
||||
|
||||
// The following both fail because they refer to the same account (user and url)
|
||||
QVERIFY(!folderman->checkPathValidityForNewFolder(dirPath + "/sub/ownCloud1", url2).isNull());
|
||||
QVERIFY(!folderman->checkPathValidityForNewFolder(dirPath + "/ownCloud2/", url2).isNull());
|
||||
QVERIFY(!folderman->checkPathValidityForNewFolder(dir.path() + "/sub/ownCloud1", url2).isNull());
|
||||
QVERIFY(!folderman->checkPathValidityForNewFolder(dir.path() + "/ownCloud2/", url2).isNull());
|
||||
|
||||
// Now it will work because the account is different
|
||||
QUrl url3("http://anotherexample.org");
|
||||
url3.setUserName("dummy");
|
||||
QCOMPARE(folderman->checkPathValidityForNewFolder(dirPath + "/sub/ownCloud1", url3), QString());
|
||||
QCOMPARE(folderman->checkPathValidityForNewFolder(dirPath + "/ownCloud2/", url3), QString());
|
||||
QCOMPARE(folderman->checkPathValidityForNewFolder(dir.path() + "/sub/ownCloud1", url3), QString());
|
||||
QCOMPARE(folderman->checkPathValidityForNewFolder(dir.path() + "/ownCloud2/", url3), QString());
|
||||
|
||||
QVERIFY(!folderman->checkPathValidityForNewFolder(dirPath).isNull());
|
||||
QVERIFY(!folderman->checkPathValidityForNewFolder(dirPath + "/sub/ownCloud1/folder").isNull());
|
||||
QVERIFY(!folderman->checkPathValidityForNewFolder(dirPath + "/sub/ownCloud1/folder/f").isNull());
|
||||
QVERIFY(!folderman->checkPathValidityForNewFolder(dir.path()).isNull());
|
||||
QVERIFY(!folderman->checkPathValidityForNewFolder(dir.path() + "/sub/ownCloud1/folder").isNull());
|
||||
QVERIFY(!folderman->checkPathValidityForNewFolder(dir.path() + "/sub/ownCloud1/folder/f").isNull());
|
||||
|
||||
|
||||
// make a bunch of links
|
||||
QVERIFY(QFile::link(dirPath + "/sub/free", dirPath + "/link1"));
|
||||
QVERIFY(QFile::link(dirPath + "/sub", dirPath + "/link2"));
|
||||
QVERIFY(QFile::link(dirPath + "/sub/ownCloud1", dirPath + "/link3"));
|
||||
QVERIFY(QFile::link(dirPath + "/sub/ownCloud1/folder", dirPath + "/link4"));
|
||||
QVERIFY(QFile::link(dir.path() + "/sub/free", dir.path() + "/link1"));
|
||||
QVERIFY(QFile::link(dir.path() + "/sub", dir.path() + "/link2"));
|
||||
QVERIFY(QFile::link(dir.path() + "/sub/ownCloud1", dir.path() + "/link3"));
|
||||
QVERIFY(QFile::link(dir.path() + "/sub/ownCloud1/folder", dir.path() + "/link4"));
|
||||
|
||||
// Ok
|
||||
QVERIFY(folderman->checkPathValidityForNewFolder(dirPath + "/link1").isNull());
|
||||
QVERIFY(folderman->checkPathValidityForNewFolder(dirPath + "/link2/free").isNull());
|
||||
QVERIFY(folderman->checkPathValidityForNewFolder(dir.path() + "/link1").isNull());
|
||||
QVERIFY(folderman->checkPathValidityForNewFolder(dir.path() + "/link2/free").isNull());
|
||||
|
||||
// Not Ok
|
||||
QVERIFY(!folderman->checkPathValidityForNewFolder(dirPath + "/link2").isNull());
|
||||
QVERIFY(!folderman->checkPathValidityForNewFolder(dir.path() + "/link2").isNull());
|
||||
|
||||
// link 3 points to an existing sync folder. To make it fail, the account must be the same
|
||||
QVERIFY(!folderman->checkPathValidityForNewFolder(dirPath + "/link3", url2).isNull());
|
||||
QVERIFY(!folderman->checkPathValidityForNewFolder(dir.path() + "/link3", url2).isNull());
|
||||
// while with a different account, this is fine
|
||||
QCOMPARE(folderman->checkPathValidityForNewFolder(dirPath + "/link3", url3), QString());
|
||||
QCOMPARE(folderman->checkPathValidityForNewFolder(dir.path() + "/link3", url3), QString());
|
||||
|
||||
QVERIFY(!folderman->checkPathValidityForNewFolder(dirPath + "/link4").isNull());
|
||||
QVERIFY(!folderman->checkPathValidityForNewFolder(dirPath + "/link3/folder").isNull());
|
||||
QVERIFY(!folderman->checkPathValidityForNewFolder(dir.path() + "/link4").isNull());
|
||||
QVERIFY(!folderman->checkPathValidityForNewFolder(dir.path() + "/link3/folder").isNull());
|
||||
|
||||
|
||||
// test some non existing sub path (error)
|
||||
QVERIFY(!folderman->checkPathValidityForNewFolder(dirPath + "/sub/ownCloud1/some/sub/path").isNull());
|
||||
QVERIFY(!folderman->checkPathValidityForNewFolder(dirPath + "/ownCloud2/blublu").isNull());
|
||||
QVERIFY(!folderman->checkPathValidityForNewFolder(dirPath + "/sub/ownCloud1/folder/g/h").isNull());
|
||||
QVERIFY(!folderman->checkPathValidityForNewFolder(dirPath + "/link3/folder/neu_folder").isNull());
|
||||
QVERIFY(!folderman->checkPathValidityForNewFolder(dir.path() + "/sub/ownCloud1/some/sub/path").isNull());
|
||||
QVERIFY(!folderman->checkPathValidityForNewFolder(dir.path() + "/ownCloud2/blublu").isNull());
|
||||
QVERIFY(!folderman->checkPathValidityForNewFolder(dir.path() + "/sub/ownCloud1/folder/g/h").isNull());
|
||||
QVERIFY(!folderman->checkPathValidityForNewFolder(dir.path() + "/link3/folder/neu_folder").isNull());
|
||||
|
||||
// Subfolder of links
|
||||
QVERIFY(folderman->checkPathValidityForNewFolder(dirPath + "/link1/subfolder").isNull());
|
||||
QVERIFY(folderman->checkPathValidityForNewFolder(dirPath + "/link2/free/subfolder").isNull());
|
||||
QVERIFY(folderman->checkPathValidityForNewFolder(dir.path() + "/link1/subfolder").isNull());
|
||||
QVERIFY(folderman->checkPathValidityForNewFolder(dir.path() + "/link2/free/subfolder").isNull());
|
||||
|
||||
// Invalid paths
|
||||
QVERIFY(!folderman->checkPathValidityForNewFolder("").isNull());
|
||||
|
||||
+114
-121
@@ -10,181 +10,174 @@
|
||||
#include "folderwatcher.h"
|
||||
#include "utility.h"
|
||||
|
||||
void touch(const QString &file)
|
||||
{
|
||||
#ifdef Q_OS_WIN
|
||||
OCC::Utility::writeRandomFile(file);
|
||||
#else
|
||||
QString cmd;
|
||||
cmd = QString("touch %1").arg(file);
|
||||
qDebug() << "Command: " << cmd;
|
||||
system(cmd.toLocal8Bit());
|
||||
#endif
|
||||
}
|
||||
|
||||
void mkdir(const QString &file)
|
||||
{
|
||||
#ifdef Q_OS_WIN
|
||||
QDir dir;
|
||||
dir.mkdir(file);
|
||||
#else
|
||||
QString cmd = QString("mkdir %1").arg(file);
|
||||
qDebug() << "Command: " << cmd;
|
||||
system(cmd.toLocal8Bit());
|
||||
#endif
|
||||
}
|
||||
|
||||
void rmdir(const QString &file)
|
||||
{
|
||||
#ifdef Q_OS_WIN
|
||||
QDir dir;
|
||||
dir.rmdir(file);
|
||||
#else
|
||||
QString cmd = QString("rmdir %1").arg(file);
|
||||
qDebug() << "Command: " << cmd;
|
||||
system(cmd.toLocal8Bit());
|
||||
#endif
|
||||
}
|
||||
|
||||
void rm(const QString &file)
|
||||
{
|
||||
#ifdef Q_OS_WIN
|
||||
QFile::remove(file);
|
||||
#else
|
||||
QString cmd = QString("rm %1").arg(file);
|
||||
qDebug() << "Command: " << cmd;
|
||||
system(cmd.toLocal8Bit());
|
||||
#endif
|
||||
}
|
||||
|
||||
void mv(const QString &file1, const QString &file2)
|
||||
{
|
||||
#ifdef Q_OS_WIN
|
||||
QFile::rename(file1, file2);
|
||||
#else
|
||||
QString cmd = QString("mv %1 %2").arg(file1, file2);
|
||||
qDebug() << "Command: " << cmd;
|
||||
system(cmd.toLocal8Bit());
|
||||
#endif
|
||||
}
|
||||
|
||||
using namespace OCC;
|
||||
|
||||
class TestFolderWatcher : public QObject
|
||||
{
|
||||
Q_OBJECT
|
||||
|
||||
QTemporaryDir _root;
|
||||
QString _rootPath;
|
||||
QScopedPointer<FolderWatcher> _watcher;
|
||||
QScopedPointer<QSignalSpy> _pathChangedSpy;
|
||||
|
||||
bool waitForPathChanged(const QString &path)
|
||||
{
|
||||
QElapsedTimer t;
|
||||
t.start();
|
||||
while (t.elapsed() < 5000) {
|
||||
// Check if it was already reported as changed by the watcher
|
||||
for (int i = 0; i < _pathChangedSpy->size(); ++i) {
|
||||
const auto &args = _pathChangedSpy->at(i);
|
||||
if (args.first().toString() == path)
|
||||
return true;
|
||||
}
|
||||
// Wait a bit and test again (don't bother checking if we timed out or not)
|
||||
_pathChangedSpy->wait(200);
|
||||
public slots:
|
||||
void slotFolderChanged( const QString& path ) {
|
||||
if (_skipNotifications.contains(path)) {
|
||||
return;
|
||||
}
|
||||
if (_requiredNotifications.contains(path)) {
|
||||
_receivedNotifications.insert(path);
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
public:
|
||||
TestFolderWatcher() {
|
||||
qsrand(QTime::currentTime().msec());
|
||||
QDir rootDir(_root.path());
|
||||
_rootPath = rootDir.canonicalPath();
|
||||
qDebug() << "creating test directory tree in " << _rootPath;
|
||||
void slotEnd() { // in case something goes wrong...
|
||||
_loop.quit();
|
||||
QVERIFY2(1 == 0, "Loop hang!");
|
||||
}
|
||||
|
||||
rootDir.mkpath("a1/b1/c1");
|
||||
rootDir.mkpath("a1/b1/c2");
|
||||
rootDir.mkpath("a1/b2/c1");
|
||||
rootDir.mkpath("a1/b3/c3");
|
||||
rootDir.mkpath("a2/b3/c3");
|
||||
Utility::writeRandomFile( _rootPath+"/a1/random.bin");
|
||||
Utility::writeRandomFile( _rootPath+"/a1/b2/todelete.bin");
|
||||
Utility::writeRandomFile( _rootPath+"/a2/renamefile");
|
||||
Utility::writeRandomFile( _rootPath+"/a1/movefile");
|
||||
private:
|
||||
QString _root;
|
||||
FolderWatcher *_watcher;
|
||||
QEventLoop _loop;
|
||||
QTimer _timer;
|
||||
QSet<QString> _requiredNotifications;
|
||||
QSet<QString> _receivedNotifications;
|
||||
QSet<QString> _skipNotifications;
|
||||
|
||||
_watcher.reset(new FolderWatcher(_rootPath));
|
||||
_pathChangedSpy.reset(new QSignalSpy(_watcher.data(), SIGNAL(pathChanged(QString))));
|
||||
void processAndWait()
|
||||
{
|
||||
_loop.processEvents();
|
||||
Utility::usleep(200000);
|
||||
_loop.processEvents();
|
||||
}
|
||||
|
||||
private slots:
|
||||
void initTestCase() {
|
||||
qsrand(QTime::currentTime().msec());
|
||||
_root = QDir::tempPath() + "/" + "test_" + QString::number(qrand());
|
||||
qDebug() << "creating test directory tree in " << _root;
|
||||
QDir rootDir(_root);
|
||||
|
||||
rootDir.mkpath(_root + "/a1/b1/c1");
|
||||
rootDir.mkpath(_root + "/a1/b1/c2");
|
||||
rootDir.mkpath(_root + "/a1/b2/c1");
|
||||
rootDir.mkpath(_root + "/a1/b3/c3");
|
||||
rootDir.mkpath(_root + "/a2/b3/c3");
|
||||
Utility::writeRandomFile( _root+"/a1/random.bin");
|
||||
Utility::writeRandomFile( _root+"/a1/b2/todelete.bin");
|
||||
Utility::writeRandomFile( _root+"/a2/renamefile");
|
||||
Utility::writeRandomFile( _root+"/a1/movefile");
|
||||
|
||||
_watcher = new FolderWatcher(_root);
|
||||
QObject::connect(_watcher, SIGNAL(pathChanged(QString)), this, SLOT(slotFolderChanged(QString)));
|
||||
_timer.singleShot(5000, this, SLOT(slotEnd()));
|
||||
}
|
||||
|
||||
void init()
|
||||
{
|
||||
_pathChangedSpy->clear();
|
||||
_receivedNotifications.clear();
|
||||
_requiredNotifications.clear();
|
||||
_skipNotifications.clear();
|
||||
}
|
||||
|
||||
void checkNotifications()
|
||||
{
|
||||
processAndWait();
|
||||
QCOMPARE(_receivedNotifications, _requiredNotifications);
|
||||
}
|
||||
|
||||
void testACreate() { // create a new file
|
||||
QString file(_rootPath + "/foo.txt");
|
||||
QString file(_root + "/foo.txt");
|
||||
QString cmd;
|
||||
_requiredNotifications.insert(file);
|
||||
cmd = QString("echo \"xyz\" > %1").arg(file);
|
||||
qDebug() << "Command: " << cmd;
|
||||
system(cmd.toLocal8Bit());
|
||||
|
||||
QVERIFY(waitForPathChanged(file));
|
||||
checkNotifications();
|
||||
}
|
||||
|
||||
void testATouch() { // touch an existing file.
|
||||
QString file(_rootPath + "/a1/random.bin");
|
||||
touch(file);
|
||||
QVERIFY(waitForPathChanged(file));
|
||||
QString file(_root + "/a1/random.bin");
|
||||
_requiredNotifications.insert(file);
|
||||
#ifdef Q_OS_WIN
|
||||
Utility::writeRandomFile(QString("%1/a1/random.bin").arg(_root));
|
||||
#else
|
||||
QString cmd;
|
||||
cmd = QString("touch %1").arg(file);
|
||||
qDebug() << "Command: " << cmd;
|
||||
system(cmd.toLocal8Bit());
|
||||
#endif
|
||||
|
||||
checkNotifications();
|
||||
}
|
||||
|
||||
void testCreateADir() {
|
||||
QString file(_rootPath+"/a1/b1/new_dir");
|
||||
mkdir(file);
|
||||
QVERIFY(waitForPathChanged(file));
|
||||
QString file(_root+"/a1/b1/new_dir");
|
||||
_requiredNotifications.insert(file);
|
||||
//_skipNotifications.insert(_root + "/a1/b1/new_dir");
|
||||
QDir dir;
|
||||
dir.mkdir(file);
|
||||
QVERIFY(QFile::exists(file));
|
||||
|
||||
checkNotifications();
|
||||
}
|
||||
|
||||
void testRemoveADir() {
|
||||
QString file(_rootPath+"/a1/b3/c3");
|
||||
rmdir(file);
|
||||
QVERIFY(waitForPathChanged(file));
|
||||
QString file(_root+"/a1/b3/c3");
|
||||
_requiredNotifications.insert(file);
|
||||
QDir dir;
|
||||
QVERIFY(dir.rmdir(file));
|
||||
|
||||
checkNotifications();
|
||||
}
|
||||
|
||||
void testRemoveAFile() {
|
||||
QString file(_rootPath+"/a1/b2/todelete.bin");
|
||||
QString file(_root+"/a1/b2/todelete.bin");
|
||||
_requiredNotifications.insert(file);
|
||||
QVERIFY(QFile::exists(file));
|
||||
rm(file);
|
||||
QFile::remove(file);
|
||||
QVERIFY(!QFile::exists(file));
|
||||
|
||||
QVERIFY(waitForPathChanged(file));
|
||||
checkNotifications();
|
||||
}
|
||||
|
||||
void testRenameAFile() {
|
||||
QString file1(_rootPath+"/a2/renamefile");
|
||||
QString file2(_rootPath+"/a2/renamefile.renamed");
|
||||
QString file1(_root+"/a2/renamefile");
|
||||
QString file2(_root+"/a2/renamefile.renamed");
|
||||
_requiredNotifications.insert(file1);
|
||||
_requiredNotifications.insert(file2);
|
||||
QVERIFY(QFile::exists(file1));
|
||||
mv(file1, file2);
|
||||
QFile::rename(file1, file2);
|
||||
QVERIFY(QFile::exists(file2));
|
||||
|
||||
QVERIFY(waitForPathChanged(file1));
|
||||
QVERIFY(waitForPathChanged(file2));
|
||||
checkNotifications();
|
||||
}
|
||||
|
||||
void testMoveAFile() {
|
||||
QString old_file(_rootPath+"/a1/movefile");
|
||||
QString new_file(_rootPath+"/a2/movefile.renamed");
|
||||
QString old_file(_root+"/a1/movefile");
|
||||
QString new_file(_root+"/a2/movefile.renamed");
|
||||
_requiredNotifications.insert(old_file);
|
||||
_requiredNotifications.insert(new_file);
|
||||
QVERIFY(QFile::exists(old_file));
|
||||
mv(old_file, new_file);
|
||||
QFile::rename(old_file, new_file);
|
||||
QVERIFY(QFile::exists(new_file));
|
||||
|
||||
QVERIFY(waitForPathChanged(old_file));
|
||||
QVERIFY(waitForPathChanged(new_file));
|
||||
checkNotifications();
|
||||
}
|
||||
|
||||
void cleanupTestCase() {
|
||||
if( _root.startsWith(QDir::tempPath() )) {
|
||||
system( QString("rm -rf %1").arg(_root).toLocal8Bit() );
|
||||
}
|
||||
delete _watcher;
|
||||
}
|
||||
};
|
||||
|
||||
#ifdef Q_OS_MAC
|
||||
QTEST_MAIN(TestFolderWatcher)
|
||||
#if QT_VERSION < QT_VERSION_CHECK(5, 0, 0)
|
||||
// Qt4 does not have QTEST_GUILESS_MAIN, so we simulate it.
|
||||
int main(int argc, char *argv[])
|
||||
{
|
||||
QCoreApplication app(argc, argv);
|
||||
TestFolderWatcher tc;
|
||||
return QTest::qExec(&tc, argc, argv);
|
||||
}
|
||||
#else
|
||||
QTEST_GUILESS_MAIN(TestFolderWatcher)
|
||||
#endif
|
||||
|
||||
@@ -169,6 +169,7 @@ private slots:
|
||||
void testFileNamesEqual()
|
||||
{
|
||||
#if QT_VERSION >= QT_VERSION_CHECK(5, 1, 0)
|
||||
qDebug() << "*** checking fileNamesEqual function";
|
||||
QTemporaryDir dir;
|
||||
QVERIFY(dir.isValid());
|
||||
QDir dir2(dir.path());
|
||||
@@ -200,5 +201,5 @@ private slots:
|
||||
|
||||
};
|
||||
|
||||
QTEST_GUILESS_MAIN(TestUtility)
|
||||
QTEST_APPLESS_MAIN(TestUtility)
|
||||
#include "testutility.moc"
|
||||
|
||||
+199
-267
Diferenças do arquivo suprimidas por serem muito extensas
Carregar Diff
+202
-268
Diferenças do arquivo suprimidas por serem muito extensas
Carregar Diff
+201
-275
Diferenças do arquivo suprimidas por serem muito extensas
Carregar Diff
+209
-275
Diferenças do arquivo suprimidas por serem muito extensas
Carregar Diff
+195
-264
Diferenças do arquivo suprimidas por serem muito extensas
Carregar Diff
+203
-276
Diferenças do arquivo suprimidas por serem muito extensas
Carregar Diff
+196
-265
Diferenças do arquivo suprimidas por serem muito extensas
Carregar Diff
+196
-265
Diferenças do arquivo suprimidas por serem muito extensas
Carregar Diff
+197
-266
Diferenças do arquivo suprimidas por serem muito extensas
Carregar Diff
+197
-266
Diferenças do arquivo suprimidas por serem muito extensas
Carregar Diff
+199
-267
Diferenças do arquivo suprimidas por serem muito extensas
Carregar Diff
+216
-285
Diferenças do arquivo suprimidas por serem muito extensas
Carregar Diff
+198
-266
Diferenças do arquivo suprimidas por serem muito extensas
Carregar Diff
+197
-266
Diferenças do arquivo suprimidas por serem muito extensas
Carregar Diff
+201
-270
Diferenças do arquivo suprimidas por serem muito extensas
Carregar Diff
+202
-268
Diferenças do arquivo suprimidas por serem muito extensas
Carregar Diff
+202
-268
Diferenças do arquivo suprimidas por serem muito extensas
Carregar Diff
+203
-271
Diferenças do arquivo suprimidas por serem muito extensas
Carregar Diff
+233
-301
Diferenças do arquivo suprimidas por serem muito extensas
Carregar Diff
+203
-269
Diferenças do arquivo suprimidas por serem muito extensas
Carregar Diff
+202
-273
Diferenças do arquivo suprimidas por serem muito extensas
Carregar Diff
+203
-276
Diferenças do arquivo suprimidas por serem muito extensas
Carregar Diff
+202
-268
Diferenças do arquivo suprimidas por serem muito extensas
Carregar Diff
+201
-269
Diferenças do arquivo suprimidas por serem muito extensas
Carregar Diff
+197
-266
Diferenças do arquivo suprimidas por serem muito extensas
Carregar Diff
+202
-268
Diferenças do arquivo suprimidas por serem muito extensas
Carregar Diff
+201
-269
Diferenças do arquivo suprimidas por serem muito extensas
Carregar Diff
+211
-277
Diferenças do arquivo suprimidas por serem muito extensas
Carregar Diff
+212
-281
Diferenças do arquivo suprimidas por serem muito extensas
Carregar Diff
+202
-268
Diferenças do arquivo suprimidas por serem muito extensas
Carregar Diff
+202
-268
Diferenças do arquivo suprimidas por serem muito extensas
Carregar Diff
Referência em uma Nova Issue
Bloquear um usuário