Changeset View
Changeset View
Standalone View
Standalone View
src/core/copyjob.cpp
Show First 20 Lines • Show All 51 Lines • ▼ Show 20 Line(s) | |||||
52 | 52 | | |||
53 | #include <qtemporaryfile.h> | 53 | #include <qtemporaryfile.h> | ||
54 | #include <QTimer> | 54 | #include <QTimer> | ||
55 | #include <QFile> | 55 | #include <QFile> | ||
56 | #include <QFileInfo> | 56 | #include <QFileInfo> | ||
57 | #include <QLinkedList> | 57 | #include <QLinkedList> | ||
58 | #include <sys/stat.h> // mode_t | 58 | #include <sys/stat.h> // mode_t | ||
59 | #include <QPointer> | 59 | #include <QPointer> | ||
60 | #include <QDir> | ||||
60 | 61 | | |||
61 | #include "job_p.h" | 62 | #include "job_p.h" | ||
62 | #include <kdiskfreespaceinfo.h> | 63 | #include <kdiskfreespaceinfo.h> | ||
63 | #include <kfilesystemtype.h> | 64 | #include <kfilesystemtype.h> | ||
64 | 65 | | |||
65 | 66 | | |||
66 | #include <QLoggingCategory> | 67 | #include <QLoggingCategory> | ||
67 | Q_DECLARE_LOGGING_CATEGORY(KIO_COPYJOB_DEBUG) | 68 | Q_DECLARE_LOGGING_CATEGORY(KIO_COPYJOB_DEBUG) | ||
▲ Show 20 Lines • Show All 1832 Lines • ▼ Show 20 Line(s) | 1896 | if (err) { | |||
1900 | // https://codereview.qt-project.org/44823 is in | 1901 | // https://codereview.qt-project.org/44823 is in | ||
1901 | if ((err == ERR_FILE_ALREADY_EXIST || err == ERR_DIR_ALREADY_EXIST || err == ERR_IDENTICAL_FILES) && | 1902 | if ((err == ERR_FILE_ALREADY_EXIST || err == ERR_DIR_ALREADY_EXIST || err == ERR_IDENTICAL_FILES) && | ||
1902 | m_currentSrcURL.isLocalFile() && dest.isLocalFile()) { | 1903 | m_currentSrcURL.isLocalFile() && dest.isLocalFile()) { | ||
1903 | const QString _src(m_currentSrcURL.adjusted(QUrl::StripTrailingSlash).toLocalFile()); | 1904 | const QString _src(m_currentSrcURL.adjusted(QUrl::StripTrailingSlash).toLocalFile()); | ||
1904 | const QString _dest(dest.adjusted(QUrl::StripTrailingSlash).toLocalFile()); | 1905 | const QString _dest(dest.adjusted(QUrl::StripTrailingSlash).toLocalFile()); | ||
1905 | if (_src != _dest && QString::compare(_src, _dest, Qt::CaseInsensitive) == 0) { | 1906 | if (_src != _dest && QString::compare(_src, _dest, Qt::CaseInsensitive) == 0) { | ||
1906 | qCDebug(KIO_COPYJOB_DEBUG) << "Couldn't rename directly, dest already exists. Detected special case of lower/uppercase renaming in same dir, try with 2 rename calls"; | 1907 | qCDebug(KIO_COPYJOB_DEBUG) << "Couldn't rename directly, dest already exists. Detected special case of lower/uppercase renaming in same dir, try with 2 rename calls"; | ||
1907 | const QString srcDir = QFileInfo(_src).absolutePath(); | 1908 | const QString srcDir = QFileInfo(_src).absolutePath(); | ||
1908 | QTemporaryFile tmpFile(srcDir + QLatin1String("kio_XXXXXX")); | 1909 | QTemporaryFile tmpFile(QDir(srcDir).filePath(QLatin1String("kio_XXXXXX"))); | ||
chinmoyr: IMO QDir isn't required here. QLatin1String("/kio_xxxxxx") is sufficient. | |||||
1909 | const bool openOk = tmpFile.open(); | 1910 | const bool openOk = tmpFile.open(); | ||
1910 | if (!openOk) { | 1911 | if (!openOk) { | ||
1911 | qCWarning(KIO_CORE) << "Couldn't open temp file in" << srcDir; | 1912 | qCWarning(KIO_CORE) << "Couldn't open temp file in" << srcDir; | ||
1912 | } else { | 1913 | } else { | ||
1913 | const QString _tmp(tmpFile.fileName()); | 1914 | const QString _tmp(tmpFile.fileName()); | ||
1914 | tmpFile.close(); | 1915 | tmpFile.close(); | ||
1915 | tmpFile.remove(); | 1916 | tmpFile.remove(); | ||
1916 | qCDebug(KIO_COPYJOB_DEBUG) << "QTemporaryFile using" << _tmp << "as intermediary"; | 1917 | qCDebug(KIO_COPYJOB_DEBUG) << "QTemporaryFile using" << _tmp << "as intermediary"; | ||
▲ Show 20 Lines • Show All 374 Lines • Show Last 20 Lines |
IMO QDir isn't required here. QLatin1String("/kio_xxxxxx") is sufficient.