mirror of
https://github.com/stashapp/stash.git
synced 2025-12-17 20:34:37 +03:00
Add default thumbnails for scenes and images (#2949)
* Use default thumbnail for scene covers * Use defautl thumbnail for image thumbnails
This commit is contained in:
@@ -118,14 +118,12 @@ func (f *BaseFile) Info(fs FS) (fs.FileInfo, error) {
|
||||
return f.info(fs, f.Path)
|
||||
}
|
||||
|
||||
func (f *BaseFile) Serve(fs FS, w http.ResponseWriter, r *http.Request) {
|
||||
func (f *BaseFile) Serve(fs FS, w http.ResponseWriter, r *http.Request) error {
|
||||
w.Header().Add("Cache-Control", "max-age=604800000") // 1 Week
|
||||
|
||||
reader, err := f.Open(fs)
|
||||
if err != nil {
|
||||
// assume not found
|
||||
http.Error(w, http.StatusText(http.StatusNotFound), http.StatusNotFound)
|
||||
return
|
||||
return err
|
||||
}
|
||||
|
||||
defer reader.Close()
|
||||
@@ -135,8 +133,7 @@ func (f *BaseFile) Serve(fs FS, w http.ResponseWriter, r *http.Request) {
|
||||
// fallback to direct copy
|
||||
data, err := io.ReadAll(reader)
|
||||
if err != nil {
|
||||
http.Error(w, err.Error(), http.StatusInternalServerError)
|
||||
return
|
||||
return err
|
||||
}
|
||||
|
||||
k, err := w.Write(data)
|
||||
@@ -144,10 +141,11 @@ func (f *BaseFile) Serve(fs FS, w http.ResponseWriter, r *http.Request) {
|
||||
logger.Warnf("error serving file (wrote %v bytes out of %v): %v", k, len(data), err)
|
||||
}
|
||||
|
||||
return
|
||||
return nil
|
||||
}
|
||||
|
||||
http.ServeContent(w, r, f.Basename, f.ModTime, rsc)
|
||||
return nil
|
||||
}
|
||||
|
||||
type Finder interface {
|
||||
|
||||
Reference in New Issue
Block a user