mirror of
https://github.com/nextcloud/desktop.git
synced 2024-11-22 13:05:51 +03:00
Please the clang-tidy overlord
Signed-off-by: Kevin Ottens <kevin.ottens@nextcloud.com>
This commit is contained in:
parent
c03a5da670
commit
c57eff6fd8
32 changed files with 75 additions and 87 deletions
|
@ -121,7 +121,7 @@ QByteArray calcAdler32(QIODevice *device)
|
|||
QByteArray buf(BUFSIZE, Qt::Uninitialized);
|
||||
|
||||
unsigned int adler = adler32(0L, Z_NULL, 0);
|
||||
qint64 size;
|
||||
qint64 size = 0;
|
||||
while (!device->atEnd()) {
|
||||
size = device->read(buf.data(), BUFSIZE);
|
||||
if (size > 0)
|
||||
|
@ -204,9 +204,7 @@ ComputeChecksum::ComputeChecksum(QObject *parent)
|
|||
{
|
||||
}
|
||||
|
||||
ComputeChecksum::~ComputeChecksum()
|
||||
{
|
||||
}
|
||||
ComputeChecksum::~ComputeChecksum() = default;
|
||||
|
||||
void ComputeChecksum::setChecksumType(const QByteArray &type)
|
||||
{
|
||||
|
|
|
@ -518,9 +518,9 @@ QString FileSystem::pathtoUNC(const QString &str)
|
|||
|
||||
/* replace all occurences of / with the windows native \ */
|
||||
|
||||
for (auto it = longStr.begin(); it != longStr.end(); ++it) {
|
||||
if (*it == QLatin1Char('/')) {
|
||||
*it = QLatin1Char('\\');
|
||||
for (auto &c : longStr) {
|
||||
if (c == QLatin1Char('/')) {
|
||||
c = QLatin1Char('\\');
|
||||
}
|
||||
}
|
||||
return longStr;
|
||||
|
|
|
@ -62,7 +62,7 @@ QString RemotePermissions::toString() const
|
|||
RemotePermissions RemotePermissions::fromDbValue(const QByteArray &value)
|
||||
{
|
||||
if (value.isEmpty())
|
||||
return RemotePermissions();
|
||||
return {};
|
||||
RemotePermissions perm;
|
||||
perm.fromArray(value.constData());
|
||||
return perm;
|
||||
|
|
|
@ -706,7 +706,7 @@ bool SyncJournalDb::updateMetadataTableStructure()
|
|||
commitInternal(QStringLiteral("update database structure: add path index"));
|
||||
}
|
||||
|
||||
if (1) {
|
||||
if (true) {
|
||||
SqlQuery query(_db);
|
||||
query.prepare("CREATE INDEX IF NOT EXISTS metadata_parent ON metadata(parent_hash(path));");
|
||||
if (!query.exec()) {
|
||||
|
|
|
@ -25,12 +25,12 @@
|
|||
#include "syncfilestatus.h"
|
||||
#include "pinstate.h"
|
||||
|
||||
typedef struct csync_file_stat_s csync_file_stat_t;
|
||||
using csync_file_stat_t = struct csync_file_stat_s;
|
||||
|
||||
namespace OCC {
|
||||
|
||||
class Account;
|
||||
typedef QSharedPointer<Account> AccountPtr;
|
||||
using AccountPtr = QSharedPointer<Account>;
|
||||
class SyncJournalDb;
|
||||
class VfsPrivate;
|
||||
class SyncFileItem;
|
||||
|
@ -329,7 +329,7 @@ OCSYNC_EXPORT std::unique_ptr<Vfs> createVfsFromPlugin(Vfs::Mode mode);
|
|||
namespace { \
|
||||
void initPlugin() \
|
||||
{ \
|
||||
OCC::Vfs::registerPlugin(QStringLiteral(name), []() -> OCC::Vfs * { return new Type; }); \
|
||||
OCC::Vfs::registerPlugin(QStringLiteral(name), []() -> OCC::Vfs * { return new (Type); }); \
|
||||
} \
|
||||
Q_COREAPP_STARTUP_FUNCTION(initPlugin) \
|
||||
}
|
||||
|
|
|
@ -66,7 +66,7 @@ class OCSYNC_EXPORT ExcludedFiles : public QObject
|
|||
{
|
||||
Q_OBJECT
|
||||
public:
|
||||
typedef std::tuple<int, int, int> Version;
|
||||
using Version = std::tuple<int, int, int>;
|
||||
|
||||
explicit ExcludedFiles(const QString &localPath = QStringLiteral("/"));
|
||||
~ExcludedFiles();
|
||||
|
|
|
@ -18,7 +18,7 @@
|
|||
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
|
||||
*/
|
||||
|
||||
#include <stdlib.h> // NOLINT this is sometimes compiled in C mode
|
||||
#include <string.h> // NOLINT this is sometimes compiled in C mode
|
||||
#include <cstdlib>
|
||||
#include <cstring>
|
||||
|
||||
#include "c_private.h"
|
||||
|
|
|
@ -39,7 +39,7 @@
|
|||
#include <unistd.h>
|
||||
#endif
|
||||
|
||||
#include <errno.h> // NOLINT this is sometimes compiled in C mode
|
||||
#include <cerrno>
|
||||
|
||||
#ifdef __MINGW32__
|
||||
#ifndef S_IRGRP
|
||||
|
@ -74,10 +74,10 @@
|
|||
|
||||
|
||||
#ifdef _WIN32
|
||||
typedef struct stat64 csync_stat_t; // NOLINT this is sometimes compiled in C mode
|
||||
using csync_stat_t = struct stat64;
|
||||
#define _FILE_OFFSET_BITS 64
|
||||
#else
|
||||
typedef struct stat csync_stat_t; // NOLINT this is sometimes compiled in C mode
|
||||
using csync_stat_t = struct stat;
|
||||
#endif
|
||||
|
||||
#ifndef O_NOATIME
|
||||
|
@ -94,7 +94,7 @@ typedef struct stat csync_stat_t; // NOLINT this is sometimes compiled in C mode
|
|||
#endif
|
||||
|
||||
#if defined _WIN32 && defined _UNICODE
|
||||
typedef wchar_t mbchar_t; // NOLINT this is sometimes compiled in C mode
|
||||
using mbchar_t = wchar_t;
|
||||
#define _topen _wopen
|
||||
#define _tdirent _wdirent
|
||||
#define _topendir _wopendir
|
||||
|
@ -115,7 +115,7 @@ typedef wchar_t mbchar_t; // NOLINT this is sometimes compiled in C mod
|
|||
#define _tchdir _wchdir
|
||||
#define _tgetcwd _wgetcwd
|
||||
#else
|
||||
typedef char mbchar_t; // NOLINT this is sometimes compiled in C mode
|
||||
using mbchar_t = char;
|
||||
#define _tdirent dirent
|
||||
#define _topen open
|
||||
#define _topendir opendir
|
||||
|
|
|
@ -74,7 +74,7 @@ int csync_vio_local_closedir(csync_vio_handle_t *dhandle) {
|
|||
|
||||
std::unique_ptr<csync_file_stat_t> csync_vio_local_readdir(csync_vio_handle_t *handle, OCC::Vfs *vfs) {
|
||||
|
||||
struct _tdirent *dirent = NULL;
|
||||
struct _tdirent *dirent = nullptr;
|
||||
std::unique_ptr<csync_file_stat_t> file_stat;
|
||||
|
||||
do {
|
||||
|
|
|
@ -113,7 +113,7 @@ void HttpCredentialsGui::showDialog()
|
|||
+ QLatin1String("<br>");
|
||||
}
|
||||
|
||||
QInputDialog *dialog = new QInputDialog();
|
||||
auto *dialog = new QInputDialog();
|
||||
dialog->setAttribute(Qt::WA_DeleteOnClose, true);
|
||||
dialog->setWindowTitle(tr("Enter Password"));
|
||||
dialog->setLabelText(msg);
|
||||
|
|
|
@ -648,8 +648,8 @@ void Folder::setVirtualFilesEnabled(bool enabled)
|
|||
_vfs->stop();
|
||||
_vfs->unregisterFolder();
|
||||
|
||||
disconnect(_vfs.data(), 0, this, 0);
|
||||
disconnect(&_engine->syncFileStatusTracker(), 0, _vfs.data(), 0);
|
||||
disconnect(_vfs.data(), nullptr, this, nullptr);
|
||||
disconnect(&_engine->syncFileStatusTracker(), nullptr, _vfs.data(), nullptr);
|
||||
|
||||
_vfs.reset(createVfsFromPlugin(newMode).release());
|
||||
|
||||
|
|
|
@ -1007,7 +1007,7 @@ Folder *FolderMan::addFolder(AccountState *accountState, const FolderDefinition
|
|||
auto vfs = createVfsFromPlugin(folderDefinition.virtualFilesMode);
|
||||
if (!vfs) {
|
||||
qCWarning(lcFolderMan) << "Could not load plugin for mode" << folderDefinition.virtualFilesMode;
|
||||
return 0;
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
auto folder = addFolderInternal(definition, accountState, std::move(vfs));
|
||||
|
|
|
@ -79,7 +79,6 @@ QString Utility::vfsCurrentAvailabilityText(VfsItemAvailability availability)
|
|||
case VfsItemAvailability::Mixed:
|
||||
return QCoreApplication::translate("utility", "Some available online only");
|
||||
case VfsItemAvailability::AllDehydrated:
|
||||
return QCoreApplication::translate("utility", "Available online only");
|
||||
case VfsItemAvailability::OnlineOnly:
|
||||
return QCoreApplication::translate("utility", "Available online only");
|
||||
}
|
||||
|
|
|
@ -246,7 +246,7 @@ void SettingsDialog::accountAdded(AccountState *s)
|
|||
|
||||
if (!brandingSingleAccount) {
|
||||
accountAction->setToolTip(s->account()->displayName());
|
||||
accountAction->setIconText(shortDisplayNameForSettings(s->account().data(), height * buttonSizeRatio));
|
||||
accountAction->setIconText(shortDisplayNameForSettings(s->account().data(), static_cast<int>(height * buttonSizeRatio)));
|
||||
}
|
||||
|
||||
_toolBar->insertAction(_toolBar->actions().at(0), accountAction);
|
||||
|
@ -295,7 +295,7 @@ void SettingsDialog::slotAccountDisplayNameChanged()
|
|||
QString displayName = account->displayName();
|
||||
action->setText(displayName);
|
||||
auto height = _toolBar->sizeHint().height();
|
||||
action->setIconText(shortDisplayNameForSettings(account, height * buttonSizeRatio));
|
||||
action->setIconText(shortDisplayNameForSettings(account, static_cast<int>(height * buttonSizeRatio)));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -201,7 +201,7 @@ void HttpCredentials::fetchFromKeychainHelper()
|
|||
if (!_clientCertBundle.isEmpty()) {
|
||||
// New case (>=2.6): We have a bundle in the settings and read the password from
|
||||
// the keychain
|
||||
ReadPasswordJob *job = new ReadPasswordJob(Theme::instance()->appName());
|
||||
auto job = new ReadPasswordJob(Theme::instance()->appName());
|
||||
addSettingsToJob(_account, job);
|
||||
job->setInsecureFallback(false);
|
||||
job->setKey(keychainKey(_account->url().toString(), _user + clientCertPasswordC, _account->id()));
|
||||
|
@ -263,7 +263,7 @@ void HttpCredentials::slotReadClientCertPasswordJobDone(QKeychain::Job *job)
|
|||
if (keychainUnavailableRetryLater(job))
|
||||
return;
|
||||
|
||||
ReadPasswordJob *readJob = static_cast<ReadPasswordJob *>(job);
|
||||
auto readJob = static_cast<ReadPasswordJob *>(job);
|
||||
if (readJob->error() == NoError) {
|
||||
_clientCertPassword = readJob->binaryData();
|
||||
} else {
|
||||
|
|
|
@ -41,7 +41,7 @@ class TokenCredentialsAccessManager : public AccessManager
|
|||
{
|
||||
public:
|
||||
friend class TokenCredentials;
|
||||
TokenCredentialsAccessManager(const TokenCredentials *cred, QObject *parent = 0)
|
||||
TokenCredentialsAccessManager(const TokenCredentials *cred, QObject *parent = nullptr)
|
||||
: AccessManager(parent)
|
||||
, _cred(cred)
|
||||
{
|
||||
|
|
|
@ -1296,9 +1296,8 @@ auto ProcessDirectoryJob::checkMovePermissions(RemotePermissions srcPerm, const
|
|||
bool destinationOK = true;
|
||||
bool destinationNewOK = true;
|
||||
if (destPerms.isNull()) {
|
||||
} else if (isDirectory && !destPerms.hasPermission(RemotePermissions::CanAddSubDirectories)) {
|
||||
destinationNewOK = false;
|
||||
} else if (!isDirectory && !destPerms.hasPermission(RemotePermissions::CanAddFile)) {
|
||||
} else if ((isDirectory && !destPerms.hasPermission(RemotePermissions::CanAddSubDirectories)) ||
|
||||
(!isDirectory && !destPerms.hasPermission(RemotePermissions::CanAddFile))) {
|
||||
destinationNewOK = false;
|
||||
}
|
||||
if (!isRename && !destinationNewOK) {
|
||||
|
|
|
@ -89,7 +89,7 @@ class DiscoverySingleLocalDirectoryJob : public QObject, public QRunnable
|
|||
{
|
||||
Q_OBJECT
|
||||
public:
|
||||
explicit DiscoverySingleLocalDirectoryJob(const AccountPtr &account, const QString &localPath, OCC::Vfs *vfs, QObject *parent = 0);
|
||||
explicit DiscoverySingleLocalDirectoryJob(const AccountPtr &account, const QString &localPath, OCC::Vfs *vfs, QObject *parent = nullptr);
|
||||
|
||||
void run() Q_DECL_OVERRIDE;
|
||||
signals:
|
||||
|
|
|
@ -22,9 +22,7 @@ using namespace OCC;
|
|||
|
||||
Q_LOGGING_CATEGORY(lcLocalDiscoveryTracker, "sync.localdiscoverytracker", QtInfoMsg)
|
||||
|
||||
LocalDiscoveryTracker::LocalDiscoveryTracker()
|
||||
{
|
||||
}
|
||||
LocalDiscoveryTracker::LocalDiscoveryTracker() = default;
|
||||
|
||||
void LocalDiscoveryTracker::addTouchedPath(const QString &relativePath)
|
||||
{
|
||||
|
|
|
@ -24,7 +24,7 @@
|
|||
namespace OCC {
|
||||
|
||||
class SyncFileItem;
|
||||
typedef QSharedPointer<SyncFileItem> SyncFileItemPtr;
|
||||
using SyncFileItemPtr = QSharedPointer<SyncFileItem>;
|
||||
|
||||
/**
|
||||
* @brief Tracks files that must be rediscovered locally
|
||||
|
|
|
@ -205,7 +205,7 @@ void GETFileJob::slotMetaDataChanged()
|
|||
return;
|
||||
}
|
||||
|
||||
bool ok;
|
||||
bool ok = false;
|
||||
_contentLength = reply()->header(QNetworkRequest::ContentLengthHeader).toLongLong(&ok);
|
||||
if (ok && _expectedContentLength != -1 && _contentLength != _expectedContentLength) {
|
||||
qCWarning(lcGetJob) << "We received a different content length than expected!"
|
||||
|
|
|
@ -441,12 +441,7 @@ UploadDevice::UploadDevice(const QString &fileName, qint64 start, qint64 size, B
|
|||
: _file(fileName)
|
||||
, _start(start)
|
||||
, _size(size)
|
||||
, _read(0)
|
||||
, _bandwidthManager(bwm)
|
||||
, _bandwidthQuota(0)
|
||||
, _readWithProgress(0)
|
||||
, _bandwidthLimited(false)
|
||||
, _choked(false)
|
||||
{
|
||||
_bandwidthManager->registerUploadDevice(this);
|
||||
}
|
||||
|
|
|
@ -73,10 +73,10 @@ private:
|
|||
|
||||
// Bandwidth manager related
|
||||
QPointer<BandwidthManager> _bandwidthManager;
|
||||
qint64 _bandwidthQuota;
|
||||
qint64 _readWithProgress;
|
||||
bool _bandwidthLimited; // if _bandwidthQuota will be used
|
||||
bool _choked; // if upload is paused (readData() will return 0)
|
||||
qint64 _bandwidthQuota = 0;
|
||||
qint64 _readWithProgress = 0;
|
||||
bool _bandwidthLimited = false; // if _bandwidthQuota will be used
|
||||
bool _choked = false; // if upload is paused (readData() will return 0)
|
||||
friend class BandwidthManager;
|
||||
public slots:
|
||||
void slotJobUploadProgress(qint64 sent, qint64 t);
|
||||
|
|
|
@ -563,7 +563,7 @@ void SyncEngine::startSync()
|
|||
// files with names that contain these.
|
||||
// It's important to respect the capability also for older servers -- the
|
||||
// version check doesn't make sense for custom servers.
|
||||
invalidFilenamePattern = "[\\\\:?*\"<>|]";
|
||||
invalidFilenamePattern = R"([\\:?*"<>|])";
|
||||
}
|
||||
if (!invalidFilenamePattern.isEmpty())
|
||||
_discoveryPhase->_invalidFilenameRx = QRegExp(invalidFilenamePattern);
|
||||
|
@ -589,12 +589,10 @@ void SyncEngine::startSync()
|
|||
void SyncEngine::slotFolderDiscovered(bool local, const QString &folder)
|
||||
{
|
||||
// Don't wanna overload the UI
|
||||
if (!_lastUpdateProgressCallbackCall.isValid()) {
|
||||
_lastUpdateProgressCallbackCall.start(); // first call
|
||||
} else if (_lastUpdateProgressCallbackCall.elapsed() < 200) {
|
||||
return;
|
||||
if (!_lastUpdateProgressCallbackCall.isValid() || _lastUpdateProgressCallbackCall.elapsed() >= 200) {
|
||||
_lastUpdateProgressCallbackCall.start(); // first call or enough elapsed time
|
||||
} else {
|
||||
_lastUpdateProgressCallbackCall.start();
|
||||
return;
|
||||
}
|
||||
|
||||
if (local) {
|
||||
|
@ -1014,7 +1012,7 @@ void SyncEngine::abort()
|
|||
} else if (_discoveryPhase) {
|
||||
// Delete the discovery and all child jobs after ensuring
|
||||
// it can't finish and start the propagator
|
||||
disconnect(_discoveryPhase.data(), 0, this, 0);
|
||||
disconnect(_discoveryPhase.data(), nullptr, this, nullptr);
|
||||
_discoveryPhase.take()->deleteLater();
|
||||
|
||||
syncError(tr("Aborted"));
|
||||
|
|
|
@ -27,9 +27,7 @@ VfsSuffix::VfsSuffix(QObject *parent)
|
|||
{
|
||||
}
|
||||
|
||||
VfsSuffix::~VfsSuffix()
|
||||
{
|
||||
}
|
||||
VfsSuffix::~VfsSuffix() = default;
|
||||
|
||||
Vfs::Mode VfsSuffix::mode() const
|
||||
{
|
||||
|
|
|
@ -61,7 +61,7 @@ static int wipe_testdir()
|
|||
}
|
||||
|
||||
static int setup_testenv(void **state) {
|
||||
int rc;
|
||||
int rc = 0;
|
||||
|
||||
rc = wipe_testdir();
|
||||
assert_int_equal(rc, 0);
|
||||
|
@ -80,7 +80,7 @@ static int setup_testenv(void **state) {
|
|||
assert_int_equal(rc, 0);
|
||||
|
||||
/* --- initialize csync */
|
||||
statevar *mystate = new statevar;
|
||||
auto mystate = new statevar;
|
||||
*state = mystate;
|
||||
return 0;
|
||||
}
|
||||
|
@ -91,7 +91,7 @@ static void output( const char *text )
|
|||
}
|
||||
|
||||
static int teardown(void **state) {
|
||||
int rc;
|
||||
int rc = -1;
|
||||
|
||||
output("================== Tearing down!\n");
|
||||
|
||||
|
@ -110,7 +110,7 @@ static int teardown(void **state) {
|
|||
*/
|
||||
static void create_dirs( const char *path )
|
||||
{
|
||||
int rc;
|
||||
int rc = -1;
|
||||
auto _mypath = QStringLiteral("%1/%2").arg(CSYNC_TEST_DIR, QString::fromUtf8(path)).toUtf8();
|
||||
char *mypath = _mypath.data();
|
||||
|
||||
|
@ -149,13 +149,13 @@ static void create_dirs( const char *path )
|
|||
*/
|
||||
static void traverse_dir(void **state, const QString &dir, int *cnt)
|
||||
{
|
||||
csync_vio_handle_t *dh;
|
||||
csync_vio_handle_t *dh = nullptr;
|
||||
std::unique_ptr<csync_file_stat_t> dirent;
|
||||
statevar *sv = (statevar*) *state;
|
||||
auto sv = (statevar*) *state;
|
||||
QByteArray subdir;
|
||||
QByteArray subdir_out;
|
||||
int rc;
|
||||
int is_dir;
|
||||
int rc = -1;
|
||||
int is_dir = 0;
|
||||
|
||||
dh = csync_vio_local_opendir(dir);
|
||||
assert_non_null(dh);
|
||||
|
@ -208,7 +208,7 @@ static void create_file( const char *path, const char *name, const char *content
|
|||
|
||||
static void check_readdir_shorttree(void **state)
|
||||
{
|
||||
statevar *sv = (statevar*) *state;
|
||||
auto sv = (statevar*) *state;
|
||||
|
||||
const char *t1 = "alibaba/und/die/vierzig/räuber/";
|
||||
create_dirs( t1 );
|
||||
|
@ -230,7 +230,7 @@ static void check_readdir_shorttree(void **state)
|
|||
|
||||
static void check_readdir_with_content(void **state)
|
||||
{
|
||||
statevar *sv = (statevar*) *state;
|
||||
auto sv = (statevar*) *state;
|
||||
int files_cnt = 0;
|
||||
|
||||
const char *t1 = "warum/nur/40/Räuber/";
|
||||
|
@ -257,7 +257,7 @@ static void check_readdir_with_content(void **state)
|
|||
|
||||
static void check_readdir_longtree(void **state)
|
||||
{
|
||||
statevar *sv = (statevar*) *state;
|
||||
auto sv = (statevar*) *state;
|
||||
|
||||
/* Strange things here: Compilers only support strings with length of 4k max.
|
||||
* The expected result string is longer, so it needs to be split up in r1, r2 and r3
|
||||
|
@ -327,7 +327,7 @@ static void check_readdir_longtree(void **state)
|
|||
// https://github.com/owncloud/client/issues/3128 https://github.com/owncloud/client/issues/2777
|
||||
static void check_readdir_bigunicode(void **state)
|
||||
{
|
||||
statevar *sv = (statevar*) *state;
|
||||
auto sv = (statevar*) *state;
|
||||
// 1: ? ASCII: 239 - EF
|
||||
// 2: ? ASCII: 187 - BB
|
||||
// 3: ? ASCII: 191 - BF
|
||||
|
@ -362,5 +362,5 @@ int torture_run_tests(void)
|
|||
cmocka_unit_test_setup_teardown(check_readdir_bigunicode, setup_testenv, teardown),
|
||||
};
|
||||
|
||||
return cmocka_run_group_tests(tests, NULL, NULL);
|
||||
return cmocka_run_group_tests(tests, nullptr, nullptr);
|
||||
}
|
||||
|
|
|
@ -18,7 +18,7 @@ class HttpServer : public QTcpServer
|
|||
{
|
||||
Q_OBJECT
|
||||
public:
|
||||
HttpServer(qint16 port, QObject* parent = 0);
|
||||
HttpServer(qint16 port, QObject* parent = nullptr);
|
||||
void incomingConnection(int socket);
|
||||
|
||||
private slots:
|
||||
|
|
|
@ -8,6 +8,10 @@
|
|||
#include "syncenginetestutils.h"
|
||||
|
||||
|
||||
#include <memory>
|
||||
|
||||
|
||||
|
||||
PathComponents::PathComponents(const char *path)
|
||||
: PathComponents { QString::fromUtf8(path) }
|
||||
{
|
||||
|
@ -374,7 +378,7 @@ FileInfo *FakePutReply::perform(FileInfo &remoteRootFileInfo, const QNetworkRequ
|
|||
fileInfo = remoteRootFileInfo.create(fileName, putPayload.size(), putPayload.at(0));
|
||||
}
|
||||
fileInfo->lastModified = OCC::Utility::qDateTimeFromTime_t(request.rawHeader("X-OC-Mtime").toLongLong());
|
||||
remoteRootFileInfo.find(fileName, /*invalidate_etags=*/true);
|
||||
remoteRootFileInfo.find(fileName, /*invalidateEtags=*/true);
|
||||
return fileInfo;
|
||||
}
|
||||
|
||||
|
@ -612,7 +616,7 @@ FileInfo *FakeChunkMoveReply::perform(FileInfo &uploadsFileInfo, FileInfo &remot
|
|||
QString source = getFilePathFromUrl(request.url());
|
||||
Q_ASSERT(!source.isEmpty());
|
||||
Q_ASSERT(source.endsWith(QLatin1String("/.file")));
|
||||
source = source.left(source.length() - qstrlen("/.file"));
|
||||
source = source.left(source.length() - static_cast<int>(qstrlen("/.file")));
|
||||
|
||||
auto sourceFolder = uploadsFileInfo.find(source);
|
||||
Q_ASSERT(sourceFolder);
|
||||
|
@ -657,7 +661,7 @@ FileInfo *FakeChunkMoveReply::perform(FileInfo &uploadsFileInfo, FileInfo &remot
|
|||
fileInfo = remoteRootFileInfo.create(fileName, size, payload);
|
||||
}
|
||||
fileInfo->lastModified = OCC::Utility::qDateTimeFromTime_t(request.rawHeader("X-OC-Mtime").toLongLong());
|
||||
remoteRootFileInfo.find(fileName, /*invalidate_etags=*/true);
|
||||
remoteRootFileInfo.find(fileName, /*invalidateEtags=*/true);
|
||||
|
||||
return fileInfo;
|
||||
}
|
||||
|
@ -800,7 +804,7 @@ QNetworkReply *FakeQNAM::createRequest(QNetworkAccessManager::Operation op, cons
|
|||
FileInfo &info = isUpload ? _uploadFileInfo : _remoteRootFileInfo;
|
||||
|
||||
auto verb = request.attribute(QNetworkRequest::CustomVerbAttribute);
|
||||
FakeReply *reply;
|
||||
FakeReply *reply = nullptr;
|
||||
if (verb == QLatin1String("PROPFIND"))
|
||||
// Ignore outgoingData always returning somethign good enough, works for now.
|
||||
reply = new FakePropfindReply { info, op, request, this };
|
||||
|
@ -841,8 +845,8 @@ FakeFolder::FakeFolder(const FileInfo &fileTemplate)
|
|||
_account->setDavDisplayName(QStringLiteral("fakename"));
|
||||
_account->setServerVersion(QStringLiteral("10.0.0"));
|
||||
|
||||
_journalDb.reset(new OCC::SyncJournalDb(localPath() + QStringLiteral(".sync_test.db")));
|
||||
_syncEngine.reset(new OCC::SyncEngine(_account, localPath(), QString(), _journalDb.get()));
|
||||
_journalDb = std::make_unique<OCC::SyncJournalDb>(localPath() + QStringLiteral(".sync_test.db"));
|
||||
_syncEngine = std::make_unique<OCC::SyncEngine>(_account, localPath(), QString(), _journalDb.get());
|
||||
// Ignore temporary files from the download. (This is in the default exclude list, but we don't load it)
|
||||
_syncEngine->excludedFiles().addManualExclude(QStringLiteral("]*.~*"));
|
||||
|
||||
|
@ -1026,5 +1030,4 @@ FakeReply::FakeReply(QObject *parent)
|
|||
}
|
||||
|
||||
FakeReply::~FakeReply()
|
||||
{
|
||||
}
|
||||
= default;
|
||||
|
|
|
@ -113,7 +113,7 @@ private slots:
|
|||
auto successCallback = [](TestCase *tc, const QNetworkRequest &request) {
|
||||
tc->pollRequest = [](TestCase *, const QNetworkRequest &) -> QNetworkReply * { std::abort(); }; // shall no longer be called
|
||||
FileInfo *info = tc->perform();
|
||||
QByteArray body = "{ \"status\":\"finished\", \"ETag\":\"\\\"" + info->etag + "\\\"\", \"fileId\":\"" + info->fileId + "\"}\n";
|
||||
QByteArray body = R"({ "status":"finished", "ETag":"\")" + info->etag + R"(\"", "fileId":")" + info->fileId + "\"}\n";
|
||||
return new FakePayloadReply(QNetworkAccessManager::GetOperation, request, body, nullptr);
|
||||
};
|
||||
// Callback that never finishes
|
||||
|
@ -139,7 +139,7 @@ private slots:
|
|||
};
|
||||
|
||||
// Create a testcase by creating a file of a given size locally and assigning it a callback
|
||||
auto insertFile = [&](const QString &file, int size, TestCase::PollRequest_t cb) {
|
||||
auto insertFile = [&](const QString &file, qint64 size, TestCase::PollRequest_t cb) {
|
||||
fakeFolder.localModifier().insert(file, size);
|
||||
testCases[file] = { std::move(cb) };
|
||||
};
|
||||
|
|
|
@ -26,7 +26,7 @@ public:
|
|||
{
|
||||
if (aborted)
|
||||
return 0;
|
||||
return std::min(size, fakeSize) + QIODevice::bytesAvailable();
|
||||
return std::min(size, fakeSize) + QIODevice::bytesAvailable(); // NOLINT: This is intended to simulare the brokeness
|
||||
}
|
||||
|
||||
qint64 readData(char *data, qint64 maxlen) override
|
||||
|
|
|
@ -666,7 +666,7 @@ private slots:
|
|||
{
|
||||
extern void csync_exclude_expand_escapes(QByteArray &input);
|
||||
|
||||
QByteArray line = "keep \\' \\\" \\? \\\\ \\a \\b \\f \\n \\r \\t \\v \\z \\#";
|
||||
QByteArray line = R"(keep \' \" \? \\ \a \b \f \n \r \t \v \z \#)";
|
||||
csync_exclude_expand_escapes(line);
|
||||
QVERIFY(0 == strcmp(line.constData(), "keep ' \" ? \\\\ \a \b \f \n \r \t \v \\z #"));
|
||||
|
||||
|
|
|
@ -310,14 +310,14 @@ private slots:
|
|||
if (redirectsDone == 0) {
|
||||
std::unique_ptr<QBuffer> payload(new QBuffer());
|
||||
payload->setData("");
|
||||
SlowFakePostReply *reply = new SlowFakePostReply(op, request, std::move(payload), this);
|
||||
auto *reply = new SlowFakePostReply(op, request, std::move(payload), this);
|
||||
reply->redirectToPolicy = true;
|
||||
redirectsDone++;
|
||||
return reply;
|
||||
} else if (redirectsDone == 1) {
|
||||
std::unique_ptr<QBuffer> payload(new QBuffer());
|
||||
payload->setData("");
|
||||
SlowFakePostReply *reply = new SlowFakePostReply(op, request, std::move(payload), this);
|
||||
auto *reply = new SlowFakePostReply(op, request, std::move(payload), this);
|
||||
reply->redirectToToken = true;
|
||||
redirectsDone++;
|
||||
return reply;
|
||||
|
|
Loading…
Reference in a new issue