fix: clean up initial review comments (flowin)

Signed-off-by: Rachel Powers <508861+Ryex@users.noreply.github.com>
This commit is contained in:
Rachel Powers 2023-02-22 17:40:07 -07:00
parent e0ef86340f
commit ae289c923c
5 changed files with 84 additions and 82 deletions

View File

@ -36,10 +36,6 @@
*/ */
#include "FileSystem.h" #include "FileSystem.h"
#include <qdebug.h>
#include <qfileinfo.h>
#include <qnamespace.h>
#include <qstorageinfo.h>
#include "BuildConfig.h" #include "BuildConfig.h"
@ -48,6 +44,7 @@
#include <QDirIterator> #include <QDirIterator>
#include <QFile> #include <QFile>
#include <QFileInfo> #include <QFileInfo>
#include <QStorageInfo>
#include <QSaveFile> #include <QSaveFile>
#include <QStandardPaths> #include <QStandardPaths>
#include <QTextStream> #include <QTextStream>
@ -435,7 +432,7 @@ bool create_link::make_links()
return true; return true;
} }
void create_link::runPrivlaged(const QString& offset) void create_link::runPrivileged(const QString& offset)
{ {
m_linked = 0; // reset counter m_linked = 0; // reset counter
m_path_results.clear(); m_path_results.clear();
@ -506,10 +503,10 @@ void create_link::runPrivlaged(const QString& offset)
in >> err_value; in >> err_value;
result.err_value = err_value; result.err_value = err_value;
if (result.err_value) { if (result.err_value) {
qDebug() << "privlaged link fail" << result.src << "to" << result.dst << "code" << result.err_value << result.err_msg; qDebug() << "privileged link fail" << result.src << "to" << result.dst << "code" << result.err_value << result.err_msg;
emit linkFailed(result.src, result.dst, result.err_msg, result.err_value); emit linkFailed(result.src, result.dst, result.err_msg, result.err_value);
} else { } else {
qDebug() << "privlaged link success" << result.src << "to" << result.dst; qDebug() << "privileged link success" << result.src << "to" << result.dst;
m_linked++; m_linked++;
emit fileLinked(result.src, result.dst); emit fileLinked(result.src, result.dst);
} }
@ -533,7 +530,7 @@ void create_link::runPrivlaged(const QString& offset)
} }
ExternalLinkFileProcess* linkFileProcess = new ExternalLinkFileProcess(serverName, m_useHardLinks, this); ExternalLinkFileProcess* linkFileProcess = new ExternalLinkFileProcess(serverName, m_useHardLinks, this);
connect(linkFileProcess, &ExternalLinkFileProcess::processExited, this, [&]() { emit finishedPrivlaged(gotResults); }); connect(linkFileProcess, &ExternalLinkFileProcess::processExited, this, [&]() { emit finishedPrivileged(gotResults); });
connect(linkFileProcess, &ExternalLinkFileProcess::finished, linkFileProcess, &QObject::deleteLater); connect(linkFileProcess, &ExternalLinkFileProcess::finished, linkFileProcess, &QObject::deleteLater);
linkFileProcess->start(); linkFileProcess->start();
@ -1041,7 +1038,7 @@ FilesystemInfo statFS(const QString& path)
QStorageInfo storage_info(NearestExistentAncestor(path)); QStorageInfo storage_info(NearestExistentAncestor(path));
info.fsTypeName = QString::fromStdString(storage_info.fileSystemType().toStdString()); info.fsTypeName = storage_info.fileSystemType();
info.fsType = getFilesystemTypeFuzzy(info.fsTypeName); info.fsType = getFilesystemTypeFuzzy(info.fsTypeName);

View File

@ -220,8 +220,8 @@ class create_link : public QObject {
int totalLinked() { return m_linked; } int totalLinked() { return m_linked; }
void runPrivlaged() { runPrivlaged(QString()); } void runPrivileged() { runPrivileged(QString()); }
void runPrivlaged(const QString& offset); void runPrivileged(const QString& offset);
QList<LinkResult> getResults() { return m_path_results; } QList<LinkResult> getResults() { return m_path_results; }
@ -230,7 +230,7 @@ class create_link : public QObject {
void fileLinked(const QString& srcName, const QString& dstName); void fileLinked(const QString& srcName, const QString& dstName);
void linkFailed(const QString& srcName, const QString& dstName, const QString& err_msg, int err_value); void linkFailed(const QString& srcName, const QString& dstName, const QString& err_msg, int err_value);
void finished(); void finished();
void finishedPrivlaged(bool gotResults); void finishedPrivileged(bool gotResults);
private: private:

View File

@ -72,14 +72,14 @@ void InstanceCopyTask::executeTask()
QEventLoop loop; QEventLoop loop;
bool got_priv_results = false; bool got_priv_results = false;
connect(&folderLink, &FS::create_link::finishedPrivlaged, this, [&](bool gotResults){ connect(&folderLink, &FS::create_link::finishedPrivileged, this, [&](bool gotResults){
if (!gotResults) { if (!gotResults) {
qDebug() << "Privlaged run exited without results!"; qDebug() << "Privileged run exited without results!";
} }
got_priv_results = gotResults; got_priv_results = gotResults;
loop.quit(); loop.quit();
}); });
folderLink.runPrivlaged(); folderLink.runPrivileged();
loop.exec(); // wait for the finished signal loop.exec(); // wait for the finished signal

View File

@ -9,8 +9,8 @@
<rect> <rect>
<x>0</x> <x>0</x>
<y>0</y> <y>0</y>
<width>527</width> <width>531</width>
<height>699</height> <height>653</height>
</rect> </rect>
</property> </property>
<property name="windowTitle"> <property name="windowTitle">
@ -112,35 +112,19 @@
</item> </item>
</layout> </layout>
</item> </item>
<item>
<layout class="QHBoxLayout" name="selectAllButtonLayout">
<item>
<widget class="QCheckBox" name="selectAllCheckbox">
<property name="sizePolicy">
<sizepolicy hsizetype="Fixed" vsizetype="Fixed">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="layoutDirection">
<enum>Qt::LeftToRight</enum>
</property>
<property name="text">
<string>Select all</string>
</property>
<property name="checked">
<bool>false</bool>
</property>
</widget>
</item>
</layout>
</item>
<item> <item>
<widget class="QGroupBox" name="copyOptionsGroup"> <widget class="QGroupBox" name="copyOptionsGroup">
<property name="title"> <property name="title">
<string>Instance Copy Options</string> <string>Instance Copy Options</string>
</property> </property>
<layout class="QGridLayout" name="copyOptionsLayout"> <layout class="QGridLayout" name="copyOptionsLayout">
<item row="1" column="0">
<widget class="QCheckBox" name="keepPlaytimeCheckbox">
<property name="text">
<string>Keep play time</string>
</property>
</widget>
</item>
<item row="6" column="1"> <item row="6" column="1">
<widget class="QCheckBox" name="copyModsCheckbox"> <widget class="QCheckBox" name="copyModsCheckbox">
<property name="toolTip"> <property name="toolTip">
@ -151,6 +135,16 @@
</property> </property>
</widget> </widget>
</item> </item>
<item row="6" column="0">
<widget class="QCheckBox" name="copyResPacksCheckbox">
<property name="enabled">
<bool>true</bool>
</property>
<property name="text">
<string>Copy resource packs</string>
</property>
</widget>
</item>
<item row="5" column="0"> <item row="5" column="0">
<widget class="QCheckBox" name="copyGameOptionsCheckbox"> <widget class="QCheckBox" name="copyGameOptionsCheckbox">
<property name="toolTip"> <property name="toolTip">
@ -161,13 +155,6 @@
</property> </property>
</widget> </widget>
</item> </item>
<item row="3" column="0">
<widget class="QCheckBox" name="copySavesCheckbox">
<property name="text">
<string>Copy saves</string>
</property>
</widget>
</item>
<item row="3" column="1"> <item row="3" column="1">
<widget class="QCheckBox" name="copyShaderPacksCheckbox"> <widget class="QCheckBox" name="copyShaderPacksCheckbox">
<property name="text"> <property name="text">
@ -182,20 +169,10 @@
</property> </property>
</widget> </widget>
</item> </item>
<item row="6" column="0"> <item row="3" column="0">
<widget class="QCheckBox" name="copyResPacksCheckbox"> <widget class="QCheckBox" name="copySavesCheckbox">
<property name="enabled">
<bool>true</bool>
</property>
<property name="text"> <property name="text">
<string>Copy resource packs</string> <string>Copy saves</string>
</property>
</widget>
</item>
<item row="1" column="0">
<widget class="QCheckBox" name="keepPlaytimeCheckbox">
<property name="text">
<string>Keep play time</string>
</property> </property>
</widget> </widget>
</item> </item>
@ -206,9 +183,35 @@
</property> </property>
</widget> </widget>
</item> </item>
<item row="7" column="1">
<widget class="QCheckBox" name="selectAllCheckbox">
<property name="sizePolicy">
<sizepolicy hsizetype="Minimum" vsizetype="Fixed">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="layoutDirection">
<enum>Qt::LeftToRight</enum>
</property>
<property name="text">
<string>Select all</string>
</property>
<property name="checked">
<bool>false</bool>
</property>
</widget>
</item>
</layout> </layout>
</widget> </widget>
</item> </item>
<item>
<widget class="Line" name="line_2">
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
</widget>
</item>
<item> <item>
<widget class="QLabel" name="advancedOptionsLabel"> <widget class="QLabel" name="advancedOptionsLabel">
<property name="text"> <property name="text">
@ -250,7 +253,7 @@
</widget> </widget>
</item> </item>
<item> <item>
<layout class="QGridLayout" name="linkOptionsGridLayout" rowstretch="0,0,0,0,0,0" columnstretch="0,0" rowminimumheight="0,0,0,0,0,0" columnminimumwidth="0,0"> <layout class="QGridLayout" name="linkOptionsGridLayout" rowstretch="0,0,0,0" columnstretch="0,0" rowminimumheight="0,0,0,0" columnminimumwidth="0,0">
<property name="leftMargin"> <property name="leftMargin">
<number>6</number> <number>6</number>
</property> </property>
@ -263,24 +266,14 @@
<property name="bottomMargin"> <property name="bottomMargin">
<number>6</number> <number>6</number>
</property> </property>
<item row="3" column="0">
<widget class="QCheckBox" name="hardLinksCheckbox">
<property name="enabled">
<bool>true</bool>
</property>
<property name="toolTip">
<string>Use hard links instead of symbolic links.</string>
</property>
<property name="text">
<string>Use hard links</string>
</property>
</widget>
</item>
<item row="2" column="1"> <item row="2" column="1">
<widget class="QCheckBox" name="recursiveLinkCheckbox"> <widget class="QCheckBox" name="recursiveLinkCheckbox">
<property name="enabled"> <property name="enabled">
<bool>false</bool> <bool>false</bool>
</property> </property>
<property name="toolTip">
<string>Link each resource individually instead of linking whole folders at once</string>
</property>
<property name="text"> <property name="text">
<string>Link files recursively</string> <string>Link files recursively</string>
</property> </property>
@ -302,14 +295,27 @@
</property> </property>
</widget> </widget>
</item> </item>
<item row="2" column="0"> <item row="3" column="0">
<widget class="QCheckBox" name="symbolicLinksCheckbox"> <widget class="QCheckBox" name="hardLinksCheckbox">
<property name="text"> <property name="enabled">
<string>Use symbolic links</string> <bool>true</bool>
</property> </property>
<property name="toolTip">
<string>Use hard links instead of copying files.</string>
</property>
<property name="text">
<string>Use hard links</string>
</property>
</widget>
</item>
<item row="2" column="0">
<widget class="QCheckBox" name="symbolicLinksCheckbox">
<property name="toolTip"> <property name="toolTip">
<string>Use symbolic links instead of copying files.</string> <string>Use symbolic links instead of copying files.</string>
</property> </property>
<property name="text">
<string>Use symbolic links</string>
</property>
</widget> </widget>
</item> </item>
</layout> </layout>
@ -373,7 +379,6 @@
<tabstop>iconButton</tabstop> <tabstop>iconButton</tabstop>
<tabstop>instNameTextBox</tabstop> <tabstop>instNameTextBox</tabstop>
<tabstop>groupBox</tabstop> <tabstop>groupBox</tabstop>
<tabstop>selectAllCheckbox</tabstop>
<tabstop>keepPlaytimeCheckbox</tabstop> <tabstop>keepPlaytimeCheckbox</tabstop>
<tabstop>copyScreenshotsCheckbox</tabstop> <tabstop>copyScreenshotsCheckbox</tabstop>
<tabstop>copySavesCheckbox</tabstop> <tabstop>copySavesCheckbox</tabstop>

View File

@ -72,15 +72,15 @@ class LinkTask : public Task {
qDebug() << "EXPECTED: Link failure, Windows requires permissions for symlinks"; qDebug() << "EXPECTED: Link failure, Windows requires permissions for symlinks";
qDebug() << "atempting to run with privelage"; qDebug() << "atempting to run with privelage";
connect(m_lnk, &FS::create_link::finishedPrivlaged, this, [&](bool gotResults){ connect(m_lnk, &FS::create_link::finishedPrivileged, this, [&](bool gotResults){
if (gotResults) { if (gotResults) {
emitSucceeded(); emitSucceeded();
} else { } else {
qDebug() << "Privlaged run exited without results!"; qDebug() << "Privileged run exited without results!";
emitFailed(); emitFailed();
} }
}); });
m_lnk->runPrivlaged(); m_lnk->runPrivileged();
} else { } else {
qDebug() << "Link Failed!" << m_lnk->getOSError().value() << m_lnk->getOSError().message().c_str(); qDebug() << "Link Failed!" << m_lnk->getOSError().value() << m_lnk->getOSError().message().c_str();
} }