Skip to content

Commit

Permalink
fix signatures for slots, more debug output from time comparison
Browse files Browse the repository at this point in the history
  • Loading branch information
sandsmark committed May 21, 2010
1 parent 0d75299 commit 0222927
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 12 deletions.
21 changes: 12 additions & 9 deletions src/dirsyncer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -22,9 +22,9 @@ DirSyncer::DirSyncer(KUrl localPath, KUrl remotePath)
{
qDebug() << "remote dir" << remotePath;
qDebug() << "local dir" << localPath;
connect(&m_dirWatcher, SIGNAL(dirty(QString)), SLOT(checkDirty(KUrl)));
connect(&m_dirWatcher, SIGNAL(created(QString)), SLOT(checkCreated(KUrl)));
connect(&m_dirWatcher, SIGNAL(deleted(QString)), SLOT(checkDeleted(KUrl)));
connect(&m_dirWatcher, SIGNAL(dirty(QString)), SLOT(checkDirty(QString)));
connect(&m_dirWatcher, SIGNAL(created(QString)), SLOT(checkCreated(QString)));
connect(&m_dirWatcher, SIGNAL(deleted(QString)), SLOT(checkDeleted(QString)));

//TODO: Check for remote folder, and add magic so we avoid stating all the time
m_dirWatcher.addDir(localPath.url(), KDirWatch::WatchSubDirs | KDirWatch::WatchFiles);
Expand All @@ -35,8 +35,9 @@ DirSyncer::DirSyncer(KUrl localPath, KUrl remotePath)
QMetaObject::invokeMethod(this, SLOT(compareDirs()), Qt::QueuedConnection);
}

void DirSyncer::checkDeleted(KUrl url)
void DirSyncer::checkDeleted(QString u)
{
KUrl url(u);
KUrl parentDir;
bool isLocal;
if (m_localPath.isParentOf(url)) {
Expand All @@ -59,14 +60,15 @@ void DirSyncer::checkDeleted(KUrl url)

}

void DirSyncer::checkCreated(KUrl url)
void DirSyncer::checkCreated(QString url)
{
//TODO
checkDirty(url);
}

void DirSyncer::checkDirty(KUrl url)
void DirSyncer::checkDirty(QString u)
{
KUrl url(u);
qDebug() << "FILTHY ANIMAL: " << url;
KUrl parent;

Expand Down Expand Up @@ -135,9 +137,10 @@ void DirSyncer::compareDirs(QString subdir)
KDateTime remoteTime = getModificationTime(remoteUrl);
KDateTime localTime = getModificationTime(localUrl);

if (remoteTime.toTime_t() > localTime.toTime_t()) // If the local dir is changed last, we assume we deleted something
if (remoteTime > localTime) { // If the local dir is changed last, we assume we deleted something
kDebug() << "Remote: " << remoteTime.toTime_t() << " local: " << localTime.toTime_t();
download(item.url());
else {
} else {
//KIO::del(remoteUrl); UNCOMMENT WHEN ABSOLUFREAKINGLUTELY SURE IT IS CORRECT!
qWarning() << "I almost deleted " << remoteUrl;
}
Expand Down Expand Up @@ -210,7 +213,7 @@ void DirSyncer::upload(KUrl file)

void DirSyncer::launchTransfer(KUrl from, KUrl to)
{
//TODO: queue these internally
//TODO: add to a composite job so they get scheduled
KIO::CopyJob *job = KIO::copy(from, to, KIO::Overwrite | KIO::HideProgressInfo);
job->setWriteIntoExistingDirectories(true);
connect(job, SIGNAL(result(KJob*)), this, SLOT(cleanJobs(KJob*)));
Expand Down
6 changes: 3 additions & 3 deletions src/dirsyncer.h
Original file line number Diff line number Diff line change
Expand Up @@ -33,9 +33,9 @@ public slots:

private slots:
void cleanJobs(KJob* completed);
void checkDirty(KUrl url);
void checkDeleted(KUrl url);
void checkCreated(KUrl url);
void checkDirty(QString url);
void checkDeleted(QString url);
void checkCreated(QString url);

private:
void launchTransfer(KUrl from, KUrl to);
Expand Down

0 comments on commit 0222927

Please sign in to comment.