MaelImhof / obsidian-jupyter

Edit .ipynb Jupyter files directly in Obsidian.
https://jupyter.mael.im/
12 stars 1 forks source link

[Bug]: Checkpoints folder is not deleted when Obsidian is closed #38

Open MaelImhof opened 2 weeks ago

MaelImhof commented 2 weeks ago

What's the issue?

When the Delete Jupyter checkpoints setting is enabled, checkpoints are put all together in one folder, in the plugin's directory. This folder is supposed to be deleted when Jupyter exits.

However, if the user closes Obsidian normally, the folder is never deleted. onunload is never called.

How to reproduce?

  1. Open the test vault
  2. Make sure Delete Jupyter checkpoints is enabled
  3. Open Welcome.ipynb
  4. Wait for some checkpoints to be created in .obsidian/plugins/jupyter/.ipynb_checkpoints
  5. Close Obsidian using the top-right (Windows) cross
  6. Checkpoints are still in .obsidian/plugins/jupyter/.ipynb_checkpoints

What have you tried?

Found out it was because onunload was never called on Obsidian exit, tried to find another hook but did not have any luck yet.

Additional information

Asked the question on Obsidian Forum, maybe some answer will come up there.

MaelImhof commented 2 weeks ago

With the received answer (thank you joethei), try to implement a solution and see if it works for a normal use case (of course, if the user kills the Obsidian process, the clean up logic probably won't be executed, but check that it is executed if the user simply closes Obsidian normally).