syncqt: Catch fs exceptions that happen when clearing staging directory
Pick-to: 6.5 Change-Id: I1617f0940e1b1d892d321fc6f5df11262ee1f288 Reviewed-by: Amir Masoud Abdol <amir.abdol@qt.io> Reviewed-by: Alexandru Croitor <alexandru.croitor@qt.io> (cherry picked from commit 9f3e7aaf17ba69a7cff81a584054978e6c283165)
This commit is contained in:
parent
606839a1f9
commit
880da41adb
@ -140,6 +140,12 @@ std::filesystem::path normilizedPath(const std::string &path)
|
|||||||
return std::filesystem::path(std::filesystem::weakly_canonical(path).generic_string());
|
return std::filesystem::path(std::filesystem::weakly_canonical(path).generic_string());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void printFilesystemError(const std::filesystem::filesystem_error &fserr, std::string_view errorMsg)
|
||||||
|
{
|
||||||
|
std::cerr << errorMsg << ": " << fserr.path1() << ".\n"
|
||||||
|
<< fserr.what() << "(" << fserr.code().value() << ")" << std::endl;
|
||||||
|
}
|
||||||
|
|
||||||
bool createDirectories(const std::string &path, std::string_view errorMsg, bool *exists = nullptr)
|
bool createDirectories(const std::string &path, std::string_view errorMsg, bool *exists = nullptr)
|
||||||
{
|
{
|
||||||
bool result = true;
|
bool result = true;
|
||||||
@ -740,26 +746,31 @@ public:
|
|||||||
return false;
|
return false;
|
||||||
|
|
||||||
if (outDirExists && !skipCleanup) {
|
if (outDirExists && !skipCleanup) {
|
||||||
for (const auto &entry :
|
try {
|
||||||
std::filesystem::recursive_directory_iterator(outputDirectory)) {
|
for (const auto &entry :
|
||||||
if (m_producedHeaders.find(entry.path().filename().generic_string())
|
std::filesystem::recursive_directory_iterator(outputDirectory)) {
|
||||||
== m_producedHeaders.end()) {
|
if (m_producedHeaders.find(entry.path().filename().generic_string())
|
||||||
// Check if header file came from another module as result of the cross-module
|
== m_producedHeaders.end()) {
|
||||||
// deprecation before removing it.
|
// Check if header file came from another module as result of the
|
||||||
std::string firstLine;
|
// cross-module deprecation before removing it.
|
||||||
{
|
std::string firstLine;
|
||||||
std::ifstream input(entry.path(), std::ifstream::in);
|
{
|
||||||
if (input.is_open()) {
|
std::ifstream input(entry.path(), std::ifstream::in);
|
||||||
std::getline(input, firstLine);
|
if (input.is_open()) {
|
||||||
input.close();
|
std::getline(input, firstLine);
|
||||||
|
input.close();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
if (firstLine.find("#ifndef DEPRECATED_HEADER_"
|
||||||
|
+ m_commandLineArgs->moduleName())
|
||||||
|
== 0
|
||||||
|
|| firstLine.find("#ifndef DEPRECATED_HEADER_") != 0)
|
||||||
|
std::filesystem::remove(entry.path());
|
||||||
}
|
}
|
||||||
if (firstLine.find("#ifndef DEPRECATED_HEADER_"
|
|
||||||
+ m_commandLineArgs->moduleName())
|
|
||||||
== 0
|
|
||||||
|| firstLine.find("#ifndef DEPRECATED_HEADER_") != 0)
|
|
||||||
std::filesystem::remove(entry.path());
|
|
||||||
}
|
}
|
||||||
|
} catch (const std::filesystem::filesystem_error &fserr) {
|
||||||
|
utils::printFilesystemError(fserr, "Unable to clean the staging directory");
|
||||||
|
return false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user