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

Workaround for Geany IDE: Detect other types of file modifications: file move, file close, file overwritten #21

Open
animaone opened this issue Dec 23, 2022 · 0 comments

Comments

@animaone
Copy link

animaone commented Dec 23, 2022

This is related to how Geany handles files by default: It creates a temporary file copy, writes the modifications to it and them copies the modifications to the current file.
These steps are made to prevent file corruption when there is no space left in the device.
Unfortunately this is not detected as a modification by jurigged and the file is not hot-reloaded

these are the events I logged by using on_any_event inside the class JuriggedHandler(FileSystemEventHandler):

event type: created path src : app_path/test_flask_hotreloading/.goutputstream-6PJ0X1
event type: modified path src : app_path/test_flask_hotreloading
event type: modified path src : app_path/test_flask_hotreloading/.goutputstream-6PJ0X1
event type: closed path src : app_path/test_flask_hotreloading/test_flask_hello.py
event type: modified path src : app_path/test_flask_hotreloading
event type: modified path src : app_path/test_flask_hotreloading/.goutputstream-6PJ0X1
event type: moved path src : app_path/test_flask_hotreloading/.goutputstream-6PJ0X1
event type: modified path src : app_path/test_flask_hotreloading
event type: closed path src : app_path/test_flask_hotreloading/test_flask_hello.py
event type: modified path src : app_path/test_flask_hotreloading

I propose the following temporary workaround:

    on_closed = on_modified

however, the best way can be to use only an on_any_event event and them, inside it handle all possible situations:

def on_any_event(self, event):
    print(f'event type: {event.event_type}  path src : {event.src_path}', flush = True)

a more aggressive approach:

def on_any_event(self, event):
    print(f'event type: {event.event_type}  path src : {event.src_path}', flush = True)
    if ".py" in event.src_path:
        #do reload procedure

I've not made a pull request because it is open to discussion, but I'm using the temporary workaround.

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

1 participant