mirror of
https://github.com/stashapp/stash.git
synced 2026-03-04 04:03:21 +01:00
* Add basename field to folder * Add parent_folders field to folder * Add basename column to folder table * Add basename filter field * Create missing folder hierarchies during migration * Treat files/folders in zips where path can't be made relative as not found Addresses an issue during clean where corrupt folder entries in zip files could not be removed due to an error during the call to Rel.
36 lines
964 B
Go
36 lines
964 B
Go
package api
|
|
|
|
import (
|
|
"context"
|
|
"path/filepath"
|
|
|
|
"github.com/stashapp/stash/internal/api/loaders"
|
|
"github.com/stashapp/stash/pkg/models"
|
|
)
|
|
|
|
func (r *folderResolver) Basename(ctx context.Context, obj *models.Folder) (string, error) {
|
|
return filepath.Base(obj.Path), nil
|
|
}
|
|
|
|
func (r *folderResolver) ParentFolder(ctx context.Context, obj *models.Folder) (*models.Folder, error) {
|
|
if obj.ParentFolderID == nil {
|
|
return nil, nil
|
|
}
|
|
|
|
return loaders.From(ctx).FolderByID.Load(*obj.ParentFolderID)
|
|
}
|
|
|
|
func (r *folderResolver) ParentFolders(ctx context.Context, obj *models.Folder) ([]*models.Folder, error) {
|
|
ids, err := loaders.From(ctx).FolderParentFolderIDs.Load(obj.ID)
|
|
if err != nil {
|
|
return nil, err
|
|
}
|
|
|
|
var errs []error
|
|
ret, errs := loaders.From(ctx).FolderByID.LoadAll(ids)
|
|
return ret, firstError(errs)
|
|
}
|
|
|
|
func (r *folderResolver) ZipFile(ctx context.Context, obj *models.Folder) (*BasicFile, error) {
|
|
return zipFileResolver(ctx, obj.ZipFileID)
|
|
}
|