store

package
v0.0.0-...-aeff70a Latest Latest
Warning

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

Go to latest
Published: Jun 6, 2022 License: MIT Imports: 11 Imported by: 5

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func WithTxRetry

func WithTxRetry(fn func(tx *gorm.DB) error, db *gorm.DB, retryCount int) error

func WithTxRetryDefault

func WithTxRetryDefault(fn func(tx *gorm.DB) error, db *gorm.DB) error

Types

type ConversionStore

type ConversionStore interface {
	AddFileToConvert(file *mcmodel.File) (*mcmodel.Conversion, error)
}

type FakeConversionStore

type FakeConversionStore struct{}

func NewFakeConversionStore

func NewFakeConversionStore() *FakeConversionStore

func (*FakeConversionStore) AddFileToConvert

func (s *FakeConversionStore) AddFileToConvert(file *mcmodel.File) (*mcmodel.Conversion, error)

type FakeFileStore

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

func NewFakeFileStore

func NewFakeFileStore(files []mcmodel.File) *FakeFileStore

func (*FakeFileStore) CreateDirIfNotExists

func (s *FakeFileStore) CreateDirIfNotExists(parentDirID int, path, name string, projectID, ownerID int) (*mcmodel.File, error)

func (*FakeFileStore) CreateDirectory

func (s *FakeFileStore) CreateDirectory(parentDirID, projectID, ownerID int, path, name string) (*mcmodel.File, error)

func (*FakeFileStore) CreateFile

func (s *FakeFileStore) CreateFile(name string, projectID, directoryID, ownerID int, mimeType string) (*mcmodel.File, error)

func (*FakeFileStore) DoneWritingToFile

func (s *FakeFileStore) DoneWritingToFile(file *mcmodel.File, checksum string, size int64, conversionStore ConversionStore) (bool, error)

func (*FakeFileStore) GetDirByPath

func (s *FakeFileStore) GetDirByPath(projectID int, path string) (*mcmodel.File, error)

func (*FakeFileStore) GetFileByPath

func (s *FakeFileStore) GetFileByPath(projectID int, path string) (*mcmodel.File, error)

func (*FakeFileStore) GetOrCreateDirPath

func (s *FakeFileStore) GetOrCreateDirPath(projectID, ownerID int, path string) (*mcmodel.File, error)

func (*FakeFileStore) ListDirectoryByPath

func (s *FakeFileStore) ListDirectoryByPath(projectID int, path string) ([]mcmodel.File, error)

func (*FakeFileStore) PointAtExistingIfExists

func (s *FakeFileStore) PointAtExistingIfExists(file *mcmodel.File) (bool, error)

func (*FakeFileStore) UpdateFileUses

func (s *FakeFileStore) UpdateFileUses(file *mcmodel.File, uuid string, fileID int) error

func (*FakeFileStore) UpdateMetadataForFileAndProject

func (s *FakeFileStore) UpdateMetadataForFileAndProject(file *mcmodel.File, checksum string, totalBytes int64) error

type FakeProjectStore

type FakeProjectStore struct {

	// Allow user to set this to determine if the call to UserCanAccessProject should return true or false.
	// It defaults to true (user can access) (See NewFakeProjectStore constructor)
	UserCanAccess bool
	// contains filtered or unexported fields
}

func NewFakeProjectStore

func NewFakeProjectStore(projects []mcmodel.Project) *FakeProjectStore

func (*FakeProjectStore) GetProjectByID

func (s *FakeProjectStore) GetProjectByID(projectID int) (*mcmodel.Project, error)

func (*FakeProjectStore) GetProjectBySlug

func (s *FakeProjectStore) GetProjectBySlug(slug string) (*mcmodel.Project, error)

func (*FakeProjectStore) GetProjectsForUser

func (s *FakeProjectStore) GetProjectsForUser(userID int) ([]mcmodel.Project, error)

func (*FakeProjectStore) UpdateProjectDirectoryCount

func (s *FakeProjectStore) UpdateProjectDirectoryCount(projectID int, directoryCount int) error

func (*FakeProjectStore) UpdateProjectSizeAndFileCount

func (s *FakeProjectStore) UpdateProjectSizeAndFileCount(projectID int, size int64, fileCount int) error

func (*FakeProjectStore) UserCanAccessProject

func (s *FakeProjectStore) UserCanAccessProject(userID, projectID int) bool

type FakeUserStore

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

func NewFakeUserStore

func NewFakeUserStore(users []mcmodel.User) *FakeUserStore

func (*FakeUserStore) GetUserBySlug

func (s *FakeUserStore) GetUserBySlug(slug string) (*mcmodel.User, error)

func (*FakeUserStore) GetUsersWithGlobusAccount

func (s *FakeUserStore) GetUsersWithGlobusAccount() (error, []mcmodel.User)

type FileStore

type FileStore interface {
	UpdateMetadataForFileAndProject(file *mcmodel.File, checksum string, totalBytes int64) error
	CreateFile(name string, projectID, directoryID, ownerID int, mimeType string) (*mcmodel.File, error)
	GetDirByPath(projectID int, path string) (*mcmodel.File, error)
	CreateDirectory(parentDirID, projectID, ownerID int, path, name string) (*mcmodel.File, error)
	CreateDirIfNotExists(parentDirID int, path, name string, projectID, ownerID int) (*mcmodel.File, error)
	ListDirectoryByPath(projectID int, path string) ([]mcmodel.File, error)
	GetOrCreateDirPath(projectID, ownerID int, path string) (*mcmodel.File, error)
	GetFileByPath(projectID int, path string) (*mcmodel.File, error)
	UpdateFileUses(file *mcmodel.File, uuid string, fileID int) error
	PointAtExistingIfExists(file *mcmodel.File) (bool, error)
	DoneWritingToFile(file *mcmodel.File, checksum string, size int64, conversionStore ConversionStore) (bool, error)
}

type GormConversionStore

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

func NewGormConversionStore

func NewGormConversionStore(db *gorm.DB) *GormConversionStore

func (*GormConversionStore) AddFileToConvert

func (s *GormConversionStore) AddFileToConvert(file *mcmodel.File) (*mcmodel.Conversion, error)

type GormFileStore

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

func NewGormFileStore

func NewGormFileStore(db *gorm.DB, mcfsRoot string) *GormFileStore

func (*GormFileStore) CreateDirIfNotExists

func (s *GormFileStore) CreateDirIfNotExists(parentDirID int, path, name string, projectID, ownerID int) (*mcmodel.File, error)

func (*GormFileStore) CreateDirectory

func (s *GormFileStore) CreateDirectory(parentDirID, projectID, ownerID int, path, name string) (*mcmodel.File, error)

func (*GormFileStore) CreateFile

func (s *GormFileStore) CreateFile(name string, projectID, directoryID, ownerID int, mimeType string) (*mcmodel.File, error)

func (*GormFileStore) DoneWritingToFile

func (s *GormFileStore) DoneWritingToFile(file *mcmodel.File, checksum string, size int64, conversionStore ConversionStore) (bool, error)

DoneWritingToFile is called when a file has been opened for writing and the caller is finished writing to it. It consolidates common steps such as updating metadata, switching to point to a file that already exists with the same checksum, and queuing the file for conversion (if needed).

func (*GormFileStore) GetDirByPath

func (s *GormFileStore) GetDirByPath(projectID int, path string) (*mcmodel.File, error)

func (*GormFileStore) GetFileByPath

func (s *GormFileStore) GetFileByPath(projectID int, path string) (*mcmodel.File, error)

func (*GormFileStore) GetOrCreateDirPath

func (s *GormFileStore) GetOrCreateDirPath(projectID, ownerID int, path string) (*mcmodel.File, error)

GetOrCreateDirPath will create all entries in the directory path if the path doesn't exist

func (*GormFileStore) ListDirectoryByPath

func (s *GormFileStore) ListDirectoryByPath(projectID int, path string) ([]mcmodel.File, error)

func (*GormFileStore) PointAtExistingIfExists

func (s *GormFileStore) PointAtExistingIfExists(file *mcmodel.File) (bool, error)

func (*GormFileStore) UpdateFileUses

func (s *GormFileStore) UpdateFileUses(file *mcmodel.File, uuid string, fileID int) error

func (*GormFileStore) UpdateMetadataForFileAndProject

func (s *GormFileStore) UpdateMetadataForFileAndProject(file *mcmodel.File, checksum string, totalBytes int64) error

UpdateMetadataForFileAndProject updates the metadata and project meta data for a file

type GormProjectStore

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

func NewGormProjectStore

func NewGormProjectStore(db *gorm.DB) *GormProjectStore

func (*GormProjectStore) GetProjectByID

func (s *GormProjectStore) GetProjectByID(projectID int) (*mcmodel.Project, error)

func (*GormProjectStore) GetProjectBySlug

func (s *GormProjectStore) GetProjectBySlug(slug string) (*mcmodel.Project, error)

func (*GormProjectStore) GetProjectsForUser

func (s *GormProjectStore) GetProjectsForUser(userID int) ([]mcmodel.Project, error)

func (*GormProjectStore) UpdateProjectDirectoryCount

func (s *GormProjectStore) UpdateProjectDirectoryCount(projectID int, directoryCount int) error

func (*GormProjectStore) UpdateProjectSizeAndFileCount

func (s *GormProjectStore) UpdateProjectSizeAndFileCount(projectID int, size int64, fileCount int) error

func (*GormProjectStore) UserCanAccessProject

func (s *GormProjectStore) UserCanAccessProject(userID, projectID int) bool

type GormTransferRequestFileStore

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

func NewGormTransferRequestFileStore

func NewGormTransferRequestFileStore(db *gorm.DB) *GormTransferRequestFileStore

func (*GormTransferRequestFileStore) DeleteTransferFileRequestByPath

func (s *GormTransferRequestFileStore) DeleteTransferFileRequestByPath(ownerID, projectID int, path string) error

func (*GormTransferRequestFileStore) DeleteTransferRequestFile

func (s *GormTransferRequestFileStore) DeleteTransferRequestFile(transferRequestFile *mcmodel.TransferRequestFile) error

func (*GormTransferRequestFileStore) GetTransferFileRequestByPath

func (s *GormTransferRequestFileStore) GetTransferFileRequestByPath(ownerID, projectID int, path string) (*mcmodel.TransferRequestFile, error)

type GormTransferRequestStore

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

func NewGormTransferRequestStore

func NewGormTransferRequestStore(db *gorm.DB, mcfsRoot string) *GormTransferRequestStore

func (*GormTransferRequestStore) CreateNewFile

func (s *GormTransferRequestStore) CreateNewFile(file, dir *mcmodel.File, transferRequest mcmodel.TransferRequest) (*mcmodel.File, error)

func (*GormTransferRequestStore) CreateNewFileVersion

func (s *GormTransferRequestStore) CreateNewFileVersion(file, dir *mcmodel.File, transferRequest mcmodel.TransferRequest) (*mcmodel.File, error)

func (*GormTransferRequestStore) GetFileByPath

func (s *GormTransferRequestStore) GetFileByPath(path string, transferRequest mcmodel.TransferRequest) (*mcmodel.File, error)

func (*GormTransferRequestStore) ListDirectory

func (s *GormTransferRequestStore) ListDirectory(dir *mcmodel.File, transferRequest mcmodel.TransferRequest) ([]mcmodel.File, error)

func (*GormTransferRequestStore) MarkFileAsOpen

func (s *GormTransferRequestStore) MarkFileAsOpen(file *mcmodel.File) error

func (*GormTransferRequestStore) MarkFileReleased

func (s *GormTransferRequestStore) MarkFileReleased(file *mcmodel.File, checksum string, projectID int, totalBytes int64) error

MarkFileReleased should only called for files that were created or opened with the Write flag set.

type GormUserStore

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

func NewGormUserStore

func NewGormUserStore(db *gorm.DB) *GormUserStore

func (*GormUserStore) GetUserBySlug

func (s *GormUserStore) GetUserBySlug(slug string) (*mcmodel.User, error)

func (*GormUserStore) GetUsersWithGlobusAccount

func (s *GormUserStore) GetUsersWithGlobusAccount() ([]mcmodel.User, error)

type ProjectStore

type ProjectStore interface {
	GetProjectByID(projectID int) (*mcmodel.Project, error)
	GetProjectBySlug(slug string) (*mcmodel.Project, error)
	GetProjectsForUser(userID int) ([]mcmodel.Project, error)
	UpdateProjectSizeAndFileCount(projectID int, size int64, fileCount int) error
	UpdateProjectDirectoryCount(projectID int, directoryCount int) error
	UserCanAccessProject(userID, projectID int) bool
}

type TransferRequestFileStore

type TransferRequestFileStore interface {
	DeleteTransferFileRequestByPath(ownerID, projectID int, path string) error
	GetTransferFileRequestByPath(ownerID, projectID int, path string) (*mcmodel.TransferRequestFile, error)
	DeleteTransferRequestFile(transferRequestFile *mcmodel.TransferRequestFile) error
}

type TransferRequestStore

type TransferRequestStore interface {
	MarkFileReleased(file *mcmodel.File, checksum string, projectID int, totalBytes int64) error
	MarkFileAsOpen(file *mcmodel.File) error
	CreateNewFile(file, dir *mcmodel.File, transferRequest mcmodel.TransferRequest) (*mcmodel.File, error)
	CreateNewFileVersion(file, dir *mcmodel.File, transferRequest mcmodel.TransferRequest) (*mcmodel.File, error)
	ListDirectory(dir *mcmodel.File, transferRequest mcmodel.TransferRequest) ([]mcmodel.File, error)
	GetFileByPath(path string, transferRequest mcmodel.TransferRequest) (*mcmodel.File, error)
}

type UserStore

type UserStore interface {
	GetUsersWithGlobusAccount() ([]mcmodel.User, error)
	GetUserBySlug(slug string) (*mcmodel.User, error)
}

Jump to

Keyboard shortcuts

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