Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

WIP: Read default folder configuration from a file on the server #6761

Closed
wants to merge 1 commit into from

Conversation

ogoffart
Copy link
Contributor

@ogoffart ogoffart commented Sep 3, 2018

This commit will read a file called .desktopclientconfig at the root
of the webdav, while running the wizard, before showing the last page.

If the file exist and contains a list of default folder to configure,
hide all the option to configure the remote folders, as the default
configurtation will be applied.

screenshot_20180903_112503

The config file should contains a json object. The currently supported
config can be seen in this these example:

{ "default_folders": [
    {
        "remote_folder" : "Documents",
        "black_list" :  [ "Archives/1999", "Archives/1998" ]
    },
    {  "remote_folder": "Music"  }
]}

The default_folders property is a list of folder configuration. The
remote_folder property is the path of the folder on the remote. The
black_list property is a list of entries for the "choose what to sync".

@ogoffart
Copy link
Contributor Author

ogoffart commented Sep 3, 2018

@michaelstingl Before continuing, it would be nice to know the use case of what should be configured.

@ChrisEdS
Copy link

ChrisEdS commented Sep 4, 2018

Is it also possible to set a default local folder with this .desktopclientconfig file?

@michaelstingl
Copy link
Contributor

@ChrisEdS We'll collect the requirements in a different issue…

@ogoffart
Copy link
Contributor Author

@michaelstingl Can you please create an issue tracking what needs to be configured?

This commit will read a file called `.desktopclientconfig` at the root
of the webdav, while running the wizard, before showing the last page.

If the file exist and contains a list of default folder to configure,
hide all the option to configure the remote folders, as the default
configurtation will be applied.

The config file should contains a json object. The currently supported
config can be seen in this these example:

```
{ "default_folders": [
    {
        "remote_folder" : "Documents",
        "black_list" :  [ "Archives/1999", "Archives/1998" ]
    },
    {  "remote_folder": "Music"  }
]}
```

The `default_folders` property is a list of folder configuration. The
`remote_folder` property is the path of the folder on the remote. The
`black_list` property is a list of entries for the "choose what to sync".
Copy link
Contributor

@ckamm ckamm left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Initial review of wip version

@@ -353,7 +353,35 @@ void OwncloudSetupWizard::testOwnCloudConnect()
// so don't automatically follow redirects.
job->setFollowRedirects(false);
job->setProperties(QList<QByteArray>() << "getlastmodified");
connect(job, &PropfindJob::result, _ocWizard, &OwncloudWizard::successfulStep);
connect(job, &PropfindJob::result, this, [this, account] {
auto *job2 = account->sendRequest("GET", Utility::concatUrlPath(account->davUrl(), ".desktopclientconfig"));
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I would prefer if this didn't store the configuration in a user-visible / editable file. I understand getting support on the server may be hard/limiting, and that this may be a reasonable tradeoff, but:

  • users will change / delete this file
  • users will think this contains their current desktop client configuration when it doesn't

@@ -353,7 +353,35 @@ void OwncloudSetupWizard::testOwnCloudConnect()
// so don't automatically follow redirects.
job->setFollowRedirects(false);
job->setProperties(QList<QByteArray>() << "getlastmodified");
connect(job, &PropfindJob::result, _ocWizard, &OwncloudWizard::successfulStep);
connect(job, &PropfindJob::result, this, [this, account] {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I would prefer if the code for triggering and handling the request checking the server here was a separate function. At least it must have a comment explaining what's going on.

@@ -362,7 +390,7 @@ void OwncloudSetupWizard::slotAuthError()
{
QString errorMsg;

PropfindJob *job = qobject_cast<PropfindJob *>(sender());
AbstractNetworkJob *job = qobject_cast<AbstractNetworkJob *>(sender());
if (!job) {
qCWarning(lcWizard) << "Can't check for authed redirects. This slot should be invoked from PropfindJob!";
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Also update this warning

@@ -610,32 +638,62 @@ void OwncloudSetupWizard::slotAssistantFinished(int result)
FolderMan *folderMan = FolderMan::instance();
auto account = applyAccountChanges();

QJsonDocument configJson = account->account()->property("oc_serverConfig").toJsonDocument();
bool hasServerConfig = configJson.isObject() && !configJson.object()["default_folders"].toArray().isEmpty();
qWarning() << configJson << hasServerConfig;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

qCWarning()

// The user already accepted the selective sync dialog. everything is in the white list
f->journalDb()->setSelectiveSyncList(SyncJournalDb::SelectiveSyncWhiteList,
QStringList() << QLatin1String("/"));
if (!hasServerConfig) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is getting very deeply nested. Split the two branches into functions?

auto f = folderMan->addFolder(account, folderDefinition);
if (f) {
if (folderDefinition.virtualFilesMode != Vfs::Off && _ocWizard->useVirtualFileSync())
f->setNewFilesAreVirtual(true);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can be removed I think. folderDefinition.virtualFilesMode is never set and useVirtualFileSync() an't be true.

_ui.rSelectiveSync->setVisible(!hasServerConfig);
_ui.bSelectiveSync->setVisible(!hasServerConfig);
_ui.lSelectiveSyncSizeLabel->setVisible(!hasServerConfig);
_ui.rVirtualFileSync->setVisible(!hasServerConfig && Theme::instance()->showVirtualFilesOption() && bestAvailableVfsMode() != Vfs::Off);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

As far as I remember removing the layout from the wSyncStrategy widget was required for making the layout not be broken on some platforms. May need testing.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

6 participants