Changeset View
Changeset View
Standalone View
Standalone View
src/core/copyjob.cpp
Show First 20 Lines • Show All 477 Lines • ▼ Show 20 Line(s) | 445 | { | |||
---|---|---|---|---|---|
478 | if (isDir | 478 | if (isDir | ||
479 | // treat symlinks as files (no recursion) | 479 | // treat symlinks as files (no recursion) | ||
480 | && !entry.isLink() | 480 | && !entry.isLink() | ||
481 | && m_mode != CopyJob::Link) { // No recursion in Link mode either. | 481 | && m_mode != CopyJob::Link) { // No recursion in Link mode either. | ||
482 | qCDebug(KIO_COPYJOB_DEBUG) << "Source is a directory"; | 482 | qCDebug(KIO_COPYJOB_DEBUG) << "Source is a directory"; | ||
483 | 483 | | |||
484 | if (srcurl.isLocalFile()) { | 484 | if (srcurl.isLocalFile()) { | ||
485 | const QString parentDir = srcurl.adjusted(QUrl::StripTrailingSlash).toLocalFile(); | 485 | const QString parentDir = srcurl.adjusted(QUrl::StripTrailingSlash).toLocalFile(); | ||
486 | if (!m_parentDirs.contains(parentDir)) { | ||||
487 | KDirWatch::self()->removeDir(parentDir); | ||||
486 | m_parentDirs.insert(parentDir); | 488 | m_parentDirs.insert(parentDir); | ||
487 | } | 489 | } | ||
490 | } | ||||
488 | 491 | | |||
489 | m_bCurrentSrcIsDir = true; // used by slotEntries | 492 | m_bCurrentSrcIsDir = true; // used by slotEntries | ||
490 | if (destinationState == DEST_IS_DIR) { // (case 1) | 493 | if (destinationState == DEST_IS_DIR) { // (case 1) | ||
491 | if (!m_asMethod) { | 494 | if (!m_asMethod) { | ||
492 | // Use <desturl>/<directory_copied> as destination, from now on | 495 | // Use <desturl>/<directory_copied> as destination, from now on | ||
493 | QString directory = srcurl.fileName(); | 496 | QString directory = srcurl.fileName(); | ||
494 | const QString sName = entry.stringValue(KIO::UDSEntry::UDS_NAME); | 497 | const QString sName = entry.stringValue(KIO::UDSEntry::UDS_NAME); | ||
495 | KProtocolInfo::FileNameUsedForCopying fnu = KProtocolManager::fileNameUsedForCopying(srcurl); | 498 | KProtocolInfo::FileNameUsedForCopying fnu = KProtocolManager::fileNameUsedForCopying(srcurl); | ||
Show All 23 Lines | |||||
519 | } | 522 | } | ||
520 | 523 | | |||
521 | startListing(srcurl); | 524 | startListing(srcurl); | ||
522 | } else { | 525 | } else { | ||
523 | qCDebug(KIO_COPYJOB_DEBUG) << "Source is a file (or a symlink), or we are linking -> no recursive listing"; | 526 | qCDebug(KIO_COPYJOB_DEBUG) << "Source is a file (or a symlink), or we are linking -> no recursive listing"; | ||
524 | 527 | | |||
525 | if (srcurl.isLocalFile()) { | 528 | if (srcurl.isLocalFile()) { | ||
526 | const QString parentDir = srcurl.adjusted(QUrl::RemoveFilename | QUrl::StripTrailingSlash).path(); | 529 | const QString parentDir = srcurl.adjusted(QUrl::RemoveFilename | QUrl::StripTrailingSlash).path(); | ||
530 | if (!m_parentDirs.contains(parentDir)) { | ||||
531 | KDirWatch::self()->removeDir(parentDir); | ||||
527 | m_parentDirs.insert(parentDir); | 532 | m_parentDirs.insert(parentDir); | ||
528 | } | 533 | } | ||
534 | } | ||||
529 | 535 | | |||
530 | statNextSrc(); | 536 | statNextSrc(); | ||
531 | } | 537 | } | ||
532 | } | 538 | } | ||
533 | 539 | | |||
534 | bool CopyJob::doSuspend() | 540 | bool CopyJob::doSuspend() | ||
535 | { | 541 | { | ||
536 | Q_D(CopyJob); | 542 | Q_D(CopyJob); | ||
▲ Show 20 Lines • Show All 355 Lines • ▼ Show 20 Line(s) | |||||
892 | void CopyJobPrivate::startRenameJob(const QUrl &slave_url) | 898 | void CopyJobPrivate::startRenameJob(const QUrl &slave_url) | ||
893 | { | 899 | { | ||
894 | Q_Q(CopyJob); | 900 | Q_Q(CopyJob); | ||
895 | 901 | | |||
896 | // Silence KDirWatch notifications, otherwise performance is horrible | 902 | // Silence KDirWatch notifications, otherwise performance is horrible | ||
897 | if (m_currentSrcURL.isLocalFile()) { | 903 | if (m_currentSrcURL.isLocalFile()) { | ||
898 | const QString parentDir = m_currentSrcURL.adjusted(QUrl::RemoveFilename).path(); | 904 | const QString parentDir = m_currentSrcURL.adjusted(QUrl::RemoveFilename).path(); | ||
899 | if (!m_parentDirs.contains(parentDir)) { | 905 | if (!m_parentDirs.contains(parentDir)) { | ||
900 | KDirWatch::self()->stopDirScan(parentDir); | 906 | KDirWatch::self()->removeDir(parentDir); | ||
901 | m_parentDirs.insert(parentDir); | 907 | m_parentDirs.insert(parentDir); | ||
902 | } | 908 | } | ||
903 | } | 909 | } | ||
904 | 910 | | |||
905 | QUrl dest = m_dest; | 911 | QUrl dest = m_dest; | ||
906 | // Append filename or dirname to destination URL, if allowed | 912 | // Append filename or dirname to destination URL, if allowed | ||
907 | if (destinationState == DEST_IS_DIR && !m_asMethod) { | 913 | if (destinationState == DEST_IS_DIR && !m_asMethod) { | ||
908 | dest = addPathToUrl(dest, m_currentSrcURL.fileName()); | 914 | dest = addPathToUrl(dest, m_currentSrcURL.fileName()); | ||
▲ Show 20 Lines • Show All 325 Lines • ▼ Show 20 Line(s) | 1231 | if (!udir.isEmpty()) { // any dir to create, finally ? | |||
1234 | m_currentDestURL = udir; | 1240 | m_currentDestURL = udir; | ||
1235 | m_bURLDirty = true; | 1241 | m_bURLDirty = true; | ||
1236 | 1242 | | |||
1237 | q->addSubjob(newjob); | 1243 | q->addSubjob(newjob); | ||
1238 | return; | 1244 | return; | ||
1239 | } else { // we have finished creating dirs | 1245 | } else { // we have finished creating dirs | ||
1240 | q->setProcessedAmount(KJob::Directories, m_processedDirs); // make sure final number appears | 1246 | q->setProcessedAmount(KJob::Directories, m_processedDirs); // make sure final number appears | ||
1241 | 1247 | | |||
1242 | if (m_mode == CopyJob::Move) { | | |||
1243 | // Now we know which dirs hold the files we're going to delete. | | |||
1244 | // To speed things up and prevent double-notification, we disable KDirWatch | | |||
1245 | // on those dirs temporarily (using KDirWatch::self, that's the instanced | | |||
1246 | // used by e.g. kdirlister). | | |||
1247 | for (QSet<QString>::const_iterator it = m_parentDirs.constBegin(); it != m_parentDirs.constEnd(); ++it) { | | |||
1248 | KDirWatch::self()->stopDirScan(*it); | | |||
1249 | } | | |||
1250 | } | | |||
1251 | | ||||
1252 | state = STATE_COPYING_FILES; | 1248 | state = STATE_COPYING_FILES; | ||
1253 | m_processedFiles++; // Ralf wants it to start at 1, not 0 | 1249 | m_processedFiles++; // Ralf wants it to start at 1, not 0 | ||
1254 | copyNextFile(); | 1250 | copyNextFile(); | ||
1255 | } | 1251 | } | ||
1256 | } | 1252 | } | ||
1257 | 1253 | | |||
1258 | void CopyJobPrivate::slotResultCopyingFiles(KJob *job) | 1254 | void CopyJobPrivate::slotResultCopyingFiles(KJob *job) | ||
1259 | { | 1255 | { | ||
▲ Show 20 Lines • Show All 503 Lines • ▼ Show 20 Line(s) | 1758 | if (d->m_mode == CopyJob::Move && !d->m_successSrcList.isEmpty()) { | |||
1763 | qCDebug(KIO_COPYJOB_DEBUG) << "KDirNotify'ing FilesRemoved" << d->m_successSrcList; | 1759 | qCDebug(KIO_COPYJOB_DEBUG) << "KDirNotify'ing FilesRemoved" << d->m_successSrcList; | ||
1764 | org::kde::KDirNotify::emitFilesRemoved(d->m_successSrcList); | 1760 | org::kde::KDirNotify::emitFilesRemoved(d->m_successSrcList); | ||
1765 | } | 1761 | } | ||
1766 | } | 1762 | } | ||
1767 | 1763 | | |||
1768 | // Re-enable watching on the dirs that held the deleted/moved files | 1764 | // Re-enable watching on the dirs that held the deleted/moved files | ||
1769 | if (d->m_mode == CopyJob::Move) { | 1765 | if (d->m_mode == CopyJob::Move) { | ||
1770 | for (QSet<QString>::const_iterator it = d->m_parentDirs.constBegin(); it != d->m_parentDirs.constEnd(); ++it) { | 1766 | for (QSet<QString>::const_iterator it = d->m_parentDirs.constBegin(); it != d->m_parentDirs.constEnd(); ++it) { | ||
1771 | KDirWatch::self()->restartDirScan(*it); | 1767 | KDirWatch::self()->addDir(*it); | ||
1772 | } | 1768 | } | ||
1773 | } | 1769 | } | ||
1774 | Job::emitResult(); | 1770 | Job::emitResult(); | ||
1775 | } | 1771 | } | ||
1776 | 1772 | | |||
1777 | void CopyJobPrivate::slotProcessedSize(KJob *, qulonglong data_size) | 1773 | void CopyJobPrivate::slotProcessedSize(KJob *, qulonglong data_size) | ||
1778 | { | 1774 | { | ||
1779 | Q_Q(CopyJob); | 1775 | Q_Q(CopyJob); | ||
▲ Show 20 Lines • Show All 468 Lines • Show Last 20 Lines |