Documentation
¶
Index ¶
- func CheckUserQuota(ctx context.Context, userID int, fileSize int64) (bool, error)
- func CleanupExpiredUploadSessions(ctx context.Context) error
- func Close() error
- func CountUsers(ctx context.Context) (int, error)
- func CreateFile(ctx context.Context, file *model.FileObject) error
- func CreateRepository(ctx context.Context, mo *model.Repository) error
- func CreateShare(ctx context.Context, mo *model.Share) error
- func CreateUploadChunk(ctx context.Context, chunk *model.UploadChunk) error
- func CreateUploadSession(ctx context.Context, session *model.UploadSession) error
- func CreateUser(ctx context.Context, user *model.User) error
- func DeleteFile(ctx context.Context, id int) error
- func DeleteFileByPath(ctx context.Context, repoID int, path string) error
- func DeleteShareByID(ctx context.Context, id int) error
- func DeleteUploadSession(ctx context.Context, uploadID string) error
- func DeleteUser(ctx context.Context, id int) error
- func GetChangesSince(ctx context.Context, repoID int, sinceVersion string, limit int) ([]*model.ChangeLog, error)
- func GetChildFiles(ctx context.Context, parentID int) ([]*model.FileObject, error)
- func GetCurrentVersion(ctx context.Context, repoID int) (*model.RepositoryVersion, error)
- func GetDB() *bun.DB
- func GetFile(ctx context.Context, reposID int, path string) (*model.FileObject, error)
- func GetFileByID(ctx context.Context, id int) (*model.FileObject, error)
- func GetFilesByUserAndPathPrefix(ctx context.Context, userID int, pathPrefix string) ([]*model.FileObject, error)
- func GetRepositoryByID(ctx context.Context, id int) (*model.Repository, error)
- func GetRepositoryByName(ctx context.Context, name string) (*model.Repository, error)
- func GetRepositoryByNameAndOwner(ctx context.Context, name string, userID int) (*model.Repository, error)
- func GetShareByID(ctx context.Context, id int) (*model.Share, error)
- func GetShareForObject(ctx context.Context, userID int, res *model.Resource) (*model.Share, error)
- func GetSharesByUserID(ctx context.Context, userID int) ([]*model.Share, error)
- func GetUploadChunk(ctx context.Context, uploadID string, chunkIndex int) (*model.UploadChunk, error)
- func GetUploadSession(ctx context.Context, uploadID string) (*model.UploadSession, error)
- func GetUploadedChunks(ctx context.Context, uploadID string) ([]*model.UploadChunk, error)
- func GetUserByEmail(ctx context.Context, email string) (*model.User, error)
- func GetUserByID(ctx context.Context, id int) (*model.User, error)
- func GetUserByUsername(ctx context.Context, username string) (*model.User, error)
- func GetUserQuotaUsage(ctx context.Context, userID int) (int64, error)
- func IncrementUploadedChunks(ctx context.Context, uploadID string) error
- func Init(ctx context.Context, dsn string)
- func ListRepositories(ctx context.Context, userID int) ([]*model.Repository, error)
- func RecordChange(ctx context.Context, change *model.ChangeLog) error
- func UpdateContentType(ctx context.Context, objects []*model.FileObject) error
- func UpdateFile(ctx context.Context, id int, update *FileUpdate) error
- func UpdateUploadSessionStatus(ctx context.Context, uploadID string, status string) error
- func UpdateUser(ctx context.Context, id int, update *UserUpdate) error
- func UpdateUserHA1(ctx context.Context, id int, ha1 string) error
- func UpdateUserQuota(ctx context.Context, userID int, totalQuotaBytes int64) error
- func UpdateVersion(ctx context.Context, repoID int, newVersion string, versionVector string) error
- func UpsertFile(ctx context.Context, file *model.FileObject) error
- type ChangeLogModel
- type FileModel
- type FileUpdate
- type ReposModel
- type RepositoryVersionModel
- type ShareModel
- type UploadChunkModel
- type UploadSessionModel
- type UserModel
- type UserQuotaModel
- type UserUpdate
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func CheckUserQuota ¶
CheckUserQuota checks if a user has enough space for a file of given size
func CreateFile ¶
func CreateFile(ctx context.Context, file *model.FileObject) error
CreateFile creates a new file record in the database
func CreateRepository ¶
func CreateRepository(ctx context.Context, mo *model.Repository) error
func CreateUploadChunk ¶
func CreateUploadChunk(ctx context.Context, chunk *model.UploadChunk) error
func CreateUploadSession ¶
func CreateUploadSession(ctx context.Context, session *model.UploadSession) error
func CreateUser ¶
CreateUser creates a new user in the database
func DeleteFile ¶
DeleteFile deletes a file with the given ID
func DeleteFileByPath ¶
DeleteFileByPath marks a file as deleted by path and user
func DeleteUser ¶
DeleteUser marks a user as inactive (soft delete)
func GetChangesSince ¶
func GetChildFiles ¶
func GetCurrentVersion ¶
func GetFileByID ¶
GetFileByID retrieves a file by ID
func GetFilesByUserAndPathPrefix ¶
func GetFilesByUserAndPathPrefix(ctx context.Context, userID int, pathPrefix string) ([]*model.FileObject, error)
GetFilesByUserAndPathPrefix retrieves files under a specific path for a user
func GetRepositoryByID ¶
func GetRepositoryByName ¶
func GetShareForObject ¶
func GetSharesByUserID ¶
func GetUploadChunk ¶
func GetUploadSession ¶
func GetUploadedChunks ¶
func GetUserByEmail ¶
GetUserByEmail retrieves a user by email
func GetUserByID ¶
GetUserByID retrieves a user by ID
func GetUserByUsername ¶
GetUserByUsername retrieves a user by username
func GetUserQuotaUsage ¶
GetUserQuotaUsage returns the used bytes for a user
func IncrementUploadedChunks ¶
func ListRepositories ¶
func UpdateContentType ¶
func UpdateContentType(ctx context.Context, objects []*model.FileObject) error
UpdateContentType updates content type of specified objects in database.
func UpdateFile ¶
func UpdateFile(ctx context.Context, id int, update *FileUpdate) error
UpdateFile updates a file in the database
func UpdateUser ¶
func UpdateUser(ctx context.Context, id int, update *UserUpdate) error
UpdateUser updates a user in the database
func UpdateUserHA1 ¶
UpdateUserHA1 updates a user's HA1 hash and realm
func UpdateUserQuota ¶
UpdateUserQuota updates the storage quota for a user
func UpdateVersion ¶
func UpsertFile ¶
func UpsertFile(ctx context.Context, file *model.FileObject) error
UpsertFile creates a new file or updates an existing file in the database using PostgreSQL's UPSERT functionality based on repo_id and path
Types ¶
type ChangeLogModel ¶
type FileModel ¶
type FileModel struct {
bun.BaseModel `bun:"table:files"`
*model.FileObject
}
FileModel represents a file object for database operations
type FileUpdate ¶
type FileUpdate struct {
MimeType *string `json:"mime_type,omitempty"`
Size *int64 `json:"size,omitempty"`
Checksum *string `json:"checksum,omitempty"`
UpdatedAt *time.Time `json:"updated_at,omitempty"`
}
FileUpdate contains fields that can be updated for a file
type ReposModel ¶
type ReposModel struct {
bun.BaseModel `bun:"table:repositories"`
*model.Repository
}
type RepositoryVersionModel ¶
type RepositoryVersionModel struct {
bun.BaseModel `bun:"table:repository_versions"`
*model.RepositoryVersion
}
type ShareModel ¶
type ShareModel struct {
}
ShareModel represents a share object for database operations
type UploadChunkModel ¶
type UploadChunkModel struct {
bun.BaseModel `bun:"table:upload_chunks"`
*model.UploadChunk
}
type UploadSessionModel ¶
type UploadSessionModel struct {
bun.BaseModel `bun:"table:upload_sessions"`
*model.UploadSession
}
type UserQuotaModel ¶
UserQuotaModel represents storage quota for a user
func GetUserQuota ¶
func GetUserQuota(ctx context.Context, userID int) (*UserQuotaModel, error)
GetUserQuota retrieves the storage quota for a user
type UserUpdate ¶
type UserUpdate struct {
FirstName *string `json:"first_name,omitempty"`
LastName *string `json:"last_name,omitempty"`
LastLogin *time.Time `json:"last_login,omitempty"`
IsActive *bool `json:"is_active,omitempty"`
IsAdmin *bool `json:"is_admin,omitempty"`
}
UserUpdate contains fields that can be updated for a user