BUG: The share server keeps listening after the last share expires
Is there an existing issue for this?
- [x] I have searched the existing issues
What happened?
The share listener is stopped only from share_util_revoke(), when the last share is revoked. A share that expires is dropped from the registry in share_registry_get(), but nothing stops the server, so once the last share has expired the listener stays bound to 0.0.0.0 until PictoPy quits. GET /share/ returns an empty list, so the app shows nothing being shared and there is no token left to revoke.
Reproduce: create a share with expires_in_minutes: 1, wait for it to expire, then check GET /share/ (empty) and the share port (still accepting connections).
With an internet share the same applies to the tunnel: the dialog only shows "Stop sharing", the one place that closes the tunnel, while a share is listed.
Nothing is exposed (every path returns 404), but it leaves a network-facing port and possibly a public tunnel open after the user has been told sharing ended. Proposed fix: stop the listener when an expiry leaves no live shares, and close the tunnel when no shares remain. Happy to work on it.
Record
- [x] I agree to follow this project's Code of Conduct
👋 Thanks for opening this issue! The maintainers will review it shortly. Till then, do not open any PR. This is a strict rule we like to follow around here :)
⚠️ Potential Duplicate Issue (Semantic Match)
This issue appears semantically similar to the following issues in AOSSIE-Org/PictoPy:
- BUG: Remove Share Button (Not Needed for Now) (#616, closed) https://github.com/AOSSIE-Org/PictoPy/issues/616 Similarity: 55.1%
Please review before proceeding.
@rohan-pandeyy when free please check this and assign me .love to fix this
Reproduced this in the app with an Internet share. It's a bit worse, the share list isn't refetched, so the dialog still shows the expired share. If someone opened the link after it expired, "Stop sharing" fails with "Share Not Found", and since tunnel.close() only runs after every revoke succeeds, the tunnel stays open. So revoking an expired share should probably count as success too?
Thanks @rohan-pandeyy for the assignment, and @ManyaJain111 for reproducing this with an internet share. That widened the bug beyond the listener, so I've covered all of it in #1763:
- Listener: a timer set at creation sweeps expired shares and stops the listener once none are live.
- Tunnel: the Album page closes it when the shares list comes back empty. The list is polled every 30s while something is shared.
- Stale dialog: the share list is refetched each time the dialog opens.
- Revoking an expired share: a 404 now counts as success, so "Stop sharing" no longer fails with "Share Not Found" and the tunnel still closes.
The tunnel only closes while the Album page is mounted, so if the user has navigated away it closes on return. Closing it from the Rust side would need the backend to push the event, which I left out of this PR. Happy to follow up if you'd like that.