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:
WithoutPants
2024-02-23 15:56:00 +11:00
committed by GitHub
parent 4a3ce8b6ec
commit ba1ebba6c0
16 changed files with 994 additions and 1 deletions

View File

@@ -14,6 +14,7 @@ type TxnManager interface {
type Repository struct {
TxnManager TxnManager
Blob BlobReader
File FileReaderWriter
Folder FolderReaderWriter
Gallery GalleryReaderWriter

View 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)
}

View File

@@ -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 {

View File

@@ -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,