Changeset View
Changeset View
Standalone View
Standalone View
src/core/copyjob.cpp
Show All 13 Lines | 1 | /* This file is part of the KDE libraries | |||
---|---|---|---|---|---|
14 | Library General Public License for more details. | 14 | Library General Public License for more details. | ||
15 | 15 | | |||
16 | You should have received a copy of the GNU Library General Public License | 16 | You should have received a copy of the GNU Library General Public License | ||
17 | along with this library; see the file COPYING.LIB. If not, write to | 17 | along with this library; see the file COPYING.LIB. If not, write to | ||
18 | the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, | 18 | the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, | ||
19 | Boston, MA 02110-1301, USA. | 19 | Boston, MA 02110-1301, USA. | ||
20 | */ | 20 | */ | ||
21 | 21 | | |||
22 | #include "global.h" | ||||
22 | #include "copyjob.h" | 23 | #include "copyjob.h" | ||
23 | #include "kiocoredebug.h" | 24 | #include "kiocoredebug.h" | ||
24 | #include <errno.h> | 25 | #include <errno.h> | ||
25 | #include "kcoredirlister.h" | 26 | #include "kcoredirlister.h" | ||
26 | #include "kfileitem.h" | 27 | #include "kfileitem.h" | ||
27 | #include "job.h" // buildErrorString | 28 | #include "job.h" // buildErrorString | ||
28 | #include "mkdirjob.h" | 29 | #include "mkdirjob.h" | ||
29 | #include "listjob.h" | 30 | #include "listjob.h" | ||
▲ Show 20 Lines • Show All 327 Lines • ▼ Show 20 Line(s) | 332 | { | |||
357 | q->connect(m_reportTimer, &QTimer::timeout, q, [this]() { | 358 | q->connect(m_reportTimer, &QTimer::timeout, q, [this]() { | ||
358 | slotReport(); | 359 | slotReport(); | ||
359 | }); | 360 | }); | ||
360 | m_reportTimer->start(REPORT_TIMEOUT); | 361 | m_reportTimer->start(REPORT_TIMEOUT); | ||
361 | 362 | | |||
362 | // Stat the dest | 363 | // Stat the dest | ||
363 | state = STATE_STATING; | 364 | state = STATE_STATING; | ||
364 | const QUrl dest = m_asMethod ? m_dest.adjusted(QUrl::RemoveFilename) : m_dest; | 365 | const QUrl dest = m_asMethod ? m_dest.adjusted(QUrl::RemoveFilename) : m_dest; | ||
365 | KIO::Job *job = KIO::stat(dest, StatJob::DestinationSide, 2, KIO::HideProgressInfo); | 366 | KIO::Job *job = KIO::stat(dest, StatJob::DestinationSide, KIO::StatDetail::StatDefaultDetails, KIO::HideProgressInfo); | ||
kossebau: Fear the same as said for Basic is true with Default. I would prefer explicit flags here as… | |||||
366 | qCDebug(KIO_COPYJOB_DEBUG) << "CopyJob: stating the dest" << m_dest; | 367 | qCDebug(KIO_COPYJOB_DEBUG) << "CopyJob: stating the dest" << m_dest; | ||
367 | q->addSubjob(job); | 368 | q->addSubjob(job); | ||
368 | } | 369 | } | ||
369 | 370 | | |||
370 | // For unit test purposes | 371 | // For unit test purposes | ||
371 | KIOCORE_EXPORT bool kio_resolve_local_urls = true; | 372 | KIOCORE_EXPORT bool kio_resolve_local_urls = true; | ||
372 | 373 | | |||
373 | void CopyJobPrivate::slotResultStating(KJob *job) | 374 | void CopyJobPrivate::slotResultStating(KJob *job) | ||
▲ Show 20 Lines • Show All 528 Lines • ▼ Show 20 Line(s) | 816 | if (m_currentStatSrc != m_srcList.constEnd()) { | |||
902 | if (entry.contains(KIO::UDSEntry::UDS_NAME)) { | 903 | if (entry.contains(KIO::UDSEntry::UDS_NAME)) { | ||
903 | qCDebug(KIO_COPYJOB_DEBUG) << "fast path! found info about" << m_currentSrcURL << "in KCoreDirLister"; | 904 | qCDebug(KIO_COPYJOB_DEBUG) << "fast path! found info about" << m_currentSrcURL << "in KCoreDirLister"; | ||
904 | // sourceStated(entry, m_currentSrcURL); // don't recurse, see #319747, use queued invokeMethod instead | 905 | // sourceStated(entry, m_currentSrcURL); // don't recurse, see #319747, use queued invokeMethod instead | ||
905 | QMetaObject::invokeMethod(q, "sourceStated", Qt::QueuedConnection, Q_ARG(KIO::UDSEntry, entry), Q_ARG(QUrl, m_currentSrcURL)); | 906 | QMetaObject::invokeMethod(q, "sourceStated", Qt::QueuedConnection, Q_ARG(KIO::UDSEntry, entry), Q_ARG(QUrl, m_currentSrcURL)); | ||
906 | return; | 907 | return; | ||
907 | } | 908 | } | ||
908 | 909 | | |||
909 | // Stat the next src url | 910 | // Stat the next src url | ||
910 | Job *job = KIO::stat(m_currentSrcURL, StatJob::SourceSide, 2, KIO::HideProgressInfo); | 911 | Job *job = KIO::stat(m_currentSrcURL, StatJob::SourceSide, KIO::StatDetail::StatDefaultDetails, KIO::HideProgressInfo); | ||
911 | qCDebug(KIO_COPYJOB_DEBUG) << "KIO::stat on" << m_currentSrcURL; | 912 | qCDebug(KIO_COPYJOB_DEBUG) << "KIO::stat on" << m_currentSrcURL; | ||
912 | state = STATE_STATING; | 913 | state = STATE_STATING; | ||
913 | q->addSubjob(job); | 914 | q->addSubjob(job); | ||
914 | m_currentDestURL = m_dest; | 915 | m_currentDestURL = m_dest; | ||
915 | m_bURLDirty = true; | 916 | m_bURLDirty = true; | ||
916 | } else { | 917 | } else { | ||
917 | // Finished the stat'ing phase | 918 | // Finished the stat'ing phase | ||
918 | // First make sure that the totals were correctly emitted | 919 | // First make sure that the totals were correctly emitted | ||
▲ Show 20 Lines • Show All 214 Lines • ▼ Show 20 Line(s) | 1130 | } else { | |||
1133 | } | 1134 | } | ||
1134 | 1135 | | |||
1135 | Q_ASSERT(((SimpleJob *)job)->url() == (*it).uDest); | 1136 | Q_ASSERT(((SimpleJob *)job)->url() == (*it).uDest); | ||
1136 | q->removeSubjob(job); | 1137 | q->removeSubjob(job); | ||
1137 | Q_ASSERT(!q->hasSubjobs()); // We should have only one job at a time ... | 1138 | Q_ASSERT(!q->hasSubjobs()); // We should have only one job at a time ... | ||
1138 | 1139 | | |||
1139 | // We need to stat the existing dir, to get its last-modification time | 1140 | // We need to stat the existing dir, to get its last-modification time | ||
1140 | QUrl existingDest((*it).uDest); | 1141 | QUrl existingDest((*it).uDest); | ||
1141 | SimpleJob *newJob = KIO::stat(existingDest, StatJob::DestinationSide, 2, KIO::HideProgressInfo); | 1142 | SimpleJob *newJob = KIO::stat(existingDest, StatJob::DestinationSide, KIO::StatDetail::StatDefaultDetails, KIO::HideProgressInfo); | ||
1142 | Scheduler::setJobPriority(newJob, 1); | 1143 | Scheduler::setJobPriority(newJob, 1); | ||
1143 | qCDebug(KIO_COPYJOB_DEBUG) << "KIO::stat for resolving conflict on" << existingDest; | 1144 | qCDebug(KIO_COPYJOB_DEBUG) << "KIO::stat for resolving conflict on" << existingDest; | ||
1144 | state = STATE_CONFLICT_CREATING_DIRS; | 1145 | state = STATE_CONFLICT_CREATING_DIRS; | ||
1145 | q->addSubjob(newJob); | 1146 | q->addSubjob(newJob); | ||
1146 | return; // Don't move to next dir yet ! | 1147 | return; // Don't move to next dir yet ! | ||
1147 | } | 1148 | } | ||
1148 | } | 1149 | } | ||
1149 | } | 1150 | } | ||
▲ Show 20 Lines • Show All 194 Lines • ▼ Show 20 Line(s) | 1344 | if (!q->uiDelegateExtension()) { | |||
1344 | q->Job::slotResult(job); // will set the error and emit result(this) | 1345 | q->Job::slotResult(job); // will set the error and emit result(this) | ||
1345 | return; | 1346 | return; | ||
1346 | } | 1347 | } | ||
1347 | 1348 | | |||
1348 | q->removeSubjob(job); | 1349 | q->removeSubjob(job); | ||
1349 | Q_ASSERT(!q->hasSubjobs()); | 1350 | Q_ASSERT(!q->hasSubjobs()); | ||
1350 | // We need to stat the existing file, to get its last-modification time | 1351 | // We need to stat the existing file, to get its last-modification time | ||
1351 | QUrl existingFile((*it).uDest); | 1352 | QUrl existingFile((*it).uDest); | ||
1352 | SimpleJob *newJob = KIO::stat(existingFile, StatJob::DestinationSide, 2, KIO::HideProgressInfo); | 1353 | SimpleJob *newJob = KIO::stat(existingFile, StatJob::DestinationSide, KIO::StatDetail::StatDefaultDetails, KIO::HideProgressInfo); | ||
1353 | Scheduler::setJobPriority(newJob, 1); | 1354 | Scheduler::setJobPriority(newJob, 1); | ||
1354 | qCDebug(KIO_COPYJOB_DEBUG) << "KIO::stat for resolving conflict on" << existingFile; | 1355 | qCDebug(KIO_COPYJOB_DEBUG) << "KIO::stat for resolving conflict on" << existingFile; | ||
1355 | state = STATE_CONFLICT_COPYING_FILES; | 1356 | state = STATE_CONFLICT_COPYING_FILES; | ||
1356 | q->addSubjob(newJob); | 1357 | q->addSubjob(newJob); | ||
1357 | return; // Don't move to next file yet ! | 1358 | return; // Don't move to next file yet ! | ||
1358 | } | 1359 | } | ||
1359 | } else { | 1360 | } else { | ||
1360 | if (m_bCurrentOperationIsLink && qobject_cast<KIO::DeleteJob *>(job)) { | 1361 | if (m_bCurrentOperationIsLink && qobject_cast<KIO::DeleteJob *>(job)) { | ||
▲ Show 20 Lines • Show All 635 Lines • ▼ Show 20 Line(s) | 1988 | if (err == ERR_DIR_ALREADY_EXIST || | |||
1996 | } else if ((isDir && m_bOverwriteAllDirs) || (!isDir && m_bOverwriteAllFiles)) { | 1997 | } else if ((isDir && m_bOverwriteAllDirs) || (!isDir && m_bOverwriteAllFiles)) { | ||
1997 | ; // nothing to do, stat+copy+del will overwrite | 1998 | ; // nothing to do, stat+copy+del will overwrite | ||
1998 | } else if ((isDir && m_bAutoRenameDirs) || (!isDir && m_bAutoRenameFiles)) { | 1999 | } else if ((isDir && m_bAutoRenameDirs) || (!isDir && m_bAutoRenameFiles)) { | ||
1999 | QUrl destDirectory = m_currentDestURL.adjusted(QUrl::RemoveFilename | QUrl::StripTrailingSlash); // m_currendDestURL includes filename | 2000 | QUrl destDirectory = m_currentDestURL.adjusted(QUrl::RemoveFilename | QUrl::StripTrailingSlash); // m_currendDestURL includes filename | ||
2000 | const QString newName = KFileUtils::suggestName(destDirectory, m_currentDestURL.fileName()); | 2001 | const QString newName = KFileUtils::suggestName(destDirectory, m_currentDestURL.fileName()); | ||
2001 | 2002 | | |||
2002 | m_dest = destDirectory; | 2003 | m_dest = destDirectory; | ||
2003 | m_dest.setPath(concatPaths(m_dest.path(), newName)); | 2004 | m_dest.setPath(concatPaths(m_dest.path(), newName)); | ||
2004 | KIO::Job *job = KIO::stat(m_dest, StatJob::DestinationSide, 2, KIO::HideProgressInfo); | 2005 | KIO::Job *job = KIO::stat(m_dest, StatJob::DestinationSide, KIO::StatDefaultDetails, KIO::HideProgressInfo); | ||
2005 | state = STATE_STATING; | 2006 | state = STATE_STATING; | ||
2006 | destinationState = DEST_NOT_STATED; | 2007 | destinationState = DEST_NOT_STATED; | ||
2007 | q->addSubjob(job); | 2008 | q->addSubjob(job); | ||
2008 | return; | 2009 | return; | ||
2009 | } else if (q->uiDelegateExtension()) { | 2010 | } else if (q->uiDelegateExtension()) { | ||
2010 | QString newPath; | 2011 | QString newPath; | ||
2011 | // we lack mtime info for both the src (not stated) | 2012 | // we lack mtime info for both the src (not stated) | ||
2012 | // and the dest (stated but this info wasn't stored) | 2013 | // and the dest (stated but this info wasn't stored) | ||
▲ Show 20 Lines • Show All 74 Lines • ▼ Show 20 Line(s) | 2087 | } else { | |||
2087 | m_bAutoRenameFiles = true; | 2088 | m_bAutoRenameFiles = true; | ||
2088 | } | 2089 | } | ||
2089 | // fall through | 2090 | // fall through | ||
2090 | Q_FALLTHROUGH(); | 2091 | Q_FALLTHROUGH(); | ||
2091 | case Result_Rename: { | 2092 | case Result_Rename: { | ||
2092 | // Set m_dest to the chosen destination | 2093 | // Set m_dest to the chosen destination | ||
2093 | // This is only for this src url; the next one will revert to m_globalDest | 2094 | // This is only for this src url; the next one will revert to m_globalDest | ||
2094 | m_dest.setPath(newPath); | 2095 | m_dest.setPath(newPath); | ||
2095 | KIO::Job *job = KIO::stat(m_dest, StatJob::DestinationSide, 2, KIO::HideProgressInfo); | 2096 | KIO::Job *job = KIO::stat(m_dest, StatJob::DestinationSide, KIO::StatDefaultDetails, KIO::HideProgressInfo); | ||
2096 | state = STATE_STATING; | 2097 | state = STATE_STATING; | ||
2097 | destinationState = DEST_NOT_STATED; | 2098 | destinationState = DEST_NOT_STATED; | ||
2098 | q->addSubjob(job); | 2099 | q->addSubjob(job); | ||
2099 | return; | 2100 | return; | ||
2100 | } | 2101 | } | ||
2101 | case Result_AutoSkip: | 2102 | case Result_AutoSkip: | ||
2102 | if (isDir) { | 2103 | if (isDir) { | ||
2103 | m_bAutoSkipDirs = true; | 2104 | m_bAutoSkipDirs = true; | ||
Show All 37 Lines | 2141 | } else if (err != KIO::ERR_UNSUPPORTED_ACTION) { | |||
2141 | qCDebug(KIO_COPYJOB_DEBUG) << "Couldn't rename" << m_currentSrcURL << "to" << dest << ", aborting"; | 2142 | qCDebug(KIO_COPYJOB_DEBUG) << "Couldn't rename" << m_currentSrcURL << "to" << dest << ", aborting"; | ||
2142 | q->setError(err); | 2143 | q->setError(err); | ||
2143 | q->setErrorText(errText); | 2144 | q->setErrorText(errText); | ||
2144 | q->emitResult(); | 2145 | q->emitResult(); | ||
2145 | return; | 2146 | return; | ||
2146 | } | 2147 | } | ||
2147 | qCDebug(KIO_COPYJOB_DEBUG) << "Couldn't rename" << m_currentSrcURL << "to" << dest << ", reverting to normal way, starting with stat"; | 2148 | qCDebug(KIO_COPYJOB_DEBUG) << "Couldn't rename" << m_currentSrcURL << "to" << dest << ", reverting to normal way, starting with stat"; | ||
2148 | qCDebug(KIO_COPYJOB_DEBUG) << "KIO::stat on" << m_currentSrcURL; | 2149 | qCDebug(KIO_COPYJOB_DEBUG) << "KIO::stat on" << m_currentSrcURL; | ||
2149 | KIO::Job *job = KIO::stat(m_currentSrcURL, StatJob::SourceSide, 2, KIO::HideProgressInfo); | 2150 | KIO::Job *job = KIO::stat(m_currentSrcURL, StatJob::SourceSide, KIO::StatDefaultDetails, KIO::HideProgressInfo); | ||
2150 | state = STATE_STATING; | 2151 | state = STATE_STATING; | ||
2151 | q->addSubjob(job); | 2152 | q->addSubjob(job); | ||
2152 | m_bOnlyRenames = false; | 2153 | m_bOnlyRenames = false; | ||
2153 | } else { | 2154 | } else { | ||
2154 | qCDebug(KIO_COPYJOB_DEBUG) << "Renaming succeeded, move on"; | 2155 | qCDebug(KIO_COPYJOB_DEBUG) << "Renaming succeeded, move on"; | ||
2155 | ++m_processedFiles; | 2156 | ++m_processedFiles; | ||
2156 | // Emit copyingDone for FileUndoManager to remember what we did. | 2157 | // Emit copyingDone for FileUndoManager to remember what we did. | ||
2157 | // Use resolved URL m_currentSrcURL since that's what we just used for renaming. See bug 391606 and kio_desktop's testTrashAndUndo(). | 2158 | // Use resolved URL m_currentSrcURL since that's what we just used for renaming. See bug 391606 and kio_desktop's testTrashAndUndo(). | ||
▲ Show 20 Lines • Show All 174 Lines • Show Last 20 Lines |
Fear the same as said for Basic is true with Default. I would prefer explicit flags here as code reader.