+
+ if (m_statJob) {
+ if (destUrl == m_statJobUrl) {
+ // We already received events for this URL. Still waiting for
+ // the stat result. StatJob will process the event when it finishes.
+ m_lastUndecidedEvent = event;
+ return;
+ }
+
+ // We are waiting for the stat result of a different URL. Cancel.
+ m_statJob->kill();
+ m_statJob = nullptr;
+ m_statJobUrl.clear();
+ }
+
+ if (destUrl.isLocalFile()) {
+ // New local URL. KFileItem will stat on demand.
+ m_destItemCache = KFileItem(destUrl);
+ m_destItemCacheInvalidationTimer.start();
+ processEvent(event);
+ return;
+ }
+
+ // New remote URL. Start a StatJob and process the event when it finishes.
+ m_lastUndecidedEvent = event;
+ m_statJob = KIO::stat(destUrl, KIO::StatJob::SourceSide, KIO::StatDetail::StatBasic, KIO::JobFlag::HideProgressInfo);
+ m_statJobUrl = destUrl;
+ connect(m_statJob, &KIO::StatJob::result, this, [this, processEvent](KJob *job) {
+ KIO::StatJob *statJob = static_cast<KIO::StatJob *>(job);
+
+ m_destItemCache = KFileItem(statJob->statResult(), m_statJobUrl);
+ m_destItemCacheInvalidationTimer.start();
+
+ if (m_lastUndecidedEvent) {
+ processEvent(m_lastUndecidedEvent);
+ m_lastUndecidedEvent = nullptr;
+ }
+
+ m_statJob = nullptr;
+ m_statJobUrl.clear();
+ });