Skip to content

Conversation

imsodin
Copy link
Member

@imsodin imsodin commented Nov 19, 2020

The PR is still WIP because of the to-dos below, but it is usable as it is right now.

The branch lives on top of #7127 (first three commits at the time of writing) - I would suggest looking at that first, however if you'd rather have one huge diff, it's available here :)

The defaults in proto are represented as normal FolderConfiguration/DeviceConfiguration messages. I added a new ext.nodefault proto extension/tag to mark fields which are not configurable (like the id). Those are used to ensure that they are at their zero value when committing a config change. Using the same type allows using it directly as a template for new folders/devices and means there's no duplication.

The defaults can be obtained and set through the rest api on rest/config/defaults/folder resp. .../device and that endpoint is used instead of the hardcoded values in the GUI (fixes #6068).

Changed defaults

If the defaults in the GUI did not match those in the config, I chose the GUI ones as those are the ones that were really in effect:

Folder:

  • max conflicts: -1 -> 10
  • min disk free: nothing/unlimited -> 1%

To-do

optional:

  • Somehow handle versioning defaults. Currently you can set default versioning for new folders including parameters, but not default parameters for the different versioning types. Not sure whether that's really necessary and the GUI versioning code is a bit messy/verbose, so haven't looked into that yet.

Testing

I extended the test checking defaults and did some manual fiddling around with config and UI, which looked good (but was likely far from comprehensive).

@tomasz1986
Copy link
Member

Does this also fix #6748 and #7033?

Folder:

  • max conflicts: -1 -> 10
  • min disk free: nothing/unlimited -> 1%

What about maxConcurrentWrites (supposed to be 2, but the GUI sets it to 0)?

@imsodin
Copy link
Member Author

imsodin commented Nov 20, 2020

That's not directly affected by this PR: The GUI didn't set it at all, like many other fields, which results in zero values. Handling that for maxConcurrentWrites has already been fixed in #7069

@imsodin
Copy link
Member Author

imsodin commented Dec 16, 2020

I adjusted the folder/device edit modals and accompanying JS to handle editing defaults too. Basically hid items for which defaults don't make sense (ids, remove buttons, ...).

They are accessible through the settings modal: Clicking on a button opens another modal to edit the settings, and dismissing that modal drops you back to the settings modal.

image

This is ready for review. Only thing left is mirroring the changes in the "untrusted GUI code".

@tomasz1986
Copy link
Member

They are accessible through the settings modal: Clicking on a button opens another modal to edit the settings, and dismissing that modal drops you back to the settings modal.

I have been trying to test, but nothing happens when trying to click any of those buttons. I have compiled from https://github.com/imsodin/syncthing/tree/all/defaultConfig and also checked a few different browsers (Chromium, IE, Palemoon), but there is no difference. No reaction at all, and no JS errors either.

@imsodin
Copy link
Member Author

imsodin commented Dec 17, 2020

Works fine for me on firefox and chromium (linux) - no idea what the problem could be. There's no new source file I have forgotten to check in, nor do I have a "gui" dir in my config (you probably don't either, as you're seeing the new buttons). To debug you could inspect the buttons using developer tools, they should have attributes like ng-click=editFolderDefaults(). If that's there, find that function (or it's absence) in syncthingController.js and add a breakpoint to see what happens (or doesn't).

The gui changes are now also applied to the untrusted files, i.e. this is fully ready now. Except of course we need to find out why it doesn't work for @tomasz1986 😬

@imsodin imsodin marked this pull request as ready for review December 17, 2020 11:04
@tomasz1986
Copy link
Member

tomasz1986 commented Dec 17, 2020

I have recompiled with the newest commits, and it is working now! I am not sure what the problem was about.

However, I have tried to fiddle around with the actual settings and something seems to be wrong…

  1. I set the folder defaults as follows.

image

image

  1. This is what I get when trying to create a new folder.

image

image

Also, just a side question, but I can see the current device's ID included under the defaults element in config.xml. Is there any reason or requirement for it to be there?

@imsodin
Copy link
Member Author

imsodin commented Dec 17, 2020

Thanks a lot @tomasz1986 !

I removed Options.DefaultFolderPath, that is now Defaults.Folder.Path. In the usage reporting I kept the variable, though it's a bit of an outlier now. Respectively we might add a new metric that checks for defaultFolder := config.FolderConfiguration; util.SetDefaults(&cfg); reflect.DeepEqual(Defaults.Folder, defaultFolder). However such a blanket check doesn't seem particularly insightful to me.

Also, just a side question, but I can see the current device's ID included under the defaults element in config.xml. Is there any reason or requirement for it to be there?

The local directory always is part of every folder, so to me it makes sense that it's also part of the default folder. All the gui and go code would add the local device anyway immediately if it was missing (i.e. there would have to be special code just to keep it out of the "default folder").

@tomasz1986
Copy link
Member

tomasz1986 commented Dec 18, 2020

I am not sure whether this is a complete version, but I have tested the current state anyway.

Right now, the File Versioning and Advanced settings seem to be applied fine. The folder ID is again placed in the proper field. The Folder Label is still empty though.

There is also this strange glitch.

  1. Set the default folder path to .\abc.
  2. Start adding new folder, but cancel before saving.
  3. The default folder path has now changed to .\abc\abc

@imsodin
Copy link
Member Author

imsodin commented Dec 18, 2020

I am not sure whether this is a complete version, but I have tested the current state anyway.

Except for the glitches you find - it is :)

There is also this strange glitch.

I cannot reproduce. Steps I took:

  1. Open folder defaults, set default folder path to \.abc, save.
  2. Click add folder. The displayed path is \.abc/*folder-id*.
  3. Click close.

Result: The path in both the add folder dialog and the default folder config dialog is still \.abc/*folder-id* resp. \.abc

Probably unrelated: .\abc is strange to me. Is \ a path separator here? And I do think relative paths work, as in "something happens" (and assume they are relative to the dir from which syncthing was started?), but it's not "on purpose", as in the desired behaviour is not defined and thus might change -> I would not recommend using it.

@tomasz1986
Copy link
Member

tomasz1986 commented Dec 18, 2020

It must be .\abc (or possibly ./abc, but not \.abc 😁), and yes, the \ is just a separator here, relative to the path, where Syncthing has been started. In most cases, I do use full paths, but using relative paths is handy for portable installations (e.g. on a USB stick).

Regardless of the relative paths, I think that I have found the culprit though.

  1. Set the default folder label to abc
  2. Set the default folder path to .

image

  1. Try creating a new folder, but do not save it.
  2. The default folder path has changed to .\abc.

image

The label is basically added to the path. Is this how it should behave? If yes, then why do we need both the label and the path?

I have also found another problem. When trying to add a folder, nothing is displayed under Sharing, even though I have multiple devices connected.

image

@tomasz1986
Copy link
Member

I have tested the commit in its current state. The folder path and folder sharing issues are gone 👏.

The only remaining problem that I can see at the moment is that default folder label does not seem to work at all. When trying to add a folder, the label is just empty, regardless of the default one.

@tomasz1986
Copy link
Member

tomasz1986 commented Dec 19, 2020

I have tested the newest iteration, and everything seems to work as intended 👍.

I have just two questions/comments.

  1. If you compare the folder defaults screen and the add folder screen, then there is one obvious difference. That is, there is no "Ignore patterns" tab in the former. I am not asking you to do it, but would there be any technical reason not to include default ignore patterns in config.xml too?

  2. Update lucas-clemente/quic-go sum #6068 seems to be a closed PR about a bug in QUIC. Is it really related/fixed by this commit?

@imsodin
Copy link
Member Author

imsodin commented Dec 19, 2020

  1. That mostly just feels out of scope for this PR: It takes existing config elements to store defaults. Ignores are not part of config. That could be made part of config, or as a separate file. Then there's the question whether we want defaults as in a template, or additionally "common" ignore patterns, as in patterns that act as if they were included. Basically a soon as you introduce ignores, it gets complicated/bikesheddy. Lets get this done and then we'll see what comes after ;)
  2. That's a typo indeed, should have been Default Folder uses different config than user-created folders #6086. And Folder defaults are not applied consistently on config migrations / new folders #6748 is at least related too.

@imsodin imsodin changed the title all: Add configurable defaults (fixes #4224, fixes #6068) all: Add configurable defaults (fixes #4224, fixes #6086) Dec 19, 2020
@tomasz1986
Copy link
Member

  1. Yeah, I was just thinking about what would be nice to have, regardless of the technical complexity. Especially since if you do integrate ignores like that, then then the question comes up, why do we need .stignore at all? Anyhow, as someone with tons of folders, I am definitely looking forward to having this PR implemented, no matter if without ignores.

  2. Please add Default Folder uses different config than user-created folders #7033 to the mix too 🙂. It is already partially fixed (regarding maxConcurrentWrites), and this commit fixes the rest.

$scope.editingDefaults = false;
return $http.get(urlbase + '/config/defaults/folder').then(function(p) {
$scope.currentFolder = p.data;
for (var k in $scope.versioningDefaults) {
Copy link
Member

Choose a reason for hiding this comment

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

Why are these not stored in the folder config?

Copy link
Member Author

Choose a reason for hiding this comment

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

Two parts: One was a bug in the current PR, the other is a conscious omission:
Bug: The default versioning type including params is stored in config.defaults.folder.versioning, however wasn't applied when adding a new folder. That's now fixed, along with moving the gui-only parameters into currentFolder._guiVersioning.
Omission: Versioning parameters are currently "free-form" (map[string]string), which prevents using ext.default in proto. The consistent thing to do would be creating proto types for all of these and adding a Config.Defaults.VersioningParams with a new map-like struct (type -> params). That just feels like a lot of work for little gain (defaults for something that's off by default).

@tomasz1986
Copy link
Member

tomasz1986 commented Jan 9, 2021

Do you think that it would be safe to use this commit as it is in production right now?

I have been doing a lot of folder reorganisation and such recently, and their configuration is a bit of a struggle. Do you expect any major changes in the future commits that could break the current state (e.g. changes to the config.xml structure, etc.)?

Copy link
Member

@calmh calmh left a comment

Choose a reason for hiding this comment

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

Awesome

@calmh calmh merged commit ffc14a7 into syncthing:main Feb 4, 2021
@calmh calmh added this to the v1.14.0 milestone Feb 4, 2021
@imsodin imsodin deleted the all/defaultConfig branch February 4, 2021 21:29
@acolomb
Copy link
Member

acolomb commented Feb 5, 2021

Was trying to check this out for local inspection. @imsodin I can't find this branch in your fork anymore?

Sorry for the noise, GitHub just didn't refresh the page...

@calmh
Copy link
Member

calmh commented Feb 8, 2021

The set of configurable options in the default settings dialog is somewhat limited; should these new pseudo-device/folders perhaps show up in the advanced config editor as well?

imsodin added a commit to imsodin/syncthing that referenced this pull request Feb 8, 2021
acolomb added a commit to acolomb/spksrc that referenced this pull request Mar 28, 2021
Utilize the newly introduced "folder default configuration" [1]
feature to preset the ignorePerms option to true.  This will not touch
any existing folders, but set the option when configuring a new folder
to be synced.

Specifically on DSM, the ignorePerms option should definitely be used
with every Syncthing folder.  Otherwise, it will possibly try to
override the UNIX permissions on synced files, which will reset the
ACL-based permissions on the content.  Possibly making them unusable
for the rest of the DSM services.

Note that this also only applies for new installations, because
config.xml is (and must be) kept during updates.

[1]: syncthing/syncthing#7131
publicarray pushed a commit to publicarray/spksrc that referenced this pull request Apr 13, 2021
Utilize the newly introduced "folder default configuration" [1]
feature to preset the ignorePerms option to true.  This will not touch
any existing folders, but set the option when configuring a new folder
to be synced.

Specifically on DSM, the ignorePerms option should definitely be used
with every Syncthing folder.  Otherwise, it will possibly try to
override the UNIX permissions on synced files, which will reset the
ACL-based permissions on the content.  Possibly making them unusable
for the rest of the DSM services.

Note that this also only applies for new installations, because
config.xml is (and must be) kept during updates.

[1]: syncthing/syncthing#7131
publicarray added a commit to SynoCommunity/spksrc that referenced this pull request Apr 15, 2021
…t. (#4527)

* syncthing: Incorporate upstream release v1.14.0.

Only package version and hashes updated.  Built successfully for
all-supported.

Note that the previous package version should have already
self-updated an installed Syncthing binary when the service was
running long enough.

* syncthing: Ignore permissions by default for new shared folders.

Utilize the newly introduced "folder default configuration" [1]
feature to preset the ignorePerms option to true.  This will not touch
any existing folders, but set the option when configuring a new folder
to be synced.

Specifically on DSM, the ignorePerms option should definitely be used
with every Syncthing folder.  Otherwise, it will possibly try to
override the UNIX permissions on synced files, which will reset the
ACL-based permissions on the content.  Possibly making them unusable
for the rest of the DSM services.

Note that this also only applies for new installations, because
config.xml is (and must be) kept during updates.

[1]: syncthing/syncthing#7131

* syncthing: Do not cache .stignore file patterns by default.

Change the default for the cacheIgnoredFiles option to false.  From
the Syncthing documentation [1]:

    Whether to cache the results of ignore pattern
    evaluation. Performance at the price of memory. Defaults to false
    as the cost for evaluating ignores is usually not significant.

The DiskStations are usually rather tight on RAM, so deviating from
Syncthing's default here is probably a bad idea for most users.  It
only matters when many (or very complex) ignore patterns are used in a
folder, so usually for power users.  Those will certainly be able to
change the option manually.

Note that this also only applies for new installations, because
config.xml is (and must be) kept during updates.

[1]: https://docs.syncthing.net/users/config.html

* syncthing: Remove / update obsolete default options.

Drop the symlinksEnabled and weakHashSelectionMethod entries from the
default config file template.  See [1] and [2].

Switch from the minHomeDiskFreePct option to the new syntax
minHomeDiskFree unit="%".

Note that this also only applies for new installations, because
config.xml is (and must be) kept during updates.  Syncthing migrates
old configuration formats on its own.

[1]: syncthing/docs@392dbd0b
[2]: syncthing/syncthing#4767

* syncthing: Add myself (@acolomb) as maintainer.

* Syncthing: Drop busybox and DSM 5 support

Required to prepare for DSM 7.0 support

* Syncthing: fixes

* Framework: log the actual command after service_prestart()

* syncthing: Incorporate upstream release v1.15.1.

Only package version and hashes updated.  Built successfully for
all-supported.

Note that the previous package version should have already
self-updated an installed Syncthing binary when the service was
running long enough.

Co-authored-by: Sebastian Schmidt <publicarray@users.noreply.github.com>
@st-review st-review added the frozen-due-to-age Issues closed and untouched for a long time, together with being locked for discussion label Feb 5, 2022
@syncthing syncthing locked and limited conversation to collaborators Feb 5, 2022
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
frozen-due-to-age Issues closed and untouched for a long time, together with being locked for discussion
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Editable default values for folders, devices
6 participants