mirror of
https://github.com/nextcloud/desktop.git
synced 2025-10-26 11:17:43 +00:00
Use a hash to store inotified pathes.
This commit is contained in:
parent
d2f989566d
commit
07cfc08823
@ -184,6 +184,7 @@ void Folder::slotOnlineChanged(bool online)
|
||||
|
||||
void Folder::slotChanged(const QStringList &pathList)
|
||||
{
|
||||
qDebug() << "** Changed was notified on " << pathList;
|
||||
evaluateSync(pathList);
|
||||
}
|
||||
|
||||
|
||||
@ -87,7 +87,7 @@ void FolderWatcher::setEventsEnabled(bool enabled)
|
||||
_eventsEnabled = enabled;
|
||||
if (_eventsEnabled) {
|
||||
// schedule a queue cleanup for accumulated events
|
||||
if ( _pendingPaths.empty() )
|
||||
if ( _pendingPathes.empty() )
|
||||
return;
|
||||
setProcessTimer();
|
||||
}
|
||||
@ -103,7 +103,7 @@ void FolderWatcher::clearPendingEvents()
|
||||
{
|
||||
if (_processTimer->isActive())
|
||||
_processTimer->stop();
|
||||
_pendingPaths.clear();
|
||||
_pendingPathes.clear();
|
||||
}
|
||||
|
||||
int FolderWatcher::eventInterval() const
|
||||
@ -161,6 +161,7 @@ void FolderWatcher::slotINotifyEvent(int mask, int cookie, const QString &path)
|
||||
_lastMask = mask;
|
||||
_lastPath = path;
|
||||
|
||||
qDebug() << "***************** Inotify Event " << mask << " on " << path;
|
||||
// cancel close write events that come after create
|
||||
if (lastMask == IN_CREATE && mask == IN_CLOSE_WRITE
|
||||
&& lastPath == path ) {
|
||||
@ -210,16 +211,24 @@ void FolderWatcher::slotINotifyEvent(int mask, int cookie, const QString &path)
|
||||
}
|
||||
}
|
||||
|
||||
if( !_pendingPathes.contains( path )) {
|
||||
_pendingPathes[path] = 0;
|
||||
}
|
||||
_pendingPathes[path] = _pendingPathes[path]+mask;
|
||||
#if 0
|
||||
_pendingPaths[path]
|
||||
_pendingPaths.append(path);
|
||||
#endif
|
||||
setProcessTimer();
|
||||
}
|
||||
|
||||
void FolderWatcher::slotProcessTimerTimeout()
|
||||
{
|
||||
qDebug() << "* Processing of event queue for" << root();
|
||||
if (!_pendingPaths.empty() || !_initialSyncDone) {
|
||||
QStringList notifyPaths(_pendingPaths);
|
||||
_pendingPaths.clear();
|
||||
|
||||
if (!_pendingPathes.empty() || !_initialSyncDone) {
|
||||
QStringList notifyPaths = _pendingPathes.keys();
|
||||
_pendingPathes.clear();
|
||||
//qDebug() << lastEventTime << eventTime;
|
||||
qDebug() << " * Notify" << notifyPaths.size() << "changed items for" << root();
|
||||
emit folderChanged(notifyPaths);
|
||||
@ -230,7 +239,7 @@ void FolderWatcher::slotProcessTimerTimeout()
|
||||
void FolderWatcher::setProcessTimer()
|
||||
{
|
||||
if (!_processTimer->isActive()) {
|
||||
qDebug() << "* Pending events for" << root() << "will be processed after events stop for" << eventInterval() << "seconds (" << QTime::currentTime().addSecs(eventInterval()).toString("HH:mm:ss") << ")." << _pendingPaths.size() << "events until now )";
|
||||
qDebug() << "* Pending events for" << root() << "will be processed after events stop for" << eventInterval() << "seconds (" << QTime::currentTime().addSecs(eventInterval()).toString("HH:mm:ss") << ")." << _pendingPathes.size() << "events until now )";
|
||||
}
|
||||
_processTimer->start(eventInterval() * 1000);
|
||||
}
|
||||
|
||||
@ -20,6 +20,7 @@
|
||||
#include <QString>
|
||||
#include <QStringList>
|
||||
#include <QTime>
|
||||
#include <QHash>
|
||||
|
||||
class QTimer;
|
||||
class INotify;
|
||||
@ -115,7 +116,8 @@ private:
|
||||
INotify *_inotify;
|
||||
QString _root;
|
||||
// paths pending to notified
|
||||
QStringList _pendingPaths;
|
||||
// QStringList _pendingPaths;
|
||||
QHash<QString, int> _pendingPathes;
|
||||
|
||||
QTimer *_processTimer;
|
||||
|
||||
|
||||
@ -63,7 +63,7 @@ void ownCloudFolder::startSync(const QStringList &pathList)
|
||||
/* Fix the url and remove user and password */
|
||||
QUrl url( _secondPath );
|
||||
url.setScheme( "owncloud" );
|
||||
qDebug() << "Second path: " << url.toEncoded();
|
||||
qDebug() << "*** Start syncing to ownCloud";
|
||||
|
||||
_csync = new CSyncThread(path(), url.toEncoded() );
|
||||
QObject::connect(_csync, SIGNAL(started()), SLOT(slotCSyncStarted()));
|
||||
|
||||
Loading…
Reference in New Issue
Block a user