Open reddec opened 5 months ago
Thanks for the PR, I like the concept.
I'm tied up on other projects at the minute but will take a look as soon as I can.
@dullage thanks! Any updates?
A bit confused: @dullage == @clach04 ?
A bit confused: @dullage == @clach04 ?
No, we are different people. I'm just a drive-by commenter who liked your PR ;-)
Sorry for the late reply. I have a few concerns with the current approach but hopefully a potential solution for them.
file_system
but this may change in the future and if it does, the shell hook code would need to be duplicated.To solve these, my suggestion is to look into the [Background Tasks)(https://fastapi.tiangolo.com/tutorial/background-tasks/) functionality of FastAPI. You may be able to use this to perform the shell hook after the response has been returned to the client.
Additionally, I think it would also be prudent to wrap the check_call
in a try catch
with the catch
simply logging the error message using logger.error
.
@dullage
I completely understand and share your concerns. I apologize for not detailing these points in the PR description earlier. Given the specific use-case example, I couldn't identify a better alternative :man_shrugging:
Adds shell hooks via environment variables
FLATNOTES_HOOK_<name>
.FLATNOTES_HOOK_CREATE
- executes once note createdFLATNOTES_HOOK_UPDATE
- executes once note updatedFLATNOTES_HOOK_DELETE
- executes once note removedIn each option,
%s
will be replaced by path to note. Work dir is set to notes dir.It opens opportunity to enable syncs. For example: