mirror of
https://github.com/stashapp/stash.git
synced 2025-12-17 20:34:37 +03:00
[Files Refactor] Bug fixes (#2868)
* Return error if multiple rows returned for id * Add missing LoadFiles calls * Show id if path is empty
This commit is contained in:
@@ -2,6 +2,7 @@ package models
|
||||
|
||||
import (
|
||||
"context"
|
||||
"strconv"
|
||||
"time"
|
||||
|
||||
"github.com/stashapp/stash/pkg/file"
|
||||
@@ -128,6 +129,20 @@ func (g Gallery) GetTitle() string {
|
||||
return g.Path
|
||||
}
|
||||
|
||||
// DisplayName returns a display name for the scene for logging purposes.
|
||||
// It returns the path or title, or otherwise it returns the ID if both of these are empty.
|
||||
func (g Gallery) DisplayName() string {
|
||||
if g.Path != "" {
|
||||
return g.Path
|
||||
}
|
||||
|
||||
if g.Title != "" {
|
||||
return g.Title
|
||||
}
|
||||
|
||||
return strconv.Itoa(g.ID)
|
||||
}
|
||||
|
||||
const DefaultGthumbWidth int = 640
|
||||
|
||||
type Galleries []*Gallery
|
||||
|
||||
@@ -4,6 +4,7 @@ import (
|
||||
"context"
|
||||
"errors"
|
||||
"path/filepath"
|
||||
"strconv"
|
||||
"time"
|
||||
|
||||
"github.com/stashapp/stash/pkg/file"
|
||||
@@ -96,6 +97,16 @@ func (i Image) GetTitle() string {
|
||||
return ""
|
||||
}
|
||||
|
||||
// DisplayName returns a display name for the scene for logging purposes.
|
||||
// It returns Path if not empty, otherwise it returns the ID.
|
||||
func (i Image) DisplayName() string {
|
||||
if i.Path != "" {
|
||||
return i.Path
|
||||
}
|
||||
|
||||
return strconv.Itoa(i.ID)
|
||||
}
|
||||
|
||||
type ImageCreateInput struct {
|
||||
*Image
|
||||
FileIDs []file.ID
|
||||
|
||||
@@ -222,6 +222,16 @@ func (s Scene) GetTitle() string {
|
||||
return filepath.Base(s.Path)
|
||||
}
|
||||
|
||||
// DisplayName returns a display name for the scene for logging purposes.
|
||||
// It returns Path if not empty, otherwise it returns the ID.
|
||||
func (s Scene) DisplayName() string {
|
||||
if s.Path != "" {
|
||||
return s.Path
|
||||
}
|
||||
|
||||
return strconv.Itoa(s.ID)
|
||||
}
|
||||
|
||||
// GetHash returns the hash of the scene, based on the hash algorithm provided. If
|
||||
// hash algorithm is MD5, then Checksum is returned. Otherwise, OSHash is returned.
|
||||
func (s Scene) GetHash(hashAlgorithm HashAlgorithm) string {
|
||||
|
||||
Reference in New Issue
Block a user