mirror of
https://github.com/nextcloud/desktop.git
synced 2024-11-27 09:30:13 +03:00
Setup of local folder with initial sync
This commit is contained in:
parent
5a42aa3028
commit
e0f8499484
5 changed files with 68 additions and 20 deletions
|
@ -187,7 +187,7 @@ void Application::slotAddFolder()
|
||||||
SitecopyConfig scConfig;
|
SitecopyConfig scConfig;
|
||||||
|
|
||||||
scConfig.writeSiteConfig( _folderWizard->field("sourceFolder").toString(), /* local path */
|
scConfig.writeSiteConfig( _folderWizard->field("sourceFolder").toString(), /* local path */
|
||||||
alias, /* _folderWizard->field("OCSiteAlias").toString(), site alias */
|
alias,
|
||||||
_folderWizard->field("OCUrl").toString(), /* site URL */
|
_folderWizard->field("OCUrl").toString(), /* site URL */
|
||||||
_folderWizard->field("OCUser").toString(),
|
_folderWizard->field("OCUser").toString(),
|
||||||
_folderWizard->field("OCPasswd").toString(),
|
_folderWizard->field("OCPasswd").toString(),
|
||||||
|
|
|
@ -19,7 +19,7 @@
|
||||||
|
|
||||||
#include "owncloudsetup.h"
|
#include "owncloudsetup.h"
|
||||||
#include "mirall/sitecopyconfig.h"
|
#include "mirall/sitecopyconfig.h"
|
||||||
|
#include "mirall/sitecopyfolder.h"
|
||||||
|
|
||||||
namespace Mirall {
|
namespace Mirall {
|
||||||
|
|
||||||
|
@ -257,7 +257,7 @@ bool OwncloudSetup::checkOwncloudAdmin( const QString& bin )
|
||||||
|
|
||||||
void OwncloudSetup::setupLocalSyncFolder()
|
void OwncloudSetup::setupLocalSyncFolder()
|
||||||
{
|
{
|
||||||
QString syncFolder( QDir::homePath() + "/ownCloud" );
|
const QString syncFolder( QDir::homePath() + "/ownCloud" );
|
||||||
qDebug() << "Setup local sync folder " << syncFolder;
|
qDebug() << "Setup local sync folder " << syncFolder;
|
||||||
QDir fi( syncFolder );
|
QDir fi( syncFolder );
|
||||||
_ocWizard->appendToResultWidget( tr("creating local sync folder %1").arg(syncFolder) );
|
_ocWizard->appendToResultWidget( tr("creating local sync folder %1").arg(syncFolder) );
|
||||||
|
@ -283,16 +283,10 @@ void OwncloudSetup::setupLocalSyncFolder()
|
||||||
ownCloudPasswd(),
|
ownCloudPasswd(),
|
||||||
targetPath );
|
targetPath );
|
||||||
|
|
||||||
// create a mirall folder entry.
|
// now there is the sitecopy config. A fetch in to the newly created folder mirrors
|
||||||
// FIXME: folderConfigPath is a method of application object, copied to here.
|
// the files from the ownCloud to local
|
||||||
const QString folderConfigPath = QDesktopServices::storageLocation(QDesktopServices::DataLocation) + "/folders";
|
startFetchFromOC( syncFolder );
|
||||||
|
|
||||||
QSettings settings(folderConfigPath + "/ownCloud", QSettings::IniFormat);
|
|
||||||
settings.setValue("folder/backend", "sitecopy");
|
|
||||||
settings.setValue("folder/path", syncFolder );
|
|
||||||
settings.setValue("backend:sitecopy/targetPath", targetPath );
|
|
||||||
settings.setValue("backend:sitecopy/alias", "ownCloud" );
|
|
||||||
settings.sync();
|
|
||||||
|
|
||||||
} else {
|
} else {
|
||||||
qDebug() << "Failed to create " << fi.path();
|
qDebug() << "Failed to create " << fi.path();
|
||||||
|
@ -300,5 +294,43 @@ void OwncloudSetup::setupLocalSyncFolder()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void OwncloudSetup::startFetchFromOC( const QString& syncFolder )
|
||||||
|
{
|
||||||
|
_scf = new SiteCopyFolder( "ownCloud",
|
||||||
|
syncFolder,
|
||||||
|
QString(),
|
||||||
|
this);
|
||||||
|
connect( _scf, SIGNAL( syncFinished( const SyncResult& )),
|
||||||
|
SLOT( slotFetchFinished( const SyncResult& )));
|
||||||
|
_ocWizard->appendToResultWidget( tr("Starting initial fetch of ownCloud data..."));
|
||||||
|
_scf->fetchFromOC();
|
||||||
|
}
|
||||||
|
|
||||||
|
void OwncloudSetup::slotFetchFinished( const SyncResult& res )
|
||||||
|
{
|
||||||
|
qDebug() << "Initial fetch finished!";
|
||||||
|
if( res.result() == SyncResult::Error ) {
|
||||||
|
_ocWizard->appendToResultWidget( tr("Initial fetch of data failed: ") + res.errorString() );
|
||||||
|
} else {
|
||||||
|
// fetch of data from ownCloud succeeded.
|
||||||
|
_ocWizard->appendToResultWidget( tr("Initial fetch of data succeeded.") );
|
||||||
|
_ocWizard->appendToResultWidget( tr("Writing mirall folder setting now.") );
|
||||||
|
// create a mirall folder entry.
|
||||||
|
// FIXME: folderConfigPath is a method of application object, copied to here.
|
||||||
|
const QString folderConfigPath = QDesktopServices::storageLocation(QDesktopServices::DataLocation) + "/folders";
|
||||||
|
|
||||||
|
const QString syncFolder( QDir::homePath() + "/ownCloud" );
|
||||||
|
const QString targetPath("/");
|
||||||
|
|
||||||
|
QSettings settings(folderConfigPath + "/ownCloud", QSettings::IniFormat);
|
||||||
|
settings.setValue("folder/backend", "sitecopy");
|
||||||
|
settings.setValue("folder/path", syncFolder );
|
||||||
|
settings.setValue("backend:sitecopy/targetPath", targetPath );
|
||||||
|
settings.setValue("backend:sitecopy/alias", "ownCloud" );
|
||||||
|
settings.sync();
|
||||||
|
}
|
||||||
|
_scf->deleteLater();
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
#include "owncloudsetup.moc"
|
#include "owncloudsetup.moc"
|
||||||
|
|
|
@ -23,6 +23,8 @@
|
||||||
|
|
||||||
namespace Mirall {
|
namespace Mirall {
|
||||||
|
|
||||||
|
class SiteCopyFolder;
|
||||||
|
class SyncResult;
|
||||||
|
|
||||||
class OwncloudSetup : public QObject
|
class OwncloudSetup : public QObject
|
||||||
{
|
{
|
||||||
|
@ -40,6 +42,8 @@ public:
|
||||||
|
|
||||||
QString mirallConfigFile() const;
|
QString mirallConfigFile() const;
|
||||||
|
|
||||||
|
void startFetchFromOC( const QString& );
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* returns the configured owncloud url if its already configured, otherwise an empty
|
* returns the configured owncloud url if its already configured, otherwise an empty
|
||||||
* string.
|
* string.
|
||||||
|
@ -62,6 +66,7 @@ protected slots:
|
||||||
void slotError( QProcess::ProcessError );
|
void slotError( QProcess::ProcessError );
|
||||||
void slotStarted();
|
void slotStarted();
|
||||||
void slotFinished( int, QProcess::ExitStatus );
|
void slotFinished( int, QProcess::ExitStatus );
|
||||||
|
void slotFetchFinished( const SyncResult& );
|
||||||
|
|
||||||
// wizard dialog signals
|
// wizard dialog signals
|
||||||
void slotInstallOCServer();
|
void slotInstallOCServer();
|
||||||
|
@ -74,6 +79,7 @@ private:
|
||||||
|
|
||||||
OwncloudWizard *_ocWizard;
|
OwncloudWizard *_ocWizard;
|
||||||
QProcess *_process;
|
QProcess *_process;
|
||||||
|
SiteCopyFolder *_scf;
|
||||||
};
|
};
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|
|
@ -24,10 +24,10 @@
|
||||||
|
|
||||||
namespace Mirall {
|
namespace Mirall {
|
||||||
|
|
||||||
SiteCopyFolder::SiteCopyFolder(const QString &alias,
|
SiteCopyFolder::SiteCopyFolder( const QString &alias,
|
||||||
const QString &path,
|
const QString &path,
|
||||||
const QString &secondPath,
|
const QString &secondPath,
|
||||||
QObject *parent)
|
QObject *parent)
|
||||||
: Folder(alias, path, parent),
|
: Folder(alias, path, parent),
|
||||||
_SiteCopy(new QProcess(this)),
|
_SiteCopy(new QProcess(this)),
|
||||||
_syncCount(0)
|
_syncCount(0)
|
||||||
|
@ -72,9 +72,16 @@ void SiteCopyFolder::startSync(const QStringList &pathList)
|
||||||
emit syncStarted();
|
emit syncStarted();
|
||||||
qDebug() << "PATHLIST: " << pathList;
|
qDebug() << "PATHLIST: " << pathList;
|
||||||
|
|
||||||
startSiteCopy( "--fetch", Status );
|
startSiteCopy( "--fetch", FlatList );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void SiteCopyFolder::fetchFromOC()
|
||||||
|
{
|
||||||
|
QMutexLocker locker( &_syncMutex );
|
||||||
|
qDebug() << "starting to sync from ownCloud";
|
||||||
|
|
||||||
|
startSiteCopy( "--fetch", Sync );
|
||||||
|
}
|
||||||
|
|
||||||
void SiteCopyFolder::startSiteCopy( const QString& command, SiteCopyState nextState )
|
void SiteCopyFolder::startSiteCopy( const QString& command, SiteCopyState nextState )
|
||||||
{
|
{
|
||||||
|
@ -141,8 +148,8 @@ void SiteCopyFolder::slotFinished(int exitCode, QProcess::ExitStatus exitStatus)
|
||||||
} else if( _NextStep == Status ) {
|
} else if( _NextStep == Status ) {
|
||||||
startSiteCopy( "--fetch", FlatList );
|
startSiteCopy( "--fetch", FlatList );
|
||||||
} else if( _NextStep == FlatList ) {
|
} else if( _NextStep == FlatList ) {
|
||||||
startSiteCopy( "--flatlist", DisplayStatus );
|
startSiteCopy( "--flatlist", ExecuteStatus );
|
||||||
} else if( _NextStep == DisplayStatus ) {
|
} else if( _NextStep == ExecuteStatus ) {
|
||||||
if( exitCode == 1 ) {
|
if( exitCode == 1 ) {
|
||||||
qDebug() << "Exit-Code: Sync Needed!";
|
qDebug() << "Exit-Code: Sync Needed!";
|
||||||
analyzeStatus();
|
analyzeStatus();
|
||||||
|
|
|
@ -29,7 +29,7 @@ class SiteCopyFolder : public Folder
|
||||||
{
|
{
|
||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
public:
|
public:
|
||||||
enum SiteCopyState { Sync, Update, Finish, Status, FlatList, DisplayStatus };
|
enum SiteCopyState { Sync, Update, Finish, Status, FlatList, ExecuteStatus };
|
||||||
|
|
||||||
SiteCopyFolder(const QString &alias,
|
SiteCopyFolder(const QString &alias,
|
||||||
const QString &path,
|
const QString &path,
|
||||||
|
@ -38,6 +38,9 @@ public:
|
||||||
|
|
||||||
virtual void startSync(const QStringList &pathList);
|
virtual void startSync(const QStringList &pathList);
|
||||||
|
|
||||||
|
// load data from ownCloud to the local directory.
|
||||||
|
void fetchFromOC();
|
||||||
|
|
||||||
virtual bool isBusy() const;
|
virtual bool isBusy() const;
|
||||||
|
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue