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

Automatic detection of filesystem changes #125

Open
wants to merge 6 commits into
base: main
Choose a base branch
from

Conversation

Edgiest05
Copy link

@Edgiest05 Edgiest05 commented May 2, 2024

This feature is somewhat working (it magically sometimes does not crash), but I need a little time to nail down its implementation. I'll have to actually understand how to refresh the library and not just guessing what needs to be done and also decide which events should trigger an update. I'm open to any suggestions.

tagstudio/src/qt/ts_qt.py Outdated Show resolved Hide resolved
tagstudio/src/qt/ts_qt.py Outdated Show resolved Hide resolved
@Edgiest05 Edgiest05 marked this pull request as ready for review May 3, 2024 16:55
@Edgiest05
Copy link
Author

Functionality successfully implemented and logic moved to proper place in his own method.
@Thesacraft if you have anything else to suggest I'm all for it.

@Thesacraft
Copy link
Collaborator

Thesacraft commented May 3, 2024

I think the class definition should completly be moved out of the QtDriver class and should instead take in a QtDriver to run the events needed. Or take in the function.

@Thesacraft
Copy link
Collaborator

Thesacraft commented May 3, 2024

Also i don't think calling the add_new_files_callback function should be used here without modification because when the library is big there is a loading bar window that pops up and tagstudio becomes unusable aslong as the refresh is happening so add_new_files_callback could be split up into one handling the actual refresh and one that provides a pop up window.

@Edgiest05
Copy link
Author

Understood, I'll look into it

@Edgiest05 Edgiest05 force-pushed the main branch 2 times, most recently from 3d21f0c to 4452b2b Compare May 5, 2024 14:37
@Edgiest05
Copy link
Author

@Thesacraft, is this closer to what you had in mind?

@Edgiest05 Edgiest05 force-pushed the main branch 2 times, most recently from 5ab8a47 to 4651a23 Compare May 5, 2024 14:50
@Edgiest05
Copy link
Author

I still have to manage some TODOs (crash if changes detected while loading), but functionality is there

@Thesacraft
Copy link
Collaborator

Thesacraft commented May 5, 2024

Why are you defining the IsDirModifiedHandler class inside of another class it could be a standalone class and i think it should not be inside of another class for readability

@Edgiest05
Copy link
Author

Why are you defining the IsDirModifiedHandler class inside of another class it could be a standalone class and i think it should not be inside of another class for readability

Mainly because there is no further need of such class beside of that location. It is there to just implement the "on_any_event" method that is what requires the watchdog module with its Observer class.
From a readability standpoint, if the code for the cache invalidation is not small I will make the class a scope of his own without a doubt. Do you think I should do it nonetheless?

@Thesacraft
Copy link
Collaborator

Thesacraft commented May 5, 2024

I think it should be moved out of there. I don't think it makes a huge diffrence because it will be loaded either way and it is just a small class. Or what do you mean by the cache invalidation

@Edgiest05
Copy link
Author

Ok, I'll move it outside.
By cache invalidation I mean that I need logic that clears the "file_cache" dict or else it will grow for as long as the program runs (for every different file it has detected as changes)

@Edgiest05
Copy link
Author

@Thesacraft it should be ready now, what do you think?

tagstudio/src/core/library.py Outdated Show resolved Hide resolved
tagstudio/src/core/library.py Outdated Show resolved Hide resolved
@Edgiest05
Copy link
Author

Both assertions were there just for debugging purposes, sorry. I'll just remove them

@Thesacraft
Copy link
Collaborator

Seems good

@Edgiest05
Copy link
Author

I've updated to the latest commit and modified the code in order to take into account the possibility of manually opening libraries. If no further changes are needed I'll be waiting for merging

@Edgiest05 Edgiest05 changed the title WIP: automatic detection of filesystem changes Automatic detection of filesystem changes May 17, 2024
tagstudio/src/qt/ts_qt.py Outdated Show resolved Hide resolved
tagstudio/src/qt/ts_qt.py Outdated Show resolved Hide resolved
requirements.txt Outdated Show resolved Hide resolved
@Edgiest05
Copy link
Author

Edgiest05 commented May 17, 2024

@yedpodtrzitko, the code you mention ended up being in this PR because of running automatic formatters on my end. It is not actually part of my contribution. Nonetheless I can apply the changes if you'd like me to.
Instead, regarding "requirements.txt", the packages I've introduced are latest version: what proper upper bound should I use? The latest version itself?

@yedpodtrzitko
Copy link
Collaborator

yedpodtrzitko commented May 17, 2024

I was assuming you were changing the code in some way, because it was already formatted so I wouldnt expect the formatter touching something what's formatted already 🤔

anyway I dont have strong opinion about it, I just usually try to narrow and simplify the code which is being touched.

@yedpodtrzitko
Copy link
Collaborator

regarding "requirements.txt", the packages I've introduced are latest version: what proper upper bound should I use? The latest version itself?

it's the latest version for now. But let's say watchdog will release version 5.0 in a few weeks with breaking changes affecting us (because why not - it's a major version bump). At which point the dependency would get installed here as well.

So I'd cap it below next major versions.

watchdog>=4.0.0,<5.0.0
cachetools>=5.3.3,<6.0.0

@Edgiest05
Copy link
Author

I was assuming you were changing the code in some way, because it was already formatted so I wouldnt expect the formatter touching something what's formatted already 🤔

anyway I dont have strong opinion about it, I just usually try to narrow and simplify the code which is being touched.

Well, improvements surely aren't a bad thing, I'll refactor it.

it's the latest version for now. But let's say watchdog will release version 5.0 in a few weeks with breaking changes affecting us (because why not - it's a major version bump). At which point the dependency would get installed here as well.

So I'd cap it below next major versions.

watchdog>=4.0.0,<5.0.0
cachetools>=5.3.3,<6.0.0

Good call, thanks for your suggestion.

@Edgiest05
Copy link
Author

Edgiest05 commented May 17, 2024

All done, I kept the pointless logic because it is probably something that is still being worked on.

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

Successfully merging this pull request may close these issues.

None yet

3 participants