Skip to content

Shared task board where people and AI coding agents work as teammates. Source-available, self-hostable.

Go

fix(storage): clean up variable shadowing and dead code (#761)

Bohan Jiang31eeb00b59ba
diff --git a/server/internal/storage/local.go b/server/internal/storage/local.go
index ada8f4d921..a2c76c0e9c 100644
--- a/server/internal/storage/local.go
+++ b/server/internal/storage/local.go
@@ -80,8 +80,8 @@ func (s *LocalStorage) DeleteKeys(ctx context.Context, keys []string) {
}
func (s *LocalStorage) Upload(ctx context.Context, key string, data []byte, contentType string, filename string) (string, error) {
- filepath := filepath.Join(s.uploadDir, key)
- if err := os.WriteFile(filepath, data, 0644); err != nil {
+ dest := filepath.Join(s.uploadDir, key)
+ if err := os.WriteFile(dest, data, 0644); err != nil {
return "", fmt.Errorf("local storage WriteFile: %w", err)
}
diff --git a/server/internal/storage/util.go b/server/internal/storage/util.go
index 3fd8f06702..56add6886d 100644
--- a/server/internal/storage/util.go
+++ b/server/internal/storage/util.go
@@ -1,8 +1,6 @@
package storage
import (
- "net/http"
- "path"
"strings"
)
@@ -21,34 +19,6 @@ func sanitizeFilename(name string) string {
return b.String()
}
-// detectContentType determines the content type for a file.
-// Uses http.DetectContentType as base, with overrides for common extensions.
-func detectContentType(data []byte, filename string) string {
- contentType := http.DetectContentType(data)
- ext := strings.ToLower(path.Ext(filename))
- if ct := overrideContentType(ext); ct != "" {
- return ct
- }
- return contentType
-}
-
-// overrideContentType returns content type overrides for extensions that http.DetectContentType gets wrong.
-func overrideContentType(ext string) string {
- switch ext {
- case ".svg":
- return "image/svg+xml"
- case ".css":
- return "text/css"
- case ".js", ".mjs":
- return "application/javascript"
- case ".json":
- return "application/json"
- case ".wasm":
- return "application/wasm"
- }
- return ""
-}
-
// isInlineContentType returns true for media types that browsers should
// display inline (images, video, audio, PDF). Everything else triggers a
// download via Content-Disposition: attachment.