From eabdb4b3087faa709ce5d55027019acd9e6b4870 Mon Sep 17 00:00:00 2001 From: Marcus Tillmanns Date: Tue, 10 Sep 2024 14:14:01 +0200 Subject: [PATCH] Utils: Remove remote specific code from FileSaver Remote devices support enough functionality now that this is no longer needed. Change-Id: I5c9d3cba6d9e7511b43360f95472cc5c7893676f Reviewed-by: hjk --- src/libs/utils/fileutils.cpp | 35 +++++++++-------------------------- 1 file changed, 9 insertions(+), 26 deletions(-) diff --git a/src/libs/utils/fileutils.cpp b/src/libs/utils/fileutils.cpp index 856b2ad7619..319235d7c49 100644 --- a/src/libs/utils/fileutils.cpp +++ b/src/libs/utils/fileutils.cpp @@ -190,22 +190,15 @@ FileSaver::FileSaver(const FilePath &filePath, QIODevice::OpenMode mode) return; } } - if (filePath.needsDevice()) { - // Write to a local temporary file first. Actual saving to the selected location - // is done via m_filePath.writeFileContents() in finalize() - m_isSafe = false; - auto tf = new QTemporaryFile(QDir::tempPath() + "/remotefilesaver-XXXXXX"); - tf->setAutoRemove(false); - m_file.reset(tf); - } else { - const bool readOnlyOrAppend = mode & (QIODevice::ReadOnly | QIODevice::Append); - m_isSafe = !readOnlyOrAppend && !filePath.hasHardLinks() - && !qtcEnvironmentVariableIsSet("QTC_DISABLE_ATOMICSAVE"); - if (m_isSafe) - m_file.reset(new SaveFile(filePath)); - else - m_file.reset(new QFile{filePath.path()}); - } + + const bool readOnlyOrAppend = mode & (QIODevice::ReadOnly | QIODevice::Append); + m_isSafe = !readOnlyOrAppend && !filePath.hasHardLinks() + && !qtcEnvironmentVariableIsSet("QTC_DISABLE_ATOMICSAVE"); + if (m_isSafe) + m_file.reset(new SaveFile(filePath)); + else + m_file.reset(new QFile{filePath.toFSPathString()}); + if (!m_file->open(QIODevice::WriteOnly | mode)) { QString err = filePath.exists() ? Tr::tr("Cannot overwrite file %1: %2") : Tr::tr("Cannot create file %1: %2"); @@ -216,16 +209,6 @@ FileSaver::FileSaver(const FilePath &filePath, QIODevice::OpenMode mode) bool FileSaver::finalize() { - if (m_filePath.needsDevice()) { - m_file->close(); - m_file->open(QIODevice::ReadOnly); - const QByteArray data = m_file->readAll(); - const expected_str res = m_filePath.writeFileContents(data); - m_file->remove(); - m_file.reset(); - return res.has_value(); - } - if (!m_isSafe) return FileSaverBase::finalize();