Help us shape the future of Go! Take the 2026 Go Developer Survey

orgshare

package
v1.17.1 Latest Latest
Warning

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

Go to latest
Published: Oct 23, 2026 License: MIT Imports: 5 Imported by: 0

Documentation

Index

Constants

View Source
const (
	KindFile = "file"
	KindDir  = "dir"
	KindText = "text"
)

Variables

This section is empty.

Functions

func CountFiles

func CountFiles(ctx context.Context, orgID int64) (int64, error)

CountFiles counts files and text notes, not folders.

func DeleteItem

func DeleteItem(ctx context.Context, orgID, id int64) error

DeleteItem removes one row.

func DeleteUpload

func DeleteUpload(ctx context.Context, id string) error

DeleteUpload removes a session.

func InsertItem

func InsertItem(ctx context.Context, item *ShareItem) error

InsertItem stores a new share object.

func InsertUpload

func InsertUpload(ctx context.Context, upload *ShareUpload) error

InsertUpload stores a resumable session.

func IsErrNotExist

func IsErrNotExist(err error) bool

IsErrNotExist reports a missing share item.

func ReservedBytes

func ReservedBytes(ctx context.Context, orgID int64) (int64, error)

ReservedBytes is stored objects plus in-progress uploads.

func SetQuota

func SetQuota(ctx context.Context, orgID, maxBytes int64) error

SetQuota stores a per-organization cap. Zero deletes the override and the default applies.

func UpdateExpiry

func UpdateExpiry(ctx context.Context, item *ShareItem) error

UpdateExpiry stores a new deadline. Zero means the object is permanent.

func UpdateStorageKey

func UpdateStorageKey(ctx context.Context, item *ShareItem) error

UpdateStorageKey stores the object path after the row id exists.

func UpdateUploadProgress

func UpdateUploadProgress(ctx context.Context, upload *ShareUpload) error

UpdateUploadProgress stores covered ranges after a chunk lands.

func UsedBytes

func UsedBytes(ctx context.Context, orgID int64) (int64, error)

UsedBytes sums stored object sizes for an organization.

Types

type ErrNotExist

type ErrNotExist struct{ ID int64 }

ErrNotExist is returned when a share object is missing.

func (ErrNotExist) Error

func (err ErrNotExist) Error() string

func (ErrNotExist) Unwrap

func (err ErrNotExist) Unwrap() error

type ShareItem

type ShareItem struct {
	ID          int64              `xorm:"pk autoincr"`
	OrgID       int64              `xorm:"INDEX NOT NULL"`
	ParentID    int64              `xorm:"INDEX NOT NULL DEFAULT 0"`
	Name        string             `xorm:"VARCHAR(255) NOT NULL"`
	Kind        string             `xorm:"VARCHAR(16) NOT NULL"`
	Size        int64              `xorm:"NOT NULL DEFAULT 0"`
	SHA256      string             `xorm:"VARCHAR(64)"`
	StorageKey  string             `xorm:"VARCHAR(255)"`
	Text        string             `xorm:"TEXT"`
	UploaderID  int64              `xorm:"INDEX NOT NULL"`
	ExpiresUnix timeutil.TimeStamp `xorm:"INDEX"`
	CreatedUnix timeutil.TimeStamp `xorm:"INDEX created"`
	UpdatedUnix timeutil.TimeStamp `xorm:"INDEX updated"`
}

ShareItem is one file, folder, or text note in an organization share.

func FindChild

func FindChild(ctx context.Context, orgID, parentID int64, name, kind string) (*ShareItem, error)

FindChild looks up one named child.

func GetItem

func GetItem(ctx context.Context, orgID, id int64) (*ShareItem, error)

GetItem loads one object in an organization.

func ListExpired

func ListExpired(ctx context.Context, now timeutil.TimeStamp) ([]*ShareItem, error)

ListExpired returns objects whose deadline has passed.

func ListItems

func ListItems(ctx context.Context, orgID, parentID int64) ([]*ShareItem, error)

ListItems returns the children of a folder. parentID 0 is the root.

func (ShareItem) TableName

func (ShareItem) TableName() string

TableName keeps the table out of Git and LFS tables.

type ShareQuota

type ShareQuota struct {
	OrgID       int64              `xorm:"pk"`
	MaxBytes    int64              `xorm:"NOT NULL"`
	UpdatedUnix timeutil.TimeStamp `xorm:"updated"`
}

ShareQuota is an optional per-organization cap. A missing row uses the server default.

func GetQuota

func GetQuota(ctx context.Context, orgID int64) (*ShareQuota, error)

GetQuota loads a per-organization cap.

func (ShareQuota) TableName

func (ShareQuota) TableName() string

TableName keeps quota rows beside share items.

type ShareUpload

type ShareUpload struct {
	ID           string             `xorm:"pk VARCHAR(64)"`
	OrgID        int64              `xorm:"INDEX NOT NULL"`
	ParentID     int64              `xorm:"NOT NULL DEFAULT 0"`
	Name         string             `xorm:"VARCHAR(255) NOT NULL"`
	Size         int64              `xorm:"NOT NULL"`
	Received     int64              `xorm:"NOT NULL DEFAULT 0"`
	SHA256       string             `xorm:"VARCHAR(64)"`
	Ranges       string             `xorm:"ranges_json TEXT"`
	Preallocated bool               `xorm:"NOT NULL DEFAULT false"`
	UploaderID   int64              `xorm:"NOT NULL"`
	ExpiresUnix  timeutil.TimeStamp `xorm:"INDEX"`
	CreatedUnix  timeutil.TimeStamp `xorm:"created"`
}

ShareUpload is an in-progress resumable upload.

func FindUpload

func FindUpload(ctx context.Context, orgID, parentID, uploaderID, size int64, name string) (*ShareUpload, error)

FindUpload returns an in-progress session with the same name and size.

func GetUpload

func GetUpload(ctx context.Context, orgID int64, id string) (*ShareUpload, error)

GetUpload loads a session owned by the organization.

func ListExpiredUploads

func ListExpiredUploads(ctx context.Context, now timeutil.TimeStamp) ([]*ShareUpload, error)

ListExpiredUploads returns sessions whose deadline has passed.

func (ShareUpload) TableName

func (ShareUpload) TableName() string

TableName keeps upload sessions beside share items.

Jump to

Keyboard shortcuts

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