scriptotek / alma-slipsomat

Tool for syncing Alma letters XSL files with a local folder
MIT License
15 stars 10 forks source link

Running defaults with non-pulled modifications in Alma will update modified date in status.json without actually pulling the changes #32

Closed daniels closed 6 years ago

daniels commented 6 years ago

Hi,

I just noticed that after running defaults, pull wouldn't retrieve files I knew were changed in Alma.

Looking at the diff of status.json after the defaults command, the modified date was changed for these files, but the checksum was not and the modified files had not been fetched. Subsequently running pull would first crash slipsomat (possibly not related, but happened both on the first run and when I reproduced the issue) and after restarting, pull reported that "0 of 113 files contained new modifications".

Reverting these lines in status.json solved the issue for me, and of course there is a workaround in always running pull before defaults.

Just in case the crash is related, here are the last few lines of the output:

- header.xsl (2017-06-08)                                                                       - header.xsl (2017-06-08)                                      no changes                       - header.xsl (2017-06-08)                                      no changes
- footer.xsl (2017-06-08)                                                                       - footer.xsl (2017-06-08)                                      no changes                       - footer.xsl (2017-06-08)                                      no changes
- WebhookFailureLetter.xsl (-)                                                                  - WebhookFailureLetter.xsl (-)                                 
Exception: 'modified'
Traceback (most recent call last):
  File "/Users/dan/tmp/alma-letters/.direnv/python-2.7.14/lib/python2.7/site-packages/slipsomat-0.1.0-py2.7.egg/slipsomat/slipsomat.py", line 1079, in execute
    function(self.browser, *args)
  File "/Users/dan/tmp/alma-letters/.direnv/python-2.7.14/lib/python2.7/site-packages/slipsomat-0.1.0-py2.7.egg/slipsomat/slipsomat.py", line 716, in pull
    if letter.remote_modified():
  File "/Users/dan/tmp/alma-letters/.direnv/python-2.7.14/lib/python2.7/site-packages/slipsomat-0.1.0-py2.7.egg/slipsomat/slipsomat.py", line 517, in remote_modified
    if os.path.exists(self.filename) and self.modified == self.table.status.letters[self.filename]['modified'] and self.modified != today:
KeyError: 'modified'
Please "pip install inquirer" if you would like more debug options
danmichaelo commented 6 years ago

@daniels , thanks for the detailed report! Wouldn't be surprised is this is also the underlying problem of the issue reported here that I didn't fully resolve: https://github.com/scriptotek/alma-slipsomat/issues/31#issuecomment-366377159

There's some design decisions made early on that I regret, so I've started on a refactoring to make things less intertwingled.