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

Please document what do do if .state.gmailieer.json gets zeroed or corrupted #278

Open
sten0 opened this issue Apr 8, 2024 · 3 comments

Comments

@sten0
Copy link

sten0 commented Apr 8, 2024

Hi @gauteh !

I recently had a moment of bad luck recently, and my .state.gmailieer.json ended up as an empty file. Presumably the thing to do in this case is to make an additional copy of .state.gmailieer.json.bak (ie: .state.gmailieer.json.bak.known_good), then cp .state.gmailieer.json.bak to .state.gmailieer.json, then gmi pull, and then let mi sync take place as scheduled.

If there aren't any pitfalls or caveats with this approach, then I'd be happy to file a PR. Otherwise I think that it would be nice if you could write something on this topic in the documentation.

Kind regards,
Nicholas

@sten0
Copy link
Author

sten0 commented Apr 8, 2024

P.S. "moment of bad luck" = unscheduled hard power-off when UPS failed

@sten0
Copy link
Author

sten0 commented Apr 9, 2024

Alternatively, maybe lieer could handle this case gracefully and automatically instead of doing this:

gmi pull
Failed to decode state file `/home/sten/.mail/account.gmail/.state.gmailieer.json`.
Traceback (most recent call last):
  File "/usr/bin/gmi", line 24, in <module>
    g.main ()
  File "/usr/share/lieer/lieer/gmailieer.py", line 419, in main
    args.func(args)
  File "/usr/share/lieer/lieer/gmailieer.py", line 612, in pull
    self.setup(args, args.dry_run, True)
  File "/usr/share/lieer/lieer/gmailieer.py", line 489, in setup
    self.local.load_repository(block)
  File "/usr/share/lieer/lieer/local.py", line 379, in load_repository
    self.state = Local.State(self.state_f, self.config)
                 ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/share/lieer/lieer/local.py", line 270, in __init__
    self.json = json.load(fd)
                ^^^^^^^^^^^^^
  File "/usr/lib/python3.11/json/__init__.py", line 293, in load
    return loads(fp.read(),
           ^^^^^^^^^^^^^^^^
  File "/usr/lib/python3.11/json/__init__.py", line 346, in loads
    return _default_decoder.decode(s)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/lib/python3.11/json/decoder.py", line 337, in decode
    obj, end = self.raw_decode(s, idx=_w(s, 0).end())
               ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/lib/python3.11/json/decoder.py", line 355, in raw_decode
    raise JSONDecodeError("Expecting value", s, err.value) from None
json.decoder.JSONDecodeError: Expecting value: line 1 column 1 (char 0)

@gauteh
Copy link
Owner

gauteh commented Apr 9, 2024 via email

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

No branches or pull requests

2 participants