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

softwarecenter

package
v1.9.0 Latest Latest
Warning

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

Go to latest
Published: Oct 17, 2026 License: MIT Imports: 26 Imported by: 0

Documentation

Overview

Package softwarecenter implements a single-writer organization file share outside Git/LFS.

Index

Constants

View Source
const (
	DefaultQuota int64 = 100 * 1024 * 1024 * 1024
	MaxQuota     int64 = 10 * 1024 * 1024 * 1024 * 1024
	MaxEntries         = 20000
)
View Source
const ChunkSize int64 = 8 * 1024 * 1024
View Source
const MaxSelection = 500

Variables

View Source
var (
	ErrInvalid      = errors.New("invalid file or folder")
	ErrConflict     = errors.New("name already exists or folder changed")
	ErrQuota        = errors.New("organization storage quota exceeded")
	ErrBusy         = errors.New("upload capacity busy")
	ErrDiskCapacity = errors.New("insufficient unreserved disk capacity")
)

Functions

func CancelUpload added in v1.9.0

func CancelUpload(ctx context.Context, orgID, userID int64, id string) error

func Delete

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

func DeleteMany added in v1.9.0

func DeleteMany(ctx context.Context, orgID int64, ids []string) error

func EnsureDirectories added in v1.9.0

func EnsureDirectories(ctx context.Context, orgID, userID int64, parent string, paths []string) (map[string]string, error)

EnsureDirectories creates one bounded batch atomically, retaining the uploaded relative paths.

func FinishDownload added in v1.9.0

func FinishDownload(ctx context.Context, orgID, userID int64, id string) error

FinishDownload persists one receipt per request; progress writes never touch the database.

func Move added in v1.9.0

func Move(ctx context.Context, orgID int64, ids []string, target string) error

func RemoveDownload added in v1.9.0

func RemoveDownload(ctx context.Context, orgID, userID int64, id string) error

func Rename

func Rename(ctx context.Context, orgID int64, id, name string) error

func SetQuota

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

func StartDownloadProgress added in v1.9.0

func StartDownloadProgress(id string, total, offset int64) func(int64, string)

Types

type ArchiveEntry added in v1.9.0

type ArchiveEntry struct {
	ID        string `json:"id"`
	Path      string `json:"path"`
	Directory bool   `json:"directory"`
	Digest    string `json:"digest"`
	Size      int64  `json:"size"`
	CRC32     uint32 `json:"crc32"`
	Modified  int64  `json:"modified"`
}

type DownloadJob added in v1.9.0

type DownloadJob struct {
	ID      string   `json:"id"`
	UserID  int64    `json:"user_id"`
	IDs     []string `json:"ids"`
	Name    string   `json:"name"`
	ETag    string   `json:"etag"`
	Size    int64    `json:"size"`
	Created int64    `json:"created"`
	Expires int64    `json:"expires"`
	Single  bool     `json:"single"`
	State   string   `json:"state,omitempty"`
	Bytes   int64    `json:"bytes,omitempty"`
	Speed   float64  `json:"speed,omitempty"`
}

func CreateDownload added in v1.9.0

func CreateDownload(ctx context.Context, orgID, userID int64, ids []string) (*DownloadJob, error)

func Downloads added in v1.9.0

func Downloads(ctx context.Context, orgID, userID int64) ([]*DownloadJob, error)

func GetDownload added in v1.9.0

func GetDownload(ctx context.Context, orgID, userID int64, id string) (*DownloadJob, error)

func OpenDownload added in v1.9.0

func OpenDownload(ctx context.Context, orgID, userID int64, id string) (*DownloadJob, io.ReadSeekCloser, error)

type Node

type Node struct {
	ID        string  `json:"id"`
	Parent    string  `json:"parent"`
	Name      string  `json:"name"`
	Directory bool    `json:"directory"`
	Size      int64   `json:"size"`
	Digest    string  `json:"digest,omitempty"`
	Modified  int64   `json:"modified"`
	UserID    int64   `json:"user_id"`
	CRC32     *uint32 `json:"crc32,omitempty"`
	UploadKey string  `json:"upload_key,omitempty"`
}

func CompleteUpload added in v1.9.0

func CompleteUpload(ctx context.Context, orgID, userID int64, id string) (*Node, error)

func CreateFolder

func CreateFolder(ctx context.Context, orgID, userID int64, parent, name string) (*Node, error)

func Open

func Open(ctx context.Context, orgID int64, id string) (*Node, *os.File, error)

func Upload

func Upload(ctx context.Context, orgID, userID int64, parent, name string, size int64, body io.Reader) (*Node, error)

type Reservation

type Reservation struct {
	Parent    string `json:"parent"`
	Name      string `json:"name"`
	Size      int64  `json:"size"`
	Started   int64  `json:"started"`
	UserID    int64  `json:"user_id,omitempty"`
	Resumable bool   `json:"resumable,omitempty"`
	Offset    int64  `json:"offset,omitempty"`
	ClientKey string `json:"client_key,omitempty"`
	Chain     string `json:"chain,omitempty"`
	HashState []byte `json:"hash_state,omitempty"`
	CRC32     uint32 `json:"crc32,omitempty"`
}

type State

type State struct {
	Version   int                     `json:"version"`
	Quota     int64                   `json:"quota"`
	Nodes     map[string]*Node        `json:"nodes"`
	Uploads   map[string]Reservation  `json:"uploads"`
	Garbage   map[string]int64        `json:"garbage,omitempty"`
	Downloads map[string]*DownloadJob `json:"downloads,omitempty"`
}

func Load

func Load(ctx context.Context, orgID int64) (*State, error)

func Snapshot

func Snapshot(ctx context.Context, orgID int64) (*State, error)

Snapshot is immutable and short-lived; membership is checked separately on every HTTP request.

func (*State) Reserved

func (s *State) Reserved() int64

func (*State) Used

func (s *State) Used() int64

type TransferProgress added in v1.9.0

type TransferProgress struct {
	Bytes   int64   `json:"bytes"`
	Total   int64   `json:"total"`
	State   string  `json:"state"`
	Updated int64   `json:"updated"`
	Speed   float64 `json:"speed"`
}

func DownloadProgress added in v1.9.0

func DownloadProgress(job *DownloadJob) TransferProgress

type UploadStatus added in v1.9.0

type UploadStatus struct {
	ID        string `json:"id"`
	Parent    string `json:"parent"`
	Name      string `json:"name"`
	Size      int64  `json:"size"`
	Offset    int64  `json:"offset"`
	ClientKey string `json:"client_key"`
	Chain     string `json:"chain"`
	ChunkSize int64  `json:"chunk_size"`
	Updated   int64  `json:"updated"`
	Node      *Node  `json:"node,omitempty"`
}

func AppendUpload added in v1.9.0

func AppendUpload(ctx context.Context, orgID, userID int64, id string, offset, size int64, digest string, body io.Reader) (*UploadStatus, error)

func BeginUpload added in v1.9.0

func BeginUpload(ctx context.Context, orgID, userID int64, parent, name, clientKey string, size int64) (*UploadStatus, error)

func GetUpload added in v1.9.0

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

func Uploads added in v1.9.0

func Uploads(ctx context.Context, orgID, userID int64) ([]*UploadStatus, error)

Jump to

Keyboard shortcuts

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