mirror of
https://github.com/nextcloud/desktop.git
synced 2025-10-26 11:17:43 +00:00
Merge pull request #8130 from nextcloud/backport/8127/stable-3.16
[stable-3.16] stop using QFile api to delete a single local file
This commit is contained in:
commit
2b33cddcf7
@ -26,6 +26,7 @@
|
||||
#include <QFile>
|
||||
#include <QCoreApplication>
|
||||
|
||||
#include <filesystem>
|
||||
#include <sys/stat.h>
|
||||
#include <sys/types.h>
|
||||
|
||||
@ -588,13 +589,30 @@ bool FileSystem::remove(const QString &fileName, QString *errorString)
|
||||
// allow that.
|
||||
setFileReadOnly(fileName, false);
|
||||
#endif
|
||||
QFile f(fileName);
|
||||
if (!f.remove()) {
|
||||
|
||||
try {
|
||||
if (!std::filesystem::remove(std::filesystem::path{fileName.toUtf8().data()})) {
|
||||
if (errorString) {
|
||||
*errorString = QObject::tr("File is already deleted");
|
||||
}
|
||||
return false;
|
||||
}
|
||||
}
|
||||
catch (const std::filesystem::filesystem_error &e)
|
||||
{
|
||||
if (errorString) {
|
||||
*errorString = f.errorString();
|
||||
*errorString = QString::fromLatin1(e.what());
|
||||
}
|
||||
return false;
|
||||
}
|
||||
catch (...)
|
||||
{
|
||||
if (errorString) {
|
||||
*errorString = QObject::tr("Error deleting the file");
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
Loading…
Reference in New Issue
Block a user