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

softwarecenter

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: 28 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 Platform added in v1.17.0

func Platform(name string) string

Platform is inferred from the suffix, never from a directory or an architecture name.

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"`
	Generation int64    `json:"generation,omitempty"`
	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 Entry added in v1.17.0

type Entry struct {
	*SoftwareNodeInfo
	Platform string `json:"platform"`
	Path     string `json:"path"`
}

type Listing added in v1.17.0

type Listing struct {
	Entries     []*Entry            `json:"entries"`
	Folders     []*SoftwareNodeInfo `json:"folders"`
	Breadcrumbs []*SoftwareNodeInfo `json:"breadcrumbs"`
	Used        int64               `json:"used"`
	Reserved    int64               `json:"reserved"`
	Quota       int64               `json:"quota"`
	Total       int                 `json:"total"`
	Page        int                 `json:"page"`
}

func List added in v1.17.0

func List(ctx context.Context, orgID int64, parent, query string, page int, recursive bool) (*Listing, error)

func ListFiltered added in v1.17.1

func ListFiltered(ctx context.Context, orgID int64, parent, query string, page int, recursive bool, platform string) (*Listing, 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 OrganizeOptions added in v1.17.0

type OrganizeOptions struct {
	Parent    string            `json:"parent"`
	Apply     bool              `json:"apply"`
	Revision  string            `json:"revision"`
	Platforms map[string]string `json:"platforms"`
}

OrganizeOptions selects a subtree and optionally applies a previously previewed revision. swagger:model SoftwareOrganizeOptions

type OrganizeReport added in v1.17.0

type OrganizeReport struct {
	Applied  bool          `json:"applied"`
	Revision string        `json:"revision"`
	Moves    []PlannedMove `json:"moves"`
	Skipped  []PlannedMove `json:"skipped"`
	Created  []string      `json:"created"`
}

func Organize added in v1.17.0

func Organize(ctx context.Context, orgID, userID int64, opts OrganizeOptions) (*OrganizeReport, error)

Organize changes only directory metadata and parent IDs in one atomic save.

type PlannedMove added in v1.17.0

type PlannedMove struct {
	ID       string `json:"id"`
	From     string `json:"from"`
	To       string `json:"to"`
	Platform string `json:"platform"`
	Reason   string `json:"reason,omitempty"`
}

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 SoftwareNodeInfo added in v1.17.0

type SoftwareNodeInfo 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"`
}

SoftwareNodeInfo is the listing projection; upload keys and owner IDs never leave the server.

type State

type State struct {
	Version    int                     `json:"version"`
	Generation int64                   `json:"generation,omitempty"`
	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