Skip to content

Fix: Handle expired ZIM files by checking Wasabi storage (Closes #819) #833

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

Closed

Conversation

Salmathmullali
Copy link

This PR improves the handling of expired ZIM files by pre-fetching the Wasabi storage URL before showing the expiration message. Instead of relying only on the timestamp, we now make a HEAD request to check if the file is still available. If the request returns a 404 Not Found, we redirect the user to a frontend page explaining that the ZIM file has expired and providing a button to re-request it.

Changes Made:

  • Added a HEAD request to check ZIM file availability.
  • Redirect users to an expiration page if the file is missing.
  • Improves user experience by making the expiration message more visible.

Motivation:

Previously, users could miss the expiration message because it was based only on timestamps. This change ensures that users are clearly informed when a ZIM file is no longer available.

How It Works:

Before displaying the expired message, the system now sends a HEAD request to Wasabi storage.

If the file exists, everything continues as usual.

If the response is 404 (Not Found), the user is redirected to a page that explains the expiration and provides a "Re-request ZIM" button.

Testing:

  • Manually tested with both available and expired ZIM files.
  • Checked for proper redirection when files are missing.

Notes:

I'm a beginner in open-source and trying to contribute to good projects. I'm excited to learn and grow, and I hope to find great mentors to support my journey. Feedback is welcome!

Copy link
Member

@audiodude audiodude left a comment

Choose a reason for hiding this comment

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

Thanks for the PR!

This is the right basic idea, but I think it's in the wrong place. I would probably prefer to put this logic here:

https://github.com/openzim/wp1/blob/main/wp1/web/builders.py#L227

Additionally, a full end to end PR for this issue would include a frontend page that explains the issue to the user and provides a button to re-request the ZIM. Oddly, you mention in your PR description that you included that, but I don't see any commits. Did you forget to push them?

Finally, we will need tests for any frontend and backend code.

@Salmathmullali
Copy link
Author

Thanks for your fast response, I appreciate your guidance and will move the logic to wp1/web/builders.py as suggested. I also realize my mistake in mentioning the frontend page , I haven’t implemented it yet but can work on it if needed.

I'm still new to open source and trying my best to learn. Your feedback has been really helpful, and I truly appreciate it. Even though I try to figure things out on my own, having a mentor like you would make a big difference in my growth. I’ll carefully follow your suggestions and improve with each contribution. Thanks again for your patience and support.

@audiodude
Copy link
Member

Superseded by #839

@audiodude audiodude closed this Apr 5, 2025
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