Check if local folder is proper and set error stat accordingly.

This commit is contained in:
Klaas Freitag 2012-10-30 12:42:17 +01:00
Родитель 4d08605b5b
Коммит fbb46b64f9
3 изменённых файлов: 35 добавлений и 12 удалений

Просмотреть файл

@ -70,18 +70,47 @@ Folder::Folder(const QString &alias, const QString &path, const QString& secondP
_online = true;
#endif
_pathWatcher = new QFileSystemWatcher(this);
_pathWatcher->addPath( _path );
connect(_pathWatcher, SIGNAL(directoryChanged(QString)),SLOT(slotLocalPathChanged(QString)));
_syncResult.setStatus( SyncResult::NotYetStarted );
// check if the local path exists
checkLocalPath();
}
Folder::~Folder()
{
}
void Folder::checkLocalPath()
{
QFileInfo fi(_path);
if( fi.isDir() && fi.isReadable() ) {
qDebug() << "Checked local path ok";
} else {
_syncResult.setStatus( SyncResult::SetupError );
setSyncEnabled(false);
if( !fi.exists() ) {
_syncResult.setErrorString(tr("The local folder %1 does not exist.").arg(_path));
} else {
if( !fi.isDir() ) {
_syncResult.setErrorString(tr("Path %1 should be a directory but is not.").arg(_path));
} else if( !fi.isReadable() ) {
_syncResult.setErrorString(tr("Path %1 is not readable.").arg(_path));
}
}
}
// if all is fine, connect a FileSystemWatcher
if( _syncResult.status() != SyncResult::SetupError ) {
_pathWatcher = new QFileSystemWatcher(this);
_pathWatcher->addPath( _path );
connect(_pathWatcher, SIGNAL(directoryChanged(QString)),
SLOT(slotLocalPathChanged(QString)));
}
}
QString Folder::alias() const
{
return _alias;

Просмотреть файл

@ -192,6 +192,8 @@ private:
*/
void evaluateSync(const QStringList &pathList);
virtual void checkLocalPath();
QString _path;
QString _secondPath;
QString _alias;

Просмотреть файл

@ -169,14 +169,6 @@ Folder* FolderMan::setupFolderFromConfigFile(const QString &file) {
settings.beginGroup( escapedAlias ); // read the group with the same name as the file which is the folder alias
QString path = settings.value(QLatin1String("localpath")).toString();
if ( path.isNull() || !QFileInfo( path ).isDir() ) {
qWarning() << " `->" << path << "does not exist. Skipping folder" << file;
// _tray->showMessage(tr("Unknown folder"),
// tr("Folder %1 does not exist").arg(path.toString()),
// QSystemTrayIcon::Critical);
return folder;
}
QString backend = settings.value(QLatin1String("backend")).toString();
QString targetPath = settings.value( QLatin1String("targetPath") ).toString();
// QString connection = settings.value( QLatin1String("connection") ).toString();