sfile

package
v0.0.0-...-36d6306 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jul 5, 2026 License: Apache-2.0 Imports: 9 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	ErrFileNotFound       = fmt.Errorf("file not found")
	ErrContentNotFound    = fmt.Errorf("content not found")
	ErrInvalidContentKind = fmt.Errorf("invalid content kind")
	ErrFolderIntoItself   = fmt.Errorf("cannot move folder into itself")
	ErrWorkspaceMismatch  = fmt.Errorf("workspace mismatch")
)

Functions

func ConvertToDBFile

func ConvertToDBFile(file mfile.File) gen.File

ConvertToDBFile converts model to DB representation

func ConvertToModelFile

func ConvertToModelFile(file gen.File) *mfile.File

ConvertToModelFile converts DB to model representation

Types

type FileService

type FileService struct {
	// contains filtered or unexported fields
}

FileService provides operations for managing files in the unified file system Supports the union type content pattern with two-query approach for content retrieval

func New

func New(queries *gen.Queries, logger *slog.Logger) *FileService

New creates a new FileService

func NewTX

func NewTX(ctx context.Context, tx *sql.Tx, logger *slog.Logger) (*FileService, error)

NewTX creates a new service instance with prepared transaction queries

func (*FileService) CheckWorkspaceID

func (s *FileService) CheckWorkspaceID(ctx context.Context, fileID, workspaceID idwrap.IDWrap) (bool, error)

CheckWorkspaceID verifies if a file belongs to a specific workspace

func (*FileService) CreateFile

func (s *FileService) CreateFile(ctx context.Context, file *mfile.File) error

CreateFile creates a new file

func (*FileService) DeleteFile

func (s *FileService) DeleteFile(ctx context.Context, id idwrap.IDWrap) error

DeleteFile deletes a file

func (*FileService) GetFile

func (s *FileService) GetFile(ctx context.Context, id idwrap.IDWrap) (*mfile.File, error)

GetFile retrieves a single file by ID (metadata only)

func (*FileService) GetFileByContentID

func (s *FileService) GetFileByContentID(ctx context.Context, contentID idwrap.IDWrap) (*mfile.File, error)

GetFileByContentID retrieves a file by its content ID

func (*FileService) GetFileContentID

func (s *FileService) GetFileContentID(ctx context.Context, id idwrap.IDWrap) (*idwrap.IDWrap, mfile.ContentType, error)

GetFileContentID retrieves the content ID for a file

func (*FileService) GetWorkspaceID

func (s *FileService) GetWorkspaceID(ctx context.Context, fileID idwrap.IDWrap) (idwrap.IDWrap, error)

GetWorkspaceID retrieves the workspace ID for a file

func (*FileService) ListFilesByParent

func (s *FileService) ListFilesByParent(ctx context.Context, workspaceID idwrap.IDWrap, parentID *idwrap.IDWrap) ([]mfile.File, error)

ListFilesByParent retrieves files directly under a parent

func (*FileService) ListFilesByWorkspace

func (s *FileService) ListFilesByWorkspace(ctx context.Context, workspaceID idwrap.IDWrap) ([]mfile.File, error)

ListFilesByWorkspace retrieves all files for a workspace

func (*FileService) MoveFile

func (s *FileService) MoveFile(ctx context.Context, fileID idwrap.IDWrap, newParentID *idwrap.IDWrap) error

MoveFile moves a file to a different parent

func (*FileService) NextDisplayOrder

func (s *FileService) NextDisplayOrder(ctx context.Context, workspaceID idwrap.IDWrap, parentID *idwrap.IDWrap) (float64, error)

NextDisplayOrder calculates the next order value for a file in a workspace/parent

func (*FileService) Reader

func (s *FileService) Reader() *Reader

func (*FileService) TX

func (s *FileService) TX(tx *sql.Tx) *FileService

TX returns a new service instance with transaction support

func (*FileService) UpdateFile

func (s *FileService) UpdateFile(ctx context.Context, file *mfile.File) error

UpdateFile updates an existing file

func (*FileService) UpsertFile

func (s *FileService) UpsertFile(ctx context.Context, file *mfile.File) error

UpsertFile creates or updates a file

type Reader

type Reader struct {
	// contains filtered or unexported fields
}

func NewReader

func NewReader(db *sql.DB, logger *slog.Logger) *Reader

func NewReaderFromQueries

func NewReaderFromQueries(queries *gen.Queries, logger *slog.Logger) *Reader

func (*Reader) CheckWorkspaceID

func (r *Reader) CheckWorkspaceID(ctx context.Context, fileID, workspaceID idwrap.IDWrap) (bool, error)

func (*Reader) FindFileByPathHash

func (r *Reader) FindFileByPathHash(ctx context.Context, workspaceID idwrap.IDWrap, pathHash string) (idwrap.IDWrap, error)

func (*Reader) GetFile

func (r *Reader) GetFile(ctx context.Context, id idwrap.IDWrap) (*mfile.File, error)

func (*Reader) GetFileByContentID

func (r *Reader) GetFileByContentID(ctx context.Context, contentID idwrap.IDWrap) (*mfile.File, error)

GetFileByContentID retrieves a file by its content ID

func (*Reader) GetFileContentID

func (r *Reader) GetFileContentID(ctx context.Context, id idwrap.IDWrap) (*idwrap.IDWrap, mfile.ContentType, error)

func (*Reader) GetWorkspaceID

func (r *Reader) GetWorkspaceID(ctx context.Context, fileID idwrap.IDWrap) (idwrap.IDWrap, error)

func (*Reader) ListFilesByParent

func (r *Reader) ListFilesByParent(ctx context.Context, workspaceID idwrap.IDWrap, parentID *idwrap.IDWrap) ([]mfile.File, error)

func (*Reader) ListFilesByWorkspace

func (r *Reader) ListFilesByWorkspace(ctx context.Context, workspaceID idwrap.IDWrap) ([]mfile.File, error)

type Writer

type Writer struct {
	// contains filtered or unexported fields
}

func NewWriter

func NewWriter(tx gen.DBTX, logger *slog.Logger) *Writer

func NewWriterFromQueries

func NewWriterFromQueries(queries *gen.Queries, logger *slog.Logger) *Writer

func (*Writer) CreateFile

func (w *Writer) CreateFile(ctx context.Context, file *mfile.File) error

func (*Writer) DeleteFile

func (w *Writer) DeleteFile(ctx context.Context, id idwrap.IDWrap) error

func (*Writer) MoveFile

func (w *Writer) MoveFile(ctx context.Context, fileID idwrap.IDWrap, newParentID *idwrap.IDWrap) error

func (*Writer) NextDisplayOrder

func (w *Writer) NextDisplayOrder(ctx context.Context, workspaceID idwrap.IDWrap, parentID *idwrap.IDWrap) (float64, error)

func (*Writer) UpdateFile

func (w *Writer) UpdateFile(ctx context.Context, file *mfile.File) error

func (*Writer) UpsertFile

func (w *Writer) UpsertFile(ctx context.Context, file *mfile.File) error

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL