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

Initial plugin #1

Closed
simonw opened this issue Mar 9, 2024 · 5 comments
Closed

Initial plugin #1

simonw opened this issue Mar 9, 2024 · 5 comments
Labels
enhancement New feature or request

Comments

@simonw
Copy link
Contributor

simonw commented Mar 9, 2024

Goal is a datbase action menu item that can request a SQLite database copy. If there is enough space in /tmp it runs a subprocess that does a VACUUM INTO to create an atomic snapshot in a temporary file, then lets you download it, then deletes the file.

@simonw simonw added the enhancement New feature or request label Mar 9, 2024
@simonw
Copy link
Contributor Author

simonw commented Mar 9, 2024

I got Claude 3 Opus to write the first version: https://gist.github.com/simonw/4cecde4a729f4da0b5059b50c8e01359

@simonw
Copy link
Contributor Author

simonw commented Mar 9, 2024

For checking space:

import shutil

# Get the total, used, and free space in bytes for the /tmp directory
total, used, free = shutil.disk_usage('/tmp')

The free will be in bytes.

simonw added a commit that referenced this issue Mar 15, 2024
@simonw
Copy link
Contributor Author

simonw commented Mar 15, 2024

Still needed:

  • Check for /tmp necessary space before executing
  • Tests

@simonw
Copy link
Contributor Author

simonw commented Mar 15, 2024

I'm going to test for available space when the user requests a download, not every time I show the export button. I don't think it's worth the extra computation on every page load for a button that is hardly ever pressed. It would also be confusing to the user if the button sometimes isn't there.

@simonw
Copy link
Contributor Author

simonw commented Mar 15, 2024

One thing that bothers me here is that /db/-/export-database is an expensive operation - and someone malicious could trick logged in users into triggering it by sending them links to that full URL.

Since database actions cannot perform POST requests just yet I'm going to add a signed parameter to the URL instead, to ensure users cannot have export links generated for them.

simonw added a commit that referenced this issue Mar 15, 2024
simonw added a commit that referenced this issue Mar 15, 2024
simonw added a commit that referenced this issue Mar 15, 2024
@simonw simonw closed this as completed Mar 15, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

1 participant