use fs::move instead of qt rename

Signed-off-by: Trial97 <alexandru.tripon97@gmail.com>
This commit is contained in:
Trial97 2023-11-04 16:49:35 +02:00
parent 79e299123c
commit 5afe6600ee
No known key found for this signature in database
GPG Key ID: 55EF5DA53DB36318
5 changed files with 7 additions and 9 deletions

View File

@ -652,8 +652,7 @@ bool move(const QString& source, const QString& dest)
if (err) { if (err) {
qWarning() << "Failed to move file:" << QString::fromStdString(err.message()); qWarning() << "Failed to move file:" << QString::fromStdString(err.message());
qDebug() << "Source file:" << source; qDebug() << "Source file:" << source << ";Destination file:" << dest;
qDebug() << "Destination file:" << dest;
} }
return err.value() == 0; return err.value() == 0;

View File

@ -953,7 +953,6 @@ bool InstanceList::commitStagedInstance(const QString& path,
if (groupName.isEmpty() && !groupName.isNull()) if (groupName.isEmpty() && !groupName.isNull())
groupName = QString(); groupName = QString();
QDir dir;
QString instID; QString instID;
InstancePtr inst; InstancePtr inst;
@ -977,7 +976,7 @@ bool InstanceList::commitStagedInstance(const QString& path,
return false; return false;
} }
} else { } else {
if (!dir.rename(path, destination)) { if (!FS::move(path, destination)) {
qWarning() << "Failed to move" << path << "to" << destination; qWarning() << "Failed to move" << path << "to" << destination;
return false; return false;
} }

View File

@ -321,7 +321,7 @@ bool FlameCreationTask::createInstance()
// Keep index file in case we need it some other time (like when changing versions) // Keep index file in case we need it some other time (like when changing versions)
QString new_index_place(FS::PathCombine(parent_folder, "manifest.json")); QString new_index_place(FS::PathCombine(parent_folder, "manifest.json"));
FS::ensureFilePathExists(new_index_place); FS::ensureFilePathExists(new_index_place);
QFile::rename(index_path, new_index_place); FS::move(index_path, new_index_place);
} catch (const JSONValidationError& e) { } catch (const JSONValidationError& e) {
setError(tr("Could not understand pack manifest:\n") + e.cause()); setError(tr("Could not understand pack manifest:\n") + e.cause());
@ -335,7 +335,7 @@ bool FlameCreationTask::createInstance()
Override::createOverrides("overrides", parent_folder, overridePath); Override::createOverrides("overrides", parent_folder, overridePath);
QString mcPath = FS::PathCombine(m_stagingPath, "minecraft"); QString mcPath = FS::PathCombine(m_stagingPath, "minecraft");
if (!QFile::rename(overridePath, mcPath)) { if (!FS::move(overridePath, mcPath)) {
setError(tr("Could not rename the overrides folder:\n") + m_pack.overrides); setError(tr("Could not rename the overrides folder:\n") + m_pack.overrides);
return false; return false;
} }

View File

@ -137,7 +137,7 @@ void PackInstallTask::install()
QDir unzipMcDir(m_stagingPath + "/unzip/minecraft"); QDir unzipMcDir(m_stagingPath + "/unzip/minecraft");
if (unzipMcDir.exists()) { if (unzipMcDir.exists()) {
// ok, found minecraft dir, move contents to instance dir // ok, found minecraft dir, move contents to instance dir
if (!QDir().rename(m_stagingPath + "/unzip/minecraft", m_stagingPath + "/.minecraft")) { if (!FS::move(m_stagingPath + "/unzip/minecraft", m_stagingPath + "/.minecraft")) {
emitFailed(tr("Failed to move unzipped Minecraft!")); emitFailed(tr("Failed to move unzipped Minecraft!"));
return; return;
} }

View File

@ -171,7 +171,7 @@ bool ModrinthCreationTask::createInstance()
// Keep index file in case we need it some other time (like when changing versions) // Keep index file in case we need it some other time (like when changing versions)
QString new_index_place(FS::PathCombine(parent_folder, "modrinth.index.json")); QString new_index_place(FS::PathCombine(parent_folder, "modrinth.index.json"));
FS::ensureFilePathExists(new_index_place); FS::ensureFilePathExists(new_index_place);
QFile::rename(index_path, new_index_place); FS::move(index_path, new_index_place);
auto mcPath = FS::PathCombine(m_stagingPath, ".minecraft"); auto mcPath = FS::PathCombine(m_stagingPath, ".minecraft");
@ -181,7 +181,7 @@ bool ModrinthCreationTask::createInstance()
Override::createOverrides("overrides", parent_folder, override_path); Override::createOverrides("overrides", parent_folder, override_path);
// Apply the overrides // Apply the overrides
if (!QFile::rename(override_path, mcPath)) { if (!FS::move(override_path, mcPath)) {
setError(tr("Could not rename the overrides folder:\n") + "overrides"); setError(tr("Could not rename the overrides folder:\n") + "overrides");
return false; return false;
} }