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

fix: Download Issue with Filenames Containing Spaces #77

Closed
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[project]
name = "smolvault"
version = "0.7.1"
version = "0.8.0"
description = "Add your description here"
readme = "README.md"
requires-python = ">=3.11"
Expand All @@ -14,6 +14,7 @@ dependencies = [
"hypercorn>=0.17.3",
"pyjwt[crypto]>=2.9.0",
"bcrypt>=4.2.0",
"sentry-sdk[fastapi]>=2.14.0",
]

[build-system]
Expand Down
8 changes: 8 additions & 0 deletions scripts/start_dev.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
#!/bin/bash

source .venv/bin/activate
hypercorn src.smolvault.main:app -b 0.0.0.0:8200 --debug \
--log-config=logging.conf --log-level=DEBUG \
--access-logfile=hypercorn.access.log \
--error-logfile=hypercorn.error.log \
--keep-alive=120 --workers=1
2 changes: 1 addition & 1 deletion src/smolvault/clients/database.py
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ class FileTag(SQLModel, table=True):
class DatabaseClient:
def __init__(self) -> None:
self.settings = get_settings()
self.engine = create_engine(f"sqlite:///{self.settings.smolvault_db}", echo=False)
self.engine = create_engine(f"sqlite:///{self.settings.smolvault_db}", echo=True)
SQLModel.metadata.create_all(self.engine)

def add_metadata(self, file_upload: FileUploadDTO, key: str) -> None:
Expand Down
2 changes: 2 additions & 0 deletions src/smolvault/config.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,8 @@ class Settings(BaseSettings):
user_whitelist: str
users_limit: int
daily_upload_limit_bytes: int
sentry_enabled: bool
sentry_dsn: str

model_config = SettingsConfigDict(env_file=".env")

Expand Down
10 changes: 9 additions & 1 deletion src/smolvault/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
from logging.handlers import RotatingFileHandler
from typing import Annotated

import sentry_sdk
from fastapi import BackgroundTasks, Depends, FastAPI, File, Form, HTTPException, UploadFile
from fastapi.middleware.cors import CORSMiddleware
from fastapi.middleware.gzip import GZipMiddleware
Expand All @@ -31,6 +32,14 @@
)
logger = logging.getLogger(__name__)

settings: Settings = get_settings()
if settings.sentry_enabled:
sentry_sdk.init(
dsn=settings.sentry_dsn,
traces_sample_rate=1.0, # Set traces_sample_rate to 1.0 to capture 100%
profiles_sample_rate=1.0,
)

app = FastAPI(title="smolvault", docs_url=None, redoc_url=None)

app.add_middleware(GZipMiddleware, minimum_size=1000)
Expand All @@ -43,7 +52,6 @@
)


settings: Settings = get_settings()
s3_client = S3Client(bucket_name=settings.smolvault_bucket)
cache = CacheManager(cache_dir=settings.smolvault_cache)

Expand Down
2 changes: 1 addition & 1 deletion terraform/iam.tf
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ data "aws_iam_policy_document" "smolvault-policy" {
statement {
effect = "Allow"
actions = ["s3:*"]
resources = [aws_s3_bucket.smolvault.arn]
resources = [aws_s3_bucket.smolvault.arn, "${aws_s3_bucket.smolvault.arn}/*"]
}
statement {
effect = "Allow"
Expand Down
Binary file added tests/mock_data/neon vintage gas station.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
2 changes: 2 additions & 0 deletions tests/testing.env
Original file line number Diff line number Diff line change
Expand Up @@ -5,3 +5,5 @@ SMOLVAULT_CACHE="./uploads/"
USER_WHITELIST="1,2"
USERS_LIMIT="3"
DAILY_UPLOAD_LIMIT_BYTES="50000"
SENTRY_ENABLED="false"
SENTRY_DSN="none"
148 changes: 84 additions & 64 deletions uv.lock

Large diffs are not rendered by default.