diff options
| author | Paul Buetow <paul@buetow.org> | 2026-05-05 14:24:23 +0300 |
|---|---|---|
| committer | Paul Buetow <paul@buetow.org> | 2026-05-05 14:24:23 +0300 |
| commit | 7bc3b65b3c66c7744e1c6d4fa69842985d06d9b7 (patch) | |
| tree | fa395b13fde18ba42bf7d5b28ad9d630cfa287cc /internal/service/write.go | |
| parent | ed208d7120b6e6a7c2ce234504228b5a1ba48f11 (diff) | |
Fix podcast support critical bugs from code review
- Fix boolean scanning from SQLite INTEGER columns (intToBool helper)
- Fix BrowseSet LIMIT 0 returning zero episodes (use 1000 instead)
- Fix checkFeed double-fetch by parsing from resp.Body directly
+ Add ParseFeedReader for body reuse
- Fix file handle leak in DownloadEpisode (explicit Close before ImportMediaFile)
- Fix incomplete rollback in DownloadEpisode (remove file + delete media row)
- Fix 204 No Content handler writing 'null' body
- Fix DownloadCoverImage to accept *http.Client with timeout
- Deduplicate uniqueFilename into shared internal/service/filename.go
- Wire frontend renderPodcastEpisodes into renderBrowse from API data
- Refactor podcasts.js: remove extra API call, fix toggle toast, remove duplicate toast
- Add Config.PodcastCheckMinutes + PODCAST_CHECK_INTERVAL_MINUTES env var
- Start background CheckFeeds goroutine in main.go with ticker
- Update NewPodcastService to accept checkInterval parameter
- Log errors from CheckFeeds and episode creation instead of silently discarding
Diffstat (limited to 'internal/service/write.go')
| -rw-r--r-- | internal/service/write.go | 23 |
1 files changed, 1 insertions, 22 deletions
diff --git a/internal/service/write.go b/internal/service/write.go index 51abf22..a83c7e1 100644 --- a/internal/service/write.go +++ b/internal/service/write.go @@ -77,7 +77,7 @@ func (s *writeService) UploadMedia(ctx context.Context, setID, userID int64, fil return nil, fmt.Errorf("mkdir: %w", err) } - path := s.uniqueFilename(dir, filename) + path := uniqueFilename(dir, filename) if !strings.HasPrefix(filepath.Clean(path), filepath.Clean(dir)+string(filepath.Separator)) { return nil, errors.New("invalid filename") } @@ -97,27 +97,6 @@ func (s *writeService) UploadMedia(ctx context.Context, setID, userID int64, fil return media, nil } -func (s *writeService) uniqueFilename(dir, filename string) string { - filename = filepath.Base(filename) - if filename == "." || filename == ".." || filename == "" { - return "" - } - ext := filepath.Ext(filename) - base := strings.TrimSuffix(filename, ext) - - candidate := filepath.Join(dir, filename) - if _, err := os.Stat(candidate); os.IsNotExist(err) { - return candidate - } - - for i := 1; ; i++ { - candidate = filepath.Join(dir, fmt.Sprintf("%s(%d)%s", base, i, ext)) - if _, err := os.Stat(candidate); os.IsNotExist(err) { - return candidate - } - } -} - func (s *writeService) saveUploadedMedia(ctx context.Context, setID int64, path string, data io.Reader, size int64) (*model.Media, error) { f, err := os.Create(path) if err != nil { |
