- Add __bad__ for bad torrents

- Add colors to logs info
- Make logs a bit more clearer
- Mark torrent has bad instead of deleting them
This commit is contained in:
Mukhtar Akere
2025-05-13 13:17:26 +01:00
parent 7c1bb52793
commit 36e681d0e6
8 changed files with 110 additions and 48 deletions

View File

@@ -83,7 +83,7 @@ func (h *Handler) getTorrentsFolders(folder string) []os.FileInfo {
}
func (h *Handler) getParentItems() []string {
parents := []string{"__all__", "torrents"}
parents := []string{"__all__", "torrents", "__bad__"}
// Add custom folders
parents = append(parents, h.cache.GetCustomFolders()...)
@@ -122,7 +122,7 @@ func (h *Handler) getChildren(name string) []os.FileInfo {
name = utils.PathUnescape(path.Clean(name))
root := path.Clean(h.getRootPath())
// toplevel “parents” (e.g. __all__, torrents)
// toplevel “parents” (e.g. __all__, torrents etc)
if name == root {
return h.getParentFiles()
}
@@ -397,6 +397,7 @@ func (h *Handler) serveDirectory(w http.ResponseWriter, r *http.Request, file we
}
return fmt.Sprintf("%.2f %s", size, unit)
},
"hasSuffix": strings.HasSuffix,
}
tmpl, err := template.New("directory").Funcs(funcMap).Parse(directoryTemplate)
if err != nil {
@@ -443,7 +444,7 @@ func (h *Handler) handleGet(w http.ResponseWriter, r *http.Request) {
if file, ok := fRaw.(*File); ok && file.content == nil {
link, err := file.getDownloadLink()
if err != nil {
h.logger.Trace().
h.logger.Error().
Err(err).
Str("path", r.URL.Path).
Msg("Could not fetch download link")