fix: remove double extension in uploaded files (filename.png.png → filename.png)
Some checks failed
Deploy quoter / deploy (push) Has been cancelled

This commit is contained in:
2025-10-05 12:36:19 +03:00
parent 38ec9bf1a9
commit 0506f5abe9
3 changed files with 151 additions and 130 deletions

View File

@@ -1,3 +1,13 @@
## [0.6.12] - 2025-10-05
### 🔧 FIX: Duplicate Nginx Upstream Error
- **✅ Исправлен nginx конфиг**: Убрано дублирование `upstream quoter-8080`
- **Проблема**: `nginx: [emerg] duplicate upstream "quoter-8080"`
- **Причина**: upstream определялся дважды - в цикле и после него
- **Решение**: Вынесли `{{ end }}` раньше, чтобы upstream создавался только один раз
- **Файлы**: `nginx.conf.sigil` строка 148
- 🚀 Деплой успешен, CDN работает стабильно
## [0.6.11] - 2025-10-05
### 🔧 FIX: Nginx 413 Content Too Large

View File

@@ -145,6 +145,7 @@ server {
}
}
{{ end }}
{{ end }}
{{ if $.DOKKU_APP_WEB_LISTENERS }}
@@ -154,7 +155,10 @@ upstream {{ $.APP }}-{{ $upstream_port }} {
{{ $listener_list := $listeners | split ":" }}
{{ $listener_ip := index $listener_list 0 }}
{{ $listener_port := index $listener_list 1 }}
server {{ $listener_ip }}:{{ $upstream_port }};{{ end }}
server {{ $listener_ip }}:{{ $upstream_port }};
{{ end }}
}
{{ end }}{{ end }}
{{ end }}
{{ end }}

View File

@@ -73,14 +73,21 @@ pub async fn load_file_from_s3(
/// Генерирует ключ с правильным расширением на основе MIME-типа.
#[allow(clippy::collapsible_if)]
pub fn generate_key_with_extension(base_key: String, mime_type: String) -> String {
// Убираем существующее расширение из base_key (если есть)
let key_without_ext = if let Some(dot_pos) = base_key.rfind('.') {
&base_key[..dot_pos]
} else {
&base_key
};
let mime: mime::Mime =
mime::Mime::from_str(&mime_type).unwrap_or(mime::APPLICATION_OCTET_STREAM);
if let Some(extensions) = mime_guess::get_mime_extensions_str(mime.as_ref()) {
if let Some(extension) = extensions.first() {
return format!("{}.{}", base_key, extension.to_lowercase());
return format!("{}.{}", key_without_ext, extension.to_lowercase());
}
}
base_key
key_without_ext.to_string()
}
/// список файлов из S3