Skip to content

Commit

Permalink
WIP: temporary fix for Windows build and disabled debug for testing
Browse files Browse the repository at this point in the history
  • Loading branch information
grulja committed Oct 4, 2024
1 parent fd0648a commit 346aa26
Show file tree
Hide file tree
Showing 4 changed files with 25 additions and 25 deletions.
2 changes: 1 addition & 1 deletion src/app/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ if (WIN32)
# HACK: we need to remove -std=c++11 definition for manifest file, otherwise
# it will complain about undefined option "s" (as first letter from -Std=c++11)
remove_definitions(-std=c++11)
target_sources(mediawriter PRIVATE data/windows.rc)
# target_sources(mediawriter PRIVATE data/windows.rc)
endif()

if (APPLE)
Expand Down
22 changes: 11 additions & 11 deletions src/app/downloadmanager.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -63,14 +63,14 @@ QString DownloadManager::userAgent()
*/
QString DownloadManager::downloadFile(DownloadReceiver *receiver, const QUrl &url, const QString &folder, Progress *progress)
{
mDebug() << this->metaObject()->className() << "Going to download" << url;
// mDebug() << this->metaObject()->className() << "Going to download" << url;
QString bareFileName = QString("%1/%2").arg(folder).arg(url.fileName());

QDir dir;
dir.mkpath(folder);

if (QFile::exists(bareFileName)) {
mDebug() << this->metaObject()->className() << "The file already exists on" << bareFileName;
// mDebug() << this->metaObject()->className() << "The file already exists on" << bareFileName;
return bareFileName;
}

Expand Down Expand Up @@ -133,7 +133,7 @@ void DownloadManager::cancel()
if (m_current) {
m_current->deleteLater();
m_current = nullptr;
mDebug() << this->metaObject()->className() << "Cancelling";
// mDebug() << this->metaObject()->className() << "Cancelling";
}
}

Expand All @@ -149,7 +149,7 @@ void DownloadManager::onStringDownloaded(const QString &text)
if (!m_current)
return;

mDebug() << this->metaObject()->className() << "Received a list of mirrors";
// mDebug() << this->metaObject()->className() << "Received a list of mirrors";

QStringList mirrors;
for (const QString &i : text.split("\n")) {
Expand Down Expand Up @@ -199,7 +199,7 @@ void DownloadManager::onDownloadError(const QString &message)

DownloadManager::DownloadManager()
{
mDebug() << this->metaObject()->className() << "User-Agent:" << userAgent();
// mDebug() << this->metaObject()->className() << "User-Agent:" << userAgent();
QNetworkProxyFactory::setUseSystemConfiguration(true);
}

Expand Down Expand Up @@ -235,7 +235,7 @@ void Download::handleNewReply(QNetworkReply *reply)
m_receiver->onDownloadError(tr("Unable to fetch the requested image."));
return;
}
mDebug() << this->metaObject()->className() << "Trying to download from a mirror:" << reply->url();
// mDebug() << this->metaObject()->className() << "Trying to download from a mirror:" << reply->url();

if (m_reply)
m_reply->deleteLater();
Expand Down Expand Up @@ -275,14 +275,14 @@ bool Download::hasCatchedUp()
void Download::start()
{
if (m_catchingUp) {
mDebug() << this->metaObject()->className() << "Will need to precompute the hash of the previously downloaded part";
// mDebug() << this->metaObject()->className() << "Will need to precompute the hash of the previously downloaded part";
// first precompute the SHA hash of the already downloaded part
m_file->open(QIODevice::ReadOnly);
m_previousSize = 0;

QTimer::singleShot(0, this, SLOT(catchUp()));
} else if (!m_path.isEmpty()) {
mDebug() << this->metaObject()->className() << "Creating a new empty file";
// mDebug() << this->metaObject()->className() << "Creating a new empty file";
m_file->open(QIODevice::WriteOnly);
}
}
Expand All @@ -299,7 +299,7 @@ void Download::catchUp()
if (!m_file->atEnd()) {
QTimer::singleShot(0, this, SLOT(catchUp()));
} else {
mDebug() << this->metaObject()->className() << "Finished computing the hash of the downloaded part";
// mDebug() << this->metaObject()->className() << "Finished computing the hash of the downloaded part";
m_file->close();
m_file->open(QIODevice::Append);
m_catchingUp = false;
Expand Down Expand Up @@ -372,7 +372,7 @@ void Download::onFinished()
{
m_timer.stop();
if (m_reply->error() != 0) {
mDebug() << this->metaObject()->className() << "An error occurred at the end:" << m_reply->errorString();
// mDebug() << this->metaObject()->className() << "An error occurred at the end:" << m_reply->errorString();
if (m_file && m_file->size() == 0) {
m_file->remove();
}
Expand All @@ -381,7 +381,7 @@ void Download::onFinished()
onReadyRead();
qApp->eventDispatcher()->processEvents(QEventLoop::ExcludeSocketNotifiers);
}
mDebug() << this->metaObject()->className() << "Finished successfully";
// mDebug() << this->metaObject()->className() << "Finished successfully";
if (m_file) {
m_file->close();
m_receiver->onFileDownloaded(m_file->fileName(), m_hash.result().toHex());
Expand Down
24 changes: 12 additions & 12 deletions src/app/releasemanager.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ ReleaseManager::ReleaseManager(QObject *parent)
: QSortFilterProxyModel(parent)
, m_sourceModel(new ReleaseListModel(this))
{
mDebug() << this->metaObject()->className() << "construction";
// mDebug() << this->metaObject()->className() << "construction";
setSourceModel(m_sourceModel);

qmlRegisterUncreatableType<Release>("MediaWriter", 1, 0, "Release", "");
Expand Down Expand Up @@ -155,7 +155,7 @@ int ReleaseManager::firstSource() const

void ReleaseManager::selectLocalFile(const QString &path)
{
mDebug() << this->metaObject()->className() << "Setting local file to" << path;
// mDebug() << this->metaObject()->className() << "Setting local file to" << path;
for (int i = 0; i < m_sourceModel->rowCount(); i++) {
Release *r = m_sourceModel->get(i);
if (r->source() == Release::LOCAL) {
Expand Down Expand Up @@ -268,7 +268,7 @@ ReleaseVariant *ReleaseManager::variant()

void ReleaseManager::onStringDownloaded(const QString &text)
{
mDebug() << this->metaObject()->className() << "Received a metadata json";
// mDebug() << this->metaObject()->className() << "Received a metadata json";

QRegularExpression re("(\\d+)\\s?(\\S+)?");
auto doc = QJsonDocument::fromJson(text.toUtf8());
Expand Down Expand Up @@ -315,7 +315,7 @@ void ReleaseManager::onStringDownloaded(const QString &text)
version = re.match(versionWithStatus).captured(1).toInt();
status = re.match(versionWithStatus).captured(2);

mDebug() << this->metaObject()->className() << "Adding" << release << versionWithStatus << arch;
// mDebug() << this->metaObject()->className() << "Adding" << release << versionWithStatus << arch;

if (!release.isEmpty() && !url.isEmpty() && !arch.isEmpty())
updateUrl(release, version, status, type, category, releaseDate, arch, url, sha256, size);
Expand Down Expand Up @@ -819,13 +819,13 @@ bool ReleaseVariant::updateUrl(const QString &url, const QString &sha256, int64_
{
bool changed = false;
if (!url.isEmpty() && m_url.toUtf8().trimmed() != url.toUtf8().trimmed()) {
mWarning() << "Url" << m_url << "changed to" << url;
// mWarning() << "Url" << m_url << "changed to" << url;
m_url = url;
emit urlChanged();
changed = true;
}
if (!sha256.isEmpty() && m_shaHash.trimmed() != sha256.trimmed()) {
mWarning() << "SHA256 hash of" << url << "changed from" << m_shaHash << "to" << sha256;
// mWarning() << "SHA256 hash of" << url << "changed from" << m_shaHash << "to" << sha256;
m_shaHash = sha256;
emit shaHashChanged();
changed = true;
Expand Down Expand Up @@ -963,7 +963,7 @@ void ReleaseVariant::onFileDownloaded(const QString &path, const QString &hash)
setStatus(FAILED_DOWNLOAD);
return;
}
mDebug() << this->metaObject()->className() << "SHA256 check passed";
// mDebug() << this->metaObject()->className() << "SHA256 check passed";

qApp->eventDispatcher()->processEvents(QEventLoop::AllEvents);

Expand All @@ -979,12 +979,12 @@ void ReleaseVariant::onFileDownloaded(const QString &path, const QString &hash)
setStatus(FAILED_DOWNLOAD);
return;
} else {
mDebug() << this->metaObject()->className() << "MD5 check passed";
// mDebug() << this->metaObject()->className() << "MD5 check passed";
QString finalFilename(path);
finalFilename = finalFilename.replace(QRegularExpression("[.]part$"), "");

if (finalFilename != path) {
mDebug() << this->metaObject()->className() << "Renaming from" << path << "to" << finalFilename;
// mDebug() << this->metaObject()->className() << "Renaming from" << path << "to" << finalFilename;
if (!QFile::rename(path, finalFilename)) {
setErrorString(tr("Unable to rename the temporary file."));
setStatus(FAILED_DOWNLOAD);
Expand All @@ -995,7 +995,7 @@ void ReleaseVariant::onFileDownloaded(const QString &path, const QString &hash)
m_iso = finalFilename;
emit isoChanged();

mDebug() << this->metaObject()->className() << "Image is ready";
// mDebug() << this->metaObject()->className() << "Image is ready";
setStatus(READY);

if (QFile(m_iso).size() != m_size) {
Expand Down Expand Up @@ -1039,7 +1039,7 @@ void ReleaseVariant::download()
m_iso = ret;
emit isoChanged();

mDebug() << this->metaObject()->className() << m_iso << "is already downloaded";
// mDebug() << this->metaObject()->className() << m_iso << "is already downloaded";
setStatus(READY);

if (QFile(m_iso).size() != m_size) {
Expand Down Expand Up @@ -1068,7 +1068,7 @@ void ReleaseVariant::resetStatus()
bool ReleaseVariant::erase()
{
if (QFile(m_iso).remove()) {
mDebug() << this->metaObject()->className() << "Deleted" << m_iso;
// mDebug() << this->metaObject()->className() << "Deleted" << m_iso;
m_iso = QString();
emit isoChanged();
return true;
Expand Down
2 changes: 1 addition & 1 deletion src/helper/win/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ add_executable(helper ${HELPER_SRCS})
# HACK: we need to remove -std=c++11 definition for manifest file, otherwise
# it will complain about undefined option "s" (as first letter from -Std=c++11)
remove_definitions(-std=c++17)
target_sources(helper PRIVATE helper.exe.rc)
#target_sources(helper PRIVATE helper.exe.rc)

target_link_libraries(helper
Qt6::Core
Expand Down

0 comments on commit 346aa26

Please sign in to comment.