mirror of
https://github.com/nextcloud/desktop.git
synced 2024-11-21 20:45:51 +03:00
Check if local folder is proper and set error stat accordingly.
This commit is contained in:
parent
4d08605b5b
commit
fbb46b64f9
3 changed files with 35 additions and 12 deletions
|
@ -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();
|
||||
|
|
Loading…
Reference in a new issue