Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Postfix magic and vars #10151

Open
wants to merge 6 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,8 @@ std::shared_ptr<HBITMAP> saveImage(const string &data)
Gdiplus::GdiplusStartupInput gdiplusStartupInput;
Gdiplus::GdiplusStartup(&gdiplusToken, &gdiplusStartupInput, nullptr);

DWORD size = 2 * 1024;
const int bytesPerKibibyte = 1024;
DWORD size = 2 * bytesPerKibibyte;
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

maybe lift my _kb operator from testchunkingng.cpp:19, put it in a utility file, and use it here?

std::vector<BYTE> buf(size, 0);
DWORD skipped;
if (!CryptStringToBinaryA(data.data(), 0, CRYPT_STRING_BASE64, buf.data(), &size, &skipped, nullptr)) {
Expand Down
18 changes: 9 additions & 9 deletions src/cmd/cmd.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -73,8 +73,8 @@ struct CmdOptions
QString exclude;
QString unsyncedfolders;
int restartTimes = 3;
int downlimit = 0;
int uplimit = 0;
int downlimitKbPerSec = 0;
int uplimitKbPerSec = 0;
bool deltasync;
qint64 deltasyncminfilesize;
};
Expand Down Expand Up @@ -201,7 +201,7 @@ void sync(const SyncCTX &ctx)
QObject::connect(engine, &SyncEngine::syncError, engine,
[](const QString &error) { qWarning() << "Sync error:" << error; });
engine->setIgnoreHiddenFiles(ctx.options.ignoreHiddenFiles);
engine->setNetworkLimits(ctx.options.uplimit, ctx.options.downlimit);
engine->setNetworkLimits(ctx.options.uplimitKbPerSec, ctx.options.downlimitKbPerSec);


// Exclude lists
Expand Down Expand Up @@ -312,8 +312,8 @@ class HttpCredentialsText : public HttpCredentials
std::cout << " -n Use netrc (5) for login" << std::endl;
std::cout << " --non-interactive Do not block execution with interaction" << std::endl;
std::cout << " --max-sync-retries [n] Retries maximum n times (default to 3)" << std::endl;
std::cout << " --uplimit [n] Limit the upload speed of files to n KB/s" << std::endl;
std::cout << " --downlimit [n] Limit the download speed of files to n KB/s" << std::endl;
std::cout << " --uplimitKbPerSec [n] Limit the upload speed of files to n KB/s" << std::endl;
std::cout << " --downlimitKbPerSec [n] Limit the download speed of files to n KB/s" << std::endl;
std::cout << " -h Sync hidden files,do not ignore them" << std::endl;
std::cout << " --version, -v Display version and exit" << std::endl;
std::cout << " --logdebug More verbose logging" << std::endl;
Expand Down Expand Up @@ -391,10 +391,10 @@ CmdOptions parseOptions(const QStringList &app_args)
options.unsyncedfolders = it.next();
} else if (option == QLatin1String("--max-sync-retries") && !it.peekNext().startsWith(QLatin1String("-"))) {
options.restartTimes = it.next().toInt();
} else if (option == QLatin1String("--uplimit") && !it.peekNext().startsWith(QLatin1String("-"))) {
options.uplimit = it.next().toInt() * 1000;
} else if (option == QLatin1String("--downlimit") && !it.peekNext().startsWith(QLatin1String("-"))) {
options.downlimit = it.next().toInt() * 1000;
} else if (option == QLatin1String("--uplimitKbPerSec") && !it.peekNext().startsWith(QLatin1String("-"))) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please don't change the commandline arguments, the change would break existing scripts.

options.uplimitKbPerSec = it.next().toInt() * 1000;
} else if (option == QLatin1String("--downlimitKbPerSec") && !it.peekNext().startsWith(QLatin1String("-"))) {
options.downlimitKbPerSec = it.next().toInt() * 1000;
} else if (option == QLatin1String("--logdebug")) {
Logger::instance()->setLogFile(QStringLiteral("-"));
Logger::instance()->setLogDebug(true);
Expand Down
3 changes: 2 additions & 1 deletion src/common/checksums.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,8 @@ namespace {

QByteArray calcAdler32(QIODevice *device)
{
const qint64 BUFSIZE(500 * 1024); // 500 KiB
const int bytesPerKibibyte = 1024;
const qint64 BUFSIZE(500 * bytesPerKibibyte); // 500 KiB
if (device->size() == 0) {
return QByteArray();
}
Expand Down
3 changes: 2 additions & 1 deletion src/gui/folderwatcher_win.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -181,7 +181,8 @@ void WatcherThread::run()
// If this buffer fills up before we've extracted its data we will lose
// change information. Therefore start big.
size_t bufferSize = 4096 * 10;
const size_t maxBuffer = 64 * 1024;
const int bytesPerKibiByte = 1024;
const size_t maxBuffer = 64 * bytesPerKibiByte;

while (true) {
switch (watchChanges(bufferSize)) {
Expand Down
2 changes: 1 addition & 1 deletion src/gui/socketapi/socketapi_p.h
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ class BloomFilter
// Initialize with m=1024 bits and k=2 (high and low 16 bits of a qHash).
// For a client navigating in less than 100 directories, this gives us a probability less than
// (1-e^(-2*100/1024))^2 = 0.03147872136 false positives.
const static int NumBits = 1024;
const static int NumBytesPerKibibyte = 1024;

public:
BloomFilter()
Expand Down
3 changes: 2 additions & 1 deletion src/gui/updater/updater.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -122,7 +122,8 @@ QString Updater::getSystemInfo()
process.waitForFinished();
QByteArray output = process.readAllStandardOutput();
qCDebug(lcUpdater) << "Sys Info size: " << output.length();
if (output.length() > 1024)
const int bytesPerKibiByte = 1024;
if (output.length() > bytesPerKibiByte)
output.clear(); // don't send too much.

return QString::fromLocal8Bit(output.toBase64());
Expand Down
3 changes: 2 additions & 1 deletion test/testutility.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,8 @@ private slots:
//NOTE: in order for the plural to work we would need to load the english translation

quint64 sec = 1000;
quint64 hour = 3600 * sec;
const int secondsPerHour = 3600;
quint64 hour = secondsPerHour * sec;

QDateTime current = QDateTime::currentDateTimeUtc();

Expand Down