Pack downloader a bit better now

This commit is contained in:
Digital Artifex
2026-08-20 14:14:22 -04:00
parent d60cdef637
commit 1aaff0cd02
4 changed files with 450 additions and 275 deletions
+70 -22
View File
@@ -387,20 +387,29 @@ auto DownloadManager::downloadPack(const QString &id) -> void
)
.onFailed
(
[this, tempFile] (const NetworkException &e)
[this, tempFile] (const std::filesystem::filesystem_error &e)
{
QFile::remove(QStringLiteral("/tmp/") + tempFile);
reset();
setError(QStringLiteral("Network Exception %1").arg(QString::number(e.errorCode)), e.message);
setError(QStringLiteral("Network Exception %1").arg(QString::number(e.code().value())), e.what());
}
)
.onFailed
(
[this, tempFile] (const FileException &e)
[this, tempFile] (const std::logic_error &e)
{
QFile::remove(QStringLiteral("/tmp/") + tempFile);
reset();
setError(QStringLiteral("File Exception %1").arg(QString::number(e.errorCode)), e.message);
setError(QStringLiteral("Logic Exception %1"), e.what());
}
)
.onFailed
(
[this, tempFile] (const std::exception &e)
{
QFile::remove(QStringLiteral("/tmp/") + tempFile);
reset();
setError(QStringLiteral("Logic Exception %1"), e.what());
}
)
.onFailed
@@ -501,10 +510,7 @@ auto DownloadManager::setDownloadProgress(qreal progress) -> void
auto DownloadManager::install(const QUrl &uri) noexcept(false) -> QUrl
{
if(!uri.isLocalFile())
{
throw FileException(QStringLiteral("URI is not a local file"));
}
validateUri(uri);
QDir tempDirectory(uri.toLocalFile());
@@ -633,7 +639,7 @@ auto DownloadManager::download(const QNetworkRequest &request, const QString &id
reply,
&QNetworkReply::readyRead,
this,
[this, downloadUri/*, reply, &downloadFile*/]()
[this, downloadUri]()
{
QMutexLocker locker(&m_fileMutex);
QFile downloadFile(downloadUri.toLocalFile());
@@ -647,9 +653,14 @@ auto DownloadManager::download(const QNetworkRequest &request, const QString &id
if(reply == nullptr)
{
throw NetworkException
throw std::system_error
{
QStringLiteral("Reply is not a qobject")
std::error_code
(
ENOENT,
std::system_category()
),
QStringLiteral("Reply is not a qobject").toStdString()
};
}
@@ -681,29 +692,61 @@ auto DownloadManager::download(const QNetworkRequest &request, const QString &id
);
}
auto DownloadManager::validateUri(const QUrl &uri) noexcept(false) -> void
{
if(!uri.isValid() || !uri.isLocalFile())
{
throw std::filesystem::filesystem_error
(
QStringLiteral("URI %1 is not a local file uri").arg
(
uri.toString()
).toStdString(),
std::error_code
(
ENOENT,
std::system_category()
)
);
}
}
auto DownloadManager::readShaderToyEntry(const QUrl &uri) noexcept(false) -> ShaderToyEntry
{
if(!uri.isLocalFile())
{
throw FileException(QStringLiteral("URI is not a local file"));
}
validateUri(uri);
QDir packDir(uri.toLocalFile());
if(!packDir.exists(QStringLiteral("pack.json")))
{
throw FileException(QStringLiteral("Pack file not found"));
throw std::filesystem::filesystem_error
(
QStringLiteral("Pack file not found").arg
(
uri.toString()
).toStdString(),
std::error_code
(
ENOENT,
std::system_category()
)
);
}
QFile packFile(packDir.absoluteFilePath(QStringLiteral("pack.json")));
if(!packFile.open(QFile::ReadOnly))
{
throw FileException
throw std::filesystem::filesystem_error
(
QStringLiteral("Could not open pack file: %1").arg
QStringLiteral("Could not open pack file").arg
(
packFile.errorString()
uri.toString()
).toStdString(),
std::error_code
(
errno,
std::system_category()
)
);
}
@@ -715,11 +758,16 @@ auto DownloadManager::readShaderToyEntry(const QUrl &uri) noexcept(false) -> Sha
if(jsonError.error != QJsonParseError::NoError)
{
throw FileException
throw std::filesystem::filesystem_error
(
QStringLiteral("Could parse pack file: %1").arg
QStringLiteral("URI %1 is not a local file uri").arg
(
jsonError.errorString()
uri.toString()
).toStdString(),
std::error_code
(
EIO,
std::system_category()
)
);
}
+1
View File
@@ -145,6 +145,7 @@ private:
auto install(const QUrl &uri) noexcept(false) -> QUrl;
auto download(const QNetworkRequest &request, const QString &id, RequestType type = Get, const QString &filename = QString()) -> QFuture<QUrl>;
auto readShaderToyEntry(const QUrl &uri) noexcept(false) -> ShaderToyEntry;
auto validateUri(const QUrl &uri) noexcept(false) -> void;
QString m_lastInstalledFile;
+378 -253
View File
@@ -60,15 +60,6 @@ auto PackCompiler::process(const QUrl &uri) -> QFuture<QUrl>
setStatus(QStringLiteral("Compiling %1").arg(uri.fileName()));
setState(Compiling);
// this was a leftover from ThumbnailGenerator
// if(!validateDirectory(uri))
// {
// throw FileException
// (
// QStringLiteral("Source directory is invalid")
// );
// }
QFileInfo info(uri.toLocalFile());
QUrl buildUri;
@@ -79,21 +70,29 @@ auto PackCompiler::process(const QUrl &uri) -> QFuture<QUrl>
prepareShaders(buildUri);
compile(buildUri);
}
catch (FileException e)
catch (const std::filesystem::filesystem_error &e)
{
removeDirectory(buildUri);
setError(QStringLiteral("File Error"), e.message);
setError(QStringLiteral("File Error"), e.what());
throw e;
}
catch (ShaderCompilerException e)
catch (const std::logic_error &e)
{
removeDirectory(buildUri);
setError(QStringLiteral("Compiler Error"), e.message);
setError(QStringLiteral("Compiler Error"), e.what());
throw e;
}
catch (const std::exception &e)
{
removeDirectory(buildUri);
setError(QStringLiteral("Generic Error"), e.what());
throw e;
}
catch (...)
{
removeDirectory(buildUri);
setError(QStringLiteral("Unknown Error"), QString());
throw std::exception();
}
return buildUri;
@@ -105,11 +104,16 @@ auto PackCompiler::prepareShaders(const QUrl &uri) noexcept(false) -> void
{
if(!uri.isLocalFile())
{
throw FileException
throw std::filesystem::filesystem_error
(
QStringLiteral("URI %1 is not a local file uri").arg
(
uri.toString()
).toStdString(),
std::error_code
(
ENOENT,
std::system_category()
)
);
}
@@ -172,11 +176,16 @@ auto PackCompiler::prepareShaders(const QUrl &uri) noexcept(false) -> void
if(!file.open(QFile::ReadWrite))
{
throw FileException
throw std::filesystem::filesystem_error
(
QStringLiteral("Could not open file %1 for preperation").arg
(
shaderDirectory.absoluteFilePath(entry)
).toStdString(),
std::error_code
(
errno,
std::system_category()
)
);
}
@@ -185,11 +194,16 @@ auto PackCompiler::prepareShaders(const QUrl &uri) noexcept(false) -> void
if(fileData.length() != file.size())
{
throw FileException
throw std::filesystem::filesystem_error
(
QStringLiteral("Could not read file %1 for preperation").arg
(
shaderDirectory.absoluteFilePath(entry)
).toStdString(),
std::error_code
(
EIO,
std::system_category()
)
);
}
@@ -208,12 +222,12 @@ auto PackCompiler::prepareShaders(const QUrl &uri) noexcept(false) -> void
}
else
{
throw FileException
throw std::logic_error
(
QStringLiteral("File %1 is an unrecognized shader type (frag/vert)").arg
(
shaderDirectory.absoluteFilePath(entry)
)
).toStdString()
);
}
@@ -244,22 +258,32 @@ auto PackCompiler::prepareShaders(const QUrl &uri) noexcept(false) -> void
if(!file.open(QFile::ReadWrite | QFile::Truncate))
{
throw FileException
throw std::filesystem::filesystem_error
(
QStringLiteral("Could not open file %1 for writing preperation").arg
(
shaderDirectory.absoluteFilePath(entry)
).toStdString(),
std::error_code
(
errno,
std::system_category()
)
);
}
if(file.write(preparedData) != preparedData.length())
{
throw FileException
throw std::filesystem::filesystem_error
(
QStringLiteral("Could not write file %1 preperation").arg
(
shaderDirectory.absoluteFilePath(entry)
).toStdString(),
std::error_code
(
errno,
std::system_category()
)
);
}
@@ -271,16 +295,7 @@ auto PackCompiler::prepareShaders(const QUrl &uri) noexcept(false) -> void
auto PackCompiler::loadCommonFragmentData(const QUrl &uri) -> QByteArray
{
if(!uri.isLocalFile())
{
throw FileException
(
QStringLiteral("URI %1 is not a local file uri").arg
(
uri.toString()
)
);
}
localCheck(uri);
QDir sourceDirectory
(
@@ -308,14 +323,30 @@ auto PackCompiler::loadCommonFragmentData(const QUrl &uri) -> QByteArray
if(!file.open(QFile::ReadWrite))
{
throw FileException(QStringLiteral("Could not open common shader data"));
throw std::filesystem::filesystem_error
(
QStringLiteral("Could not open common shader data").toStdString(),
std::error_code
(
errno,
std::system_category()
)
);
}
data = file.readAll();
if(data.length() != file.size())
{
throw FileException(QStringLiteral("Common fragment shader file read error"));
throw std::filesystem::filesystem_error
(
QStringLiteral("Common file read error").toStdString(),
std::error_code
(
errno,
std::system_category()
)
);
}
file.close();
@@ -327,16 +358,7 @@ auto PackCompiler::loadCommonFragmentData(const QUrl &uri) -> QByteArray
auto PackCompiler::loadCommonVertexData(const QUrl &uri) -> QByteArray
{
if(!uri.isLocalFile())
{
throw FileException
(
QStringLiteral("URI %1 is not a local file uri").arg
(
uri.toString()
)
);
}
localCheck(uri);
QDir sourceDirectory
(
@@ -364,14 +386,30 @@ auto PackCompiler::loadCommonVertexData(const QUrl &uri) -> QByteArray
if(!file.open(QFile::ReadWrite))
{
throw FileException(QStringLiteral("Could not open common vertex shader data"));
throw std::filesystem::filesystem_error
(
QStringLiteral("Common vertex file open error").toStdString(),
std::error_code
(
errno,
std::system_category()
)
);
}
data = file.readAll();
if(data.length() != file.size())
{
throw FileException(QStringLiteral("Common vertex shader file read error"));
throw std::filesystem::filesystem_error
(
QStringLiteral("Common vertex file read error").toStdString(),
std::error_code
(
EIO,
std::system_category()
)
);
}
file.close();
@@ -383,16 +421,7 @@ auto PackCompiler::loadCommonVertexData(const QUrl &uri) -> QByteArray
auto PackCompiler::loadGlobalData(const QUrl &uri) -> QByteArray
{
if(!uri.isLocalFile())
{
throw FileException
(
QStringLiteral("URI %1 is not a local file uri").arg
(
uri.toString()
)
);
}
localCheck(uri);
QDir sourceDirectory
(
@@ -420,9 +449,14 @@ auto PackCompiler::loadGlobalData(const QUrl &uri) -> QByteArray
if(!file.open(QFile::ReadWrite))
{
throw FileException
throw std::filesystem::filesystem_error
(
QStringLiteral("Could not open global shader data")
QStringLiteral("Common global file open error").toStdString(),
std::error_code
(
errno,
std::system_category()
)
);
}
@@ -430,9 +464,9 @@ auto PackCompiler::loadGlobalData(const QUrl &uri) -> QByteArray
if(data.length() != file.size())
{
throw FileException
throw std::underflow_error
(
QStringLiteral("Global shader file read error")
QStringLiteral("Common vertex file read error").toStdString()
);
}
@@ -456,10 +490,7 @@ auto PackCompiler::validateDirectory(const QUrl &uri) -> bool
auto PackCompiler::createDirectory(const QUrl &uri) -> void
{
if(!uri.isLocalFile() || !uri.isValid())
{
throw FileException(QStringLiteral("Uri needs to be a local file"), 0);
}
localCheck(uri);
QStringList arguments =
{
@@ -467,68 +498,103 @@ auto PackCompiler::createDirectory(const QUrl &uri) -> void
uri.toLocalFile()
};
QProcess *process = new QProcess(this);
QProcess process;
QObject::connect
(
process,
&QProcess::readyReadStandardOutput,
this,
[this, process]()
{
QByteArray processData = process->readAllStandardOutput();
setCompilerOutput(m_compilerOutput + processData);
}
);
// QObject::connect
// (
// &process,
// &QProcess::readyReadStandardOutput,
// this,
// [this, &process]()
// {
// QByteArray processData = process.readAllStandardOutput();
// setCompilerOutput(m_compilerOutput + processData);
// }
// );
QObject::connect
(
process,
&QProcess::readyReadStandardError,
this,
[this, process]()
{
QByteArray processData = process->readAllStandardError();
// QObject::connect
// (
// &process,
// &QProcess::readyReadStandardError,
// this,
// [this, &process]()
// {
// QByteArray processData = process.readAllStandardError();
if(!processData.isValidUtf8())
{
qWarning() << QStringLiteral("Process output not valid UTF8 data");
return;
}
// if(!processData.isValidUtf8())
// {
// qWarning() << QStringLiteral("Process output not valid UTF8 data");
// return;
// }
setCompilerOutput(m_compilerOutput + processData);
}
);
// setCompilerOutput(m_compilerOutput + processData);
// }
// );
process->start(QStringLiteral("mkdir"), arguments);
process.start(QStringLiteral("mkdir"), arguments);
if(!process->waitForStarted(3000))
if(!process.waitForStarted(3000))
{
process->deleteLater();
throw FileException(QStringLiteral("Could not start preprocessor"));
throw std::filesystem::filesystem_error
(
QStringLiteral("Could not start process for create directory").toStdString(),
std::error_code
(
errno,
std::system_category()
)
);
}
if(!process->waitForFinished())
if(!process.waitForFinished())
{
process->deleteLater();
throw FileException(QStringLiteral("Preprocessor timeout"));
throw std::filesystem::filesystem_error
(
QStringLiteral("Process timeout for create directory").toStdString(),
std::error_code
(
errno,
std::system_category()
)
);
}
if(process->exitCode() != 0)
if(process.exitCode() != 0)
{
process->deleteLater();
throw ShaderCompilerException(m_compilerOutput);
throw std::ios_base::failure
(
QStringLiteral("Process exited abnormally").toStdString(),
std::error_code
(
process.exitCode(),
std::system_category()
)
);
}
}
process->deleteLater();
auto PackCompiler::localCheck(const QUrl &uri) noexcept(false) -> void
{
if(!uri.isValid() || !uri.isLocalFile())
{
throw std::filesystem::filesystem_error
(
QStringLiteral("URI %1 is not a local file uri").arg
(
uri.toString()
).toStdString(),
std::error_code
(
ENOENT,
std::system_category()
)
);
}
}
auto PackCompiler::extract(const QUrl &sourceUri) noexcept(false) -> QUrl
{
if(!sourceUri.isLocalFile() || !sourceUri.isValid())
{
throw FileException(QStringLiteral("Uri needs to be a local file"), 0);
}
localCheck(sourceUri);
QFileInfo info(sourceUri.toLocalFile());
@@ -555,61 +621,83 @@ auto PackCompiler::extract(const QUrl &sourceUri) noexcept(false) -> QUrl
createDirectory(outputUri);
}
QProcess *process = new QProcess(this);
QProcess process;
QObject::connect
(
process,
&QProcess::readyReadStandardOutput,
this,
[this, process]()
{
QByteArray processData = process->readAllStandardOutput();
setCompilerOutput(m_compilerOutput + processData);
}
);
// QObject::connect
// (
// &process,
// &QProcess::readyReadStandardOutput,
// this,
// [this, &process]()
// {
// QByteArray processData = process.readAllStandardOutput();
// setCompilerOutput(m_compilerOutput + processData);
// }
// );
QObject::connect
(
process,
&QProcess::readyReadStandardError,
this,
[this, process]()
{
QByteArray processData = process->readAllStandardError();
// QObject::connect
// (
// &process,
// &QProcess::readyReadStandardError,
// this,
// [this, &process]()
// {
// QByteArray processData = process.readAllStandardError();
if(!processData.isValidUtf8())
{
qWarning() << QStringLiteral("Process output not valid UTF8 data");
return;
}
// if(!processData.isValidUtf8())
// {
// qWarning() << QStringLiteral("Process output not valid UTF8 data");
// return;
// }
setCompilerOutput(m_compilerOutput + processData);
}
);
// setCompilerOutput(m_compilerOutput + processData);
// }
// );
process->start(QStringLiteral("tar"), arguments);
process.start(QStringLiteral("tar"), arguments);
if(!process->waitForStarted(3000))
if(!process.waitForStarted(3000))
{
process->deleteLater();
throw FileException(QStringLiteral("Could not start preprocessor"));
throw std::filesystem::filesystem_error
(
QStringLiteral("Could not start process for extract").toStdString(),
std::error_code
(
errno,
std::system_category()
)
);
}
if(!process->waitForFinished())
if(!process.waitForFinished())
{
process->deleteLater();
throw FileException(QStringLiteral("Preprocessor timeout"));
throw std::filesystem::filesystem_error
(
QStringLiteral("Process timeout for extract").toStdString(),
std::error_code
(
errno,
std::system_category()
)
);
}
if(process->exitCode() != 0)
if(process.exitCode() != 0)
{
process->deleteLater();
throw ShaderCompilerException(m_compilerOutput);
throw std::ios_base::failure
(
QStringLiteral("Extract process exited abnormally: %1").arg
(
process.readAllStandardError()
).toStdString(),
std::error_code
(
process.exitCode(),
std::system_category()
)
);
}
process->deleteLater();
QFile::remove(sourceUri.toLocalFile());
return outputUri;
@@ -630,10 +718,7 @@ auto PackCompiler::copyFile(const QUrl &sourceUri, const QUrl &destinationUri) n
auto PackCompiler::compile(const QUrl &uri) noexcept(false) -> void
{
if(!uri.isLocalFile() || !uri.isValid())
{
throw FileException(QStringLiteral("Uri needs to be a local file"), 0);
}
localCheck(uri);
setState(Compiling);
@@ -704,77 +789,101 @@ auto PackCompiler::preprocess(const QUrl &uri) noexcept(false) -> void
outputUri.toLocalFile()
};
QProcess *process = new QProcess(this);
QProcess process;
QObject::connect
(
process,
&QProcess::readyReadStandardOutput,
this,
[this, process]()
{
QByteArray processData = process->readAllStandardOutput();
setCompilerOutput(m_compilerOutput + processData);
}
);
// QObject::connect
// (
// &process,
// &QProcess::readyReadStandardOutput,
// this,
// [this, &process]()
// {
// QByteArray processData = process.readAllStandardOutput();
// setCompilerOutput(m_compilerOutput + processData);
// }
// );
QObject::connect
(
process,
&QProcess::readyReadStandardError,
this,
[this, process]()
{
QByteArray processData = process->readAllStandardError();
// QObject::connect
// (
// &process,
// &QProcess::readyReadStandardError,
// this,
// [this, &process]()
// {
// QByteArray processData = process.readAllStandardError();
if(!processData.isValidUtf8())
{
qWarning() << QStringLiteral("Process output not valid UTF8 data");
return;
}
// if(!processData.isValidUtf8())
// {
// qWarning() << QStringLiteral("Process output not valid UTF8 data");
// return;
// }
setCompilerOutput(m_compilerOutput + processData);
}
);
// setCompilerOutput(m_compilerOutput + processData);
// }
// );
process->start(QStringLiteral("cpp"), arguments);
process.start(QStringLiteral("cpp"), arguments);
if(!process->waitForStarted(3000))
if(!process.waitForStarted(3000))
{
process->deleteLater();
throw FileException(QStringLiteral("Could not start preprocessor"));
throw std::filesystem::filesystem_error
(
QStringLiteral("Could not start preprocessor").toStdString(),
std::error_code
(
errno,
std::system_category()
)
);
}
if(!process->waitForFinished())
if(!process.waitForFinished())
{
process->deleteLater();
throw FileException(QStringLiteral("Preprocessor timeout"));
throw std::filesystem::filesystem_error
(
QStringLiteral("Process timeout for preprocessor").toStdString(),
std::error_code
(
errno,
std::system_category()
)
);
}
if(process->exitCode() != 0)
if(process.exitCode() != 0)
{
process->deleteLater();
throw ShaderCompilerException(m_compilerOutput);
throw std::ios_base::failure
(
QStringLiteral("Preprocessor exited abnormally").toStdString(),
std::error_code
(
process.exitCode(),
std::system_category()
)
);
}
process->deleteLater();
QFile::remove(uri.toLocalFile());
QFile::rename(outputUri.toLocalFile(), uri.toLocalFile());
}
auto PackCompiler::appendVersion(const QUrl &uri) noexcept(false) -> void
{
if(!uri.isValid() || !uri.isLocalFile())
{
throw FileException(QStringLiteral("File is not a valid local file"));
}
localCheck(uri);
QFile file(uri.toLocalFile());
if(!file.open(QFile::ReadWrite))
{
throw FileException(QStringLiteral("Could not open file for appending"));
throw std::filesystem::filesystem_error
(
QStringLiteral("Could not open file for appending").toStdString(),
std::error_code
(
errno,
std::system_category()
)
);
}
QByteArray data = file.readAll();
@@ -790,13 +899,7 @@ auto PackCompiler::appendVersion(const QUrl &uri) noexcept(false) -> void
auto PackCompiler::compileShader(const QUrl &uri) noexcept(false) -> void
{
if(!uri.isLocalFile())
{
throw FileException
(
QStringLiteral("Uri needs to be a local file")
);
}
localCheck(uri);
QString qsb = QStringLiteral("/usr/lib/qt6/bin/qsb");
@@ -822,66 +925,93 @@ auto PackCompiler::compileShader(const QUrl &uri) noexcept(false) -> void
uri.toLocalFile()
};
QProcess *process = new QProcess(this);
QProcess process;
QString path = uri.toDisplayString(QUrl::RemoveFilename | QUrl::RemoveScheme).remove(QStringLiteral("//"));
process->setWorkingDirectory(path);
process.setWorkingDirectory(path);
QObject::connect
(
process,
&QProcess::readyReadStandardOutput,
this,
[this, process]()
{
QByteArray processData = process->readAllStandardOutput();
setCompilerOutput(m_compilerOutput + processData);
}
);
// QObject::connect
// (
// &process,
// &QProcess::readyReadStandardOutput,
// this,
// [this, &process]()
// {
// QByteArray processData = process.readAllStandardOutput();
// setCompilerOutput(m_compilerOutput + processData);
// }
// );
QObject::connect
(
process,
&QProcess::readyReadStandardError,
this,
[this, process]()
{
QByteArray processData = process->readAllStandardError();
// QObject::connect
// (
// &process,
// &QProcess::readyReadStandardError,
// this,
// [this, &process]()
// {
// QByteArray processData = process.readAllStandardError();
if(!processData.isValidUtf8())
{
qWarning() << QStringLiteral("Process output not valid UTF8 data");
return;
}
// if(!processData.isValidUtf8())
// {
// qWarning() << QStringLiteral("Process output not valid UTF8 data");
// return;
// }
setCompilerOutput(m_compilerOutput + processData);
}
);
// setCompilerOutput(m_compilerOutput + processData);
// }
// );
process->start(qsb, arguments);
process.start(qsb, arguments);
if(!process->waitForStarted(3000))
if(!process.waitForStarted(3000))
{
process->deleteLater();
throw FileException(QStringLiteral("Could not start shader compiler"));
throw std::filesystem::filesystem_error
(
QStringLiteral("Could not start preprocessor").toStdString(),
std::error_code
(
errno,
std::system_category()
)
);
}
if(!process->waitForFinished())
if(!process.waitForFinished())
{
process->deleteLater();
throw FileException(QStringLiteral("Shader compiler timeout"));
throw std::filesystem::filesystem_error
(
QStringLiteral("Process timeout for preprocessor").toStdString(),
std::error_code
(
errno,
std::system_category()
)
);
}
if(process->exitCode() != 0)
if(process.exitCode() != 0)
{
process->deleteLater();
throw ShaderCompilerException(m_compilerOutput);
throw std::ios_base::failure
(
QStringLiteral("Preprocessor exited abnormally").toStdString(),
std::error_code
(
process.exitCode(),
std::system_category()
)
);
}
process->deleteLater();
if(!QFile::remove(uri.toLocalFile()))
{
throw FileException(QStringLiteral("Could not clean up"));
throw std::filesystem::filesystem_error
(
QStringLiteral("Could not cleanup").toStdString(),
std::error_code
(
errno,
std::system_category()
)
);
}
}
@@ -893,29 +1023,24 @@ auto PackCompiler::removeDirectory(const QUrl &uri) -> bool
uri.toLocalFile()
};
QProcess *process = new QProcess(this);
QProcess process;
process.start(QStringLiteral("rm"), arguments);
process->start(QStringLiteral("rm"), arguments);
if(!process->waitForStarted(3000))
if(!process.waitForStarted(3000))
{
process->deleteLater();
return false;
}
if(!process->waitForFinished())
if(!process.waitForFinished())
{
process->deleteLater();
return false;
}
if(process->exitCode() != 0)
if(process.exitCode() != 0)
{
process->deleteLater();
return false;
}
process->deleteLater();
return true;
}
+1
View File
@@ -114,6 +114,7 @@ protected:
auto createDirectory(const QUrl &uri) -> void;
auto localCheck(const QUrl &uri) noexcept(false) -> void;
auto extract(const QUrl &sourceUri) noexcept(false) -> QUrl;
auto copyFile(const QUrl &sourceUri, const QUrl &destinationUri) noexcept(false) -> void;
auto compile(const QUrl &uri) noexcept(false) -> void;