jaypyles / obsidian-to-bookstack

Download and upload changes between an Obsidian Vault and a Bookstack instance.
MIT License
54 stars 7 forks source link

Script crashes when a book has no shelf assigned #8

Open Geronimoes opened 5 months ago

Geronimoes commented 5 months ago

First off, thanks a lot for working on this - it fills a need I had for my setup, and works well in most cases!

The issue I encountered: when a book is not assigned to a shelf (other books are assigned to shelves on my setup, this was a test), the script will run into an error when downloading to the local client. Here is the error text:

__main__.py:27Traceback (most recent call last):
  File "/home/username/.local/bin/obsidian_to_bookstack", line 8, in <module>
    sys.exit(main())
  File "/home/username/.local/pipx/venvs/obsidian-to-bookstack/lib/python3.10/site-packages/obsidian_to_bookstack/__main__.py", line 119, in main
    cli()
  File "/home/username/.local/pipx/venvs/obsidian-to-bookstack/lib/python3.10/site-packages/click/core.py", line 1157, in __call__
    return self.main(*args, **kwargs)
  File "/home/username/.local/pipx/venvs/obsidian-to-bookstack/lib/python3.10/site-packages/click/core.py", line 1078, in main
    rv = self.invoke(ctx)
  File "/home/username/.local/pipx/venvs/obsidian-to-bookstack/lib/python3.10/site-packages/click/core.py", line 1688, in invoke
    return _process_result(sub_ctx.command.invoke(sub_ctx))
  File "/home/username/.local/pipx/venvs/obsidian-to-bookstack/lib/python3.10/site-packages/click/core.py", line 1434, in invoke
    return ctx.invoke(self.callback, **ctx.params)
  File "/home/username/.local/pipx/venvs/obsidian-to-bookstack/lib/python3.10/site-packages/click/core.py", line 783, in invoke
    return __callback(*args, **kwargs)
  File "/home/username/.local/pipx/venvs/obsidian-to-bookstack/lib/python3.10/site-packages/click/decorators.py", line 33, in new_func
    return f(get_current_context(), *args, **kwargs)
  File "/home/username/.local/pipx/venvs/obsidian-to-bookstack/lib/python3.10/site-packages/obsidian_to_bookstack/__main__.py", line 59, in local
    b.sync_local()
  File "/home/username/.local/pipx/venvs/obsidian-to-bookstack/lib/python3.10/site-packages/obsidian_to_bookstack/bookstack/bookstack.py", line 291, in sync_local
    self.book_collector.create_local_missing_books()
  File "/home/username/.local/pipx/venvs/obsidian-to-bookstack/lib/python3.10/site-packages/obsidian_to_bookstack/bookstack/collectors/local/BookCollector.py", line 71, in create_local_missing_books
    path = os.path.join(self.path, book.shelf.name, book.name)
AttributeError: 'NoneType' object has no attribute 'name'