Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Conversation

@Alex-Kent
Copy link
Contributor

This patch does the following:

  • Watching multiple files/layers is now working properly
  • Support added for file names that are URL-encoded (including those with options appended); this includes things like delimited text files (CSV and the like).

The code is reasonably-well documented, let me know if you have any questions.

• Support added for file names that are URL-encoded (including those with options appended)
@Alex-Kent
Copy link
Contributor Author

I can submit a new PR if you'd like.

@evetion
Copy link
Owner

evetion commented Feb 11, 2025

Thanks for the PR! I'll take a look tomorrow. In the meantime, can you explain a bit on what things didn't work before? Either edited in the PR description above, or a new issue?

I can submit a new PR if you'd like.

How familiar are you with git? You should be able to just commit to the main branch of your fork where you did this work to update this PR.

@Alex-Kent
Copy link
Contributor Author

Why don't I submit a bug report for the two things that were changed.

As for Git, I'm somewhat proficient but I'm not hugely familiar with how Github handles things. I'll try pushing an update to my repo and see if it propagates here.

Copy link
Owner

@evetion evetion left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm not sure about the change to the monitoring. You have added a lot of warnings about variable naming/aliasing, and pass the path, but you don't need it in the function (only for logging). So the main change is to use the layer_id, but that is not passed by the signal, and still cached from the code above it. The signal only passes the path I guess, and that might set it to both arguments?

I'm also not sure what didn't work in the old code, did the layers not update in some cases?

Let me know if you want me to work on the PR.

@Alex-Kent
Copy link
Contributor Author

I'll be submitting a second bug report shortly regarding the changes to to callback function. In a nutshell it's a workaround for what appears to be a Python bug (likely system-dependent).

@Alex-Kent
Copy link
Contributor Author

All of the changes that we've been discussing plus the fix for #4 have been implemented and pushed to Github. For installing the callback I used my implementation (a lambda); as this is your project though it's ultimately your decision as to which method to use for this. Currently I'm passively testing the code (it's being triggered every minute or so) and I haven't seen any issues so far.

• Improved comments
• Changed callback function name since a method with the same name also exists (this has no effect on the code's function)
@Alex-Kent
Copy link
Contributor Author

The most recent push (14ec5f8) covers everything that we've been discussing. This code has been tested for the past 24 hours with multiple file-backed layers being watched and no issues have been seen. In my opinion this code should be ready to be merged.

@evetion evetion merged commit 5083128 into evetion:main Feb 14, 2025
@evetion
Copy link
Owner

evetion commented Feb 14, 2025

Thanks for the finding the bugs, reporting and fixing them! I will make some minor changes and make a release this weekend.

@Alex-Kent
Copy link
Contributor Author

Alex-Kent commented Feb 14, 2025

Thanks for the finding the bugs, reporting and fixing them!

¡De nada! And thank you for writing such a useful plugin!

I will make some minor changes

There's always something missed: lines 66 and 67 aren't needed and can be deleted (that's the from qgis.core import QgsProject statement and its comment). I've updated my code and am passively testing to ensure it can be safely removed (which it should as it was only used for retrieving the layer by its ID in my initial push). This change was pushed to my copy of the repo after you merged the code (4e49c7a).

@evetion
Copy link
Owner

evetion commented Feb 15, 2025

I've removed some lines, ran an autoformatter, added a test and some more in 1577f35. Most impactful, I've shortened a check you did for re-adding the watch at 1577f35#diff-859e6c5392dbec182d14bd578888ecdd0c6c29b9007f5abce8d7654f541b2418R356. Can you confirm it still works as it should?

edit: See, it was good to check, I think I inverted the condition there.

@Alex-Kent
Copy link
Contributor Author

Can you confirm it still works as it should?

I read through the diff and saw a few things, mostly minor (stylistic), one or two that might be issues. I'll pull the code and test it then annotate the aforementioned diff.

@Alex-Kent
Copy link
Contributor Author

Alex-Kent commented Feb 15, 2025

Correction: I'll annotate the diff between your merge of my pull request (5083128) and your most recent push (1f35f16). [edit: Or not, Github won't let me annotate that diff.]

@Alex-Kent
Copy link
Contributor Author

How are you running test.py?

@Alex-Kent
Copy link
Contributor Author

Alex-Kent commented Feb 15, 2025

I added comments to 1f35f16 and 1577f35

The current code is running fine on my system (it's been running with watched file updates [for multiple files] every minute or two for the past 4 hours).

@evetion
Copy link
Owner

evetion commented Feb 15, 2025

Great, thanks for testing! I'll make a release tomorrow.

@Alex-Kent
Copy link
Contributor Author

Alex-Kent commented Feb 15, 2025

There are a few suggested changes in the comments I made.

Amongst other things, can you test this on Windows or would you like me to install QGIS in a VM and test it there? [edit: I did the latter.] To be specific, on Windows / characters in file:// URIs may need to be changed to \.

@Alex-Kent
Copy link
Contributor Author

I was right, file:// URI aren't handled correctly on Windows (there's even an odd added quirk). Fixing it looks trivial. I'll submit a bug report and a new PR to fix the issue.

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.

2 participants