зеркало из https://github.com/nextcloud/desktop.git
The unison folder class.
May be factor it out in a external process tool folder type later.
This commit is contained in:
Родитель
25685de4fd
Коммит
f42169a8fc
|
@ -11,6 +11,7 @@ mirall/folderwatcher.cpp
|
|||
mirall/gitfolder.cpp
|
||||
mirall/inotify.cpp
|
||||
mirall/temporarydir.cpp
|
||||
mirall/unisonfolder.cpp
|
||||
)
|
||||
qt4_automoc(${mirall_SRCS})
|
||||
|
||||
|
|
|
@ -23,15 +23,20 @@ Folder::Folder(const QString &path, QObject *parent)
|
|||
SLOT(slotChanged(const QString &)));
|
||||
}
|
||||
|
||||
Folder::~Folder()
|
||||
{
|
||||
}
|
||||
|
||||
QString Folder::path() const
|
||||
{
|
||||
return _path;
|
||||
}
|
||||
|
||||
QAction * Folder::action() const
|
||||
{
|
||||
return _action;
|
||||
}
|
||||
|
||||
Folder::~Folder()
|
||||
{
|
||||
}
|
||||
|
||||
void Folder::slotChanged(const QString &path)
|
||||
{
|
||||
//qDebug() << "path " << path << " changed";
|
||||
|
|
|
@ -18,6 +18,8 @@ public:
|
|||
Folder(const QString &path, QObject *parent = 0L);
|
||||
virtual ~Folder();
|
||||
|
||||
QString path() const;
|
||||
|
||||
QAction *action() const;
|
||||
|
||||
/**
|
||||
|
|
|
@ -0,0 +1,45 @@
|
|||
#include <QMutexLocker>
|
||||
#include <QProcess>
|
||||
#include <QStringList>
|
||||
#include "mirall/unisonfolder.h"
|
||||
|
||||
namespace Mirall {
|
||||
|
||||
UnisonFolder::UnisonFolder(const QString &path, const QString &secondPath, QObject *parent)
|
||||
: Folder(path, parent),
|
||||
_unison(new QProcess(this)),
|
||||
_secondPath(secondPath)
|
||||
{
|
||||
}
|
||||
|
||||
UnisonFolder::~UnisonFolder()
|
||||
{
|
||||
}
|
||||
|
||||
QString UnisonFolder::secondPath() const
|
||||
{
|
||||
return _secondPath;
|
||||
}
|
||||
|
||||
void UnisonFolder::startSync()
|
||||
{
|
||||
QMutexLocker locker(&_syncMutex);
|
||||
|
||||
QString program = "unison";
|
||||
QStringList args;
|
||||
args << "-ui" << "text";
|
||||
args << "-auto" << "-batch";
|
||||
args << "-confirmbigdel";
|
||||
//args << "-path";
|
||||
args << path();
|
||||
args << secondPath();
|
||||
|
||||
_unison->start(program, args);
|
||||
|
||||
emit syncStarted();
|
||||
emit syncFinished();
|
||||
}
|
||||
|
||||
} // ns
|
||||
|
||||
#include "unisonfolder.moc"
|
|
@ -0,0 +1,29 @@
|
|||
#ifndef MIRALL_UNISONFOLDER_H
|
||||
#define MIRALL_UNISONFOLDER_H
|
||||
|
||||
#include <QMutex>
|
||||
#include "mirall/folder.h"
|
||||
|
||||
class QProcess;
|
||||
|
||||
namespace Mirall {
|
||||
|
||||
class UnisonFolder : public Folder
|
||||
{
|
||||
public:
|
||||
UnisonFolder(const QString &path, const QString &secondPath, QObject *parent = 0L);
|
||||
virtual ~UnisonFolder();
|
||||
|
||||
QString secondPath() const;
|
||||
|
||||
virtual void startSync();
|
||||
|
||||
private:
|
||||
QMutex _syncMutex;
|
||||
QProcess *_unison;
|
||||
QString _secondPath;
|
||||
};
|
||||
|
||||
}
|
||||
|
||||
#endif
|
Загрузка…
Ссылка в новой задаче