mirror of
https://github.com/stashapp/stash.git
synced 2025-12-16 20:07:05 +03:00
Add Clean generated files task (#4607)
* Add clean generate task * Add to library tasks * Save and read defaults * Stop handling and logging * Make filename parsing more robust
This commit is contained in:
@@ -14,6 +14,7 @@ type TxnManager interface {
|
||||
type Repository struct {
|
||||
TxnManager TxnManager
|
||||
|
||||
Blob BlobReader
|
||||
File FileReaderWriter
|
||||
Folder FolderReaderWriter
|
||||
Gallery GalleryReaderWriter
|
||||
|
||||
8
pkg/models/repository_blob.go
Normal file
8
pkg/models/repository_blob.go
Normal file
@@ -0,0 +1,8 @@
|
||||
package models
|
||||
|
||||
import "context"
|
||||
|
||||
// FileGetter provides methods to get files by ID.
|
||||
type BlobReader interface {
|
||||
EntryExists(ctx context.Context, checksum string) (bool, error)
|
||||
}
|
||||
@@ -235,6 +235,17 @@ func (qb *BlobStore) readFromFilesystem(ctx context.Context, checksum string) ([
|
||||
}
|
||||
}
|
||||
|
||||
func (qb *BlobStore) EntryExists(ctx context.Context, checksum string) (bool, error) {
|
||||
q := dialect.From(qb.table()).Select(goqu.COUNT("*")).Where(qb.tableMgr.byID(checksum))
|
||||
|
||||
var found int
|
||||
if err := querySimple(ctx, q, &found); err != nil {
|
||||
return false, fmt.Errorf("querying %s: %w", qb.table(), err)
|
||||
}
|
||||
|
||||
return found != 0, nil
|
||||
}
|
||||
|
||||
// Read reads the data from the database or filesystem, depending on which is enabled.
|
||||
func (qb *BlobStore) Read(ctx context.Context, checksum string) ([]byte, error) {
|
||||
if !qb.options.UseDatabase && !qb.options.UseFilesystem {
|
||||
|
||||
@@ -126,6 +126,7 @@ func (db *Database) IsLocked(err error) bool {
|
||||
func (db *Database) Repository() models.Repository {
|
||||
return models.Repository{
|
||||
TxnManager: db,
|
||||
Blob: db.Blobs,
|
||||
File: db.File,
|
||||
Folder: db.Folder,
|
||||
Gallery: db.Gallery,
|
||||
|
||||
Reference in New Issue
Block a user