mirror of
https://github.com/stashapp/stash.git
synced 2025-12-18 12:54:38 +03:00
Populate image/gallery title during scan (#1359)
This commit is contained in:
@@ -257,3 +257,10 @@ func GetTitle(s *models.Image) string {
|
|||||||
_, fn := getFilePath(s.Path)
|
_, fn := getFilePath(s.Path)
|
||||||
return filepath.Base(fn)
|
return filepath.Base(fn)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// GetFilename gets the base name of the image file
|
||||||
|
// If stripExt is set the file extension is omitted from the name
|
||||||
|
func GetFilename(s *models.Image, stripExt bool) string {
|
||||||
|
_, fn := getFilePath(s.Path)
|
||||||
|
return utils.GetNameFromPath(fn, stripExt)
|
||||||
|
}
|
||||||
|
|||||||
@@ -240,6 +240,10 @@ func (t *ScanTask) scanGallery() {
|
|||||||
Timestamp: fileModTime,
|
Timestamp: fileModTime,
|
||||||
Valid: true,
|
Valid: true,
|
||||||
},
|
},
|
||||||
|
Title: sql.NullString{
|
||||||
|
String: utils.GetNameFromPath(t.FilePath, t.StripFileExtension),
|
||||||
|
Valid: true,
|
||||||
|
},
|
||||||
CreatedAt: models.SQLiteTimestamp{Timestamp: currentTime},
|
CreatedAt: models.SQLiteTimestamp{Timestamp: currentTime},
|
||||||
UpdatedAt: models.SQLiteTimestamp{Timestamp: currentTime},
|
UpdatedAt: models.SQLiteTimestamp{Timestamp: currentTime},
|
||||||
}
|
}
|
||||||
@@ -853,6 +857,9 @@ func (t *ScanTask) scanImage() {
|
|||||||
CreatedAt: models.SQLiteTimestamp{Timestamp: currentTime},
|
CreatedAt: models.SQLiteTimestamp{Timestamp: currentTime},
|
||||||
UpdatedAt: models.SQLiteTimestamp{Timestamp: currentTime},
|
UpdatedAt: models.SQLiteTimestamp{Timestamp: currentTime},
|
||||||
}
|
}
|
||||||
|
newImage.Title.String = image.GetFilename(&newImage, t.StripFileExtension)
|
||||||
|
newImage.Title.Valid = true
|
||||||
|
|
||||||
if err := image.SetFileDetails(&newImage); err != nil {
|
if err := image.SetFileDetails(&newImage); err != nil {
|
||||||
logger.Error(err.Error())
|
logger.Error(err.Error())
|
||||||
return
|
return
|
||||||
@@ -966,6 +973,10 @@ func (t *ScanTask) associateImageWithFolderGallery(imageID int, qb models.Galler
|
|||||||
},
|
},
|
||||||
CreatedAt: models.SQLiteTimestamp{Timestamp: currentTime},
|
CreatedAt: models.SQLiteTimestamp{Timestamp: currentTime},
|
||||||
UpdatedAt: models.SQLiteTimestamp{Timestamp: currentTime},
|
UpdatedAt: models.SQLiteTimestamp{Timestamp: currentTime},
|
||||||
|
Title: sql.NullString{
|
||||||
|
String: utils.GetNameFromPath(path, false),
|
||||||
|
Valid: true,
|
||||||
|
},
|
||||||
}
|
}
|
||||||
|
|
||||||
logger.Infof("Creating gallery for folder %s", path)
|
logger.Infof("Creating gallery for folder %s", path)
|
||||||
|
|||||||
@@ -283,3 +283,14 @@ func IsPathInDir(dir, pathToCheck string) bool {
|
|||||||
|
|
||||||
return false
|
return false
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// GetNameFromPath returns the name of a file from its path
|
||||||
|
// if stripExtension is true the extension is omitted from the name
|
||||||
|
func GetNameFromPath(path string, stripExtension bool) string {
|
||||||
|
fn := filepath.Base(path)
|
||||||
|
if stripExtension {
|
||||||
|
ext := filepath.Ext(fn)
|
||||||
|
fn = strings.TrimSuffix(fn, ext)
|
||||||
|
}
|
||||||
|
return fn
|
||||||
|
}
|
||||||
|
|||||||
@@ -33,6 +33,7 @@
|
|||||||
* Change performer text query to search by name and alias only.
|
* Change performer text query to search by name and alias only.
|
||||||
|
|
||||||
### 🐛 Bug fixes
|
### 🐛 Bug fixes
|
||||||
|
* Fix image/gallery title not being set during scan.
|
||||||
* Reverted video previews always playing on small devices.
|
* Reverted video previews always playing on small devices.
|
||||||
* Fix performer/studio being cleared when skipped in scene tagger.
|
* Fix performer/studio being cleared when skipped in scene tagger.
|
||||||
* Fixed error when auto-tagging for performers/studios/tags with regex characters in the name.
|
* Fixed error when auto-tagging for performers/studios/tags with regex characters in the name.
|
||||||
|
|||||||
Reference in New Issue
Block a user