summaryrefslogtreecommitdiffstats
path: root/src/corelib/io/qfile.cpp
diff options
context:
space:
mode:
authorThiago Macieira <thiago.macieira@intel.com>2025-01-23 18:39:55 -0800
committerThiago Macieira <thiago.macieira@intel.com>2025-02-04 16:03:50 -0800
commitfb5b9fd6f39eba8a15e69c82be202846bb42cf8c (patch)
tree2052ca67a54ff37aeb84c18a981dcce9940d857b /src/corelib/io/qfile.cpp
parentd1694476271346d13ac8ca3138328d295bf403b4 (diff)
QFile::copy: remove the fallback to copying through QDir::tempPath()
This would never work: if we failed to create the temporary file in the target directory, then a later QTemporaryFile::rename() to that name is even less likely to work. If we didn't have write permissions, we're not likely to get them; if the disk was so full that we couldn't create a file, the copying of the data is going to fail too; if the FS is out of inodes, it wouldn't be able to create the file anywhere either. The only case where the creation elsewhere would work is if it were a different FS, but then QTemporaryFile::rename() won't succeed. Change-Id: I1ba6b9f7050f81163d14fffd79ff4e7460201e86 Reviewed-by: Ahmad Samir <a.samirh78@gmail.com>
Diffstat (limited to 'src/corelib/io/qfile.cpp')
-rw-r--r--src/corelib/io/qfile.cpp7
1 files changed, 2 insertions, 5 deletions
diff --git a/src/corelib/io/qfile.cpp b/src/corelib/io/qfile.cpp
index 89a270d2c8c..05a55cf2327 100644
--- a/src/corelib/io/qfile.cpp
+++ b/src/corelib/io/qfile.cpp
@@ -824,11 +824,8 @@ QFile::copy(const QString &newName)
error = true;
#else
QTemporaryFile out(fileTemplate.arg(QFileInfo(newName).path()));
- if (!out.open()) {
- out.setFileTemplate(fileTemplate.arg(QDir::tempPath()));
- if (!out.open())
- error = true;
- }
+ if (!out.open())
+ error = true;
#endif
if (error) {
d->setError(QFile::CopyError, tr("Cannot open for output: %1").arg(out.errorString()));