Fix behaviour when the destination file is deleted #21
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Context
As commented out in #20, if during the time LS is running the destination file is deleted by another agent in the machine, the plugin takes the event without any kind of feedback. This makes the plugin behaviour awkward and confusing, including data loss.
Reason
This happen because the plugin caches the file objects without doing any maintenance in case the file got deleted. There is a check for something similar at
close_stale_files
function, but this might not make it on time.Fix
Add a new variable (
create_if_deleted
) to control the behaviour and make the open function react to it. Also include an option to forward events to the failure file in case this new variable is set to false. This enhancements make feedback always there, either by adding the files again to the destination file or using the failure file, there is also logging added.Fixes #20