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

Import profile: support multiple skip_dir/skip_file entries #65

Closed
mjbogusz opened this issue Nov 4, 2022 · 3 comments
Closed

Import profile: support multiple skip_dir/skip_file entries #65

mjbogusz opened this issue Nov 4, 2022 · 3 comments
Assignees
Labels
bug Something isn't working

Comments

@mjbogusz
Copy link

mjbogusz commented Nov 4, 2022

As per the onedrive usage docs, the skip_dir and skip_file entries can be specified multiple times.

Right now OneDriveGUI fails to parse such a config with no GUI-visible error, only with a traceback on the console:

Traceback (most recent call last):
  File "/tmp/.mount_OneDriuGuN24//usr/src/OneDriveGUI.py", line 783, in import_profile
    _new_od_config = read_config(config_path)
  File "/tmp/.mount_OneDriuGuN24//usr/src/OneDriveGUI.py", line 2774, in read_config
    config.read_string(config_string)
  File "/tmp/.mount_OneDriuGuN24/usr/lib/python3.8/configparser.py", line 723, in read_string
    self.read_file(sfile, source)
  File "/tmp/.mount_OneDriuGuN24/usr/lib/python3.8/configparser.py", line 718, in read_file
    self._read(f, source)
  File "/tmp/.mount_OneDriuGuN24/usr/lib/python3.8/configparser.py", line 1093, in _read
    raise DuplicateOptionError(sectname, optname,
configparser.DuplicateOptionError: While reading from '<string>' [line 12]: option 'skip_dir' in section 'onedrive' already exists

A simple workaround is to merge the multiple lines with a pipe (|) as per the docs linked above - this allows the profile to be imported successfully.

@bpozdena
Copy link
Owner

bpozdena commented Nov 7, 2022

Unfortunately, I will not be able to support this. It would need a significant rewrite.

Please define all your skip_dir and skip_file entries within a single line for now. The pipe separator is of course supported in the GUI as well.

I will try to improve the error handling. I will also look into auto-converting the entries into a single line.

@bpozdena bpozdena self-assigned this Nov 7, 2022
@bpozdena bpozdena added the bug Something isn't working label Nov 7, 2022
@mjbogusz
Copy link
Author

mjbogusz commented Nov 7, 2022

From configparser docs:

When strict is True (the default), the parser won’t allow for any section or option duplicates while reading from a single source (file, string or dictionary), raising DuplicateSectionError or DuplicateOptionError. [...] Otherwise, internal empty lines of a multiline option are kept as part of the value.

I'm not sure how it concatenates the options though, and it's mostly relevant for the one-time import; Therefore I'd consider a clear error message with the single-line workaround mentioned a very valid solution.

bpozdena added a commit that referenced this issue Nov 27, 2022
@bpozdena
Copy link
Owner

Multi-line options 'skip_file' and 'skip_dir' will now be automatically consolidated into a single line.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants