Documentation
¶
Overview ¶
Package orgshare plans organization file sharing without touching Git or LFS paths.
Index ¶
- Constants
- Variables
- func Admit(input AdmitInput) error
- func CanDelete(isOwner, isUploader bool) bool
- func CanRead(isMember bool) bool
- func CanWrite(isMember bool) bool
- func CheckQuota(input QuotaInput) error
- func CleanJoin(parts []string) string
- func CoveredBytes(spans []Span) int64
- func Deadline(now time.Time, days int, permanent bool) time.Time
- func Expired(deadline, now time.Time) bool
- func Expiry(now time.Time, days int) time.Time
- func NormalizeChunk(n int64) int64
- func NormalizeParallel(n int) int
- func Open(filePath string) (*os.File, error)
- func Reserve(filePath string, size int64) (bool, error)
- func SafeParts(raw string) ([]string, error)
- func WriteAt(filePath string, offset int64, data []byte) (int64, error)
- func WriteAtReader(filePath string, offset int64, r io.Reader, length int64) error
- type AdmitInput
- type ContentRange
- type HTTPClient
- type HTTPItem
- type LimitError
- type QuotaInput
- type Span
- type Volume
Constants ¶
const ( // DefaultMaxBytes is the per-organization share cap, 100 GiB. DefaultMaxBytes int64 = 100 << 30 // DefaultMaxFileBytes leaves room for a language or IDE installer inside that cap. DefaultMaxFileBytes int64 = 32 << 30 // DefaultExpireDays removes a new object after 30 days unless it is marked permanent. DefaultExpireDays = 30 // DefaultReserveBytes stays free on the share volume so the disk is not filled to zero. DefaultReserveBytes int64 = 1 << 30 DefaultParallel = 4 MaxParallel = 8 DefaultChunkBytes int64 = 8 << 20 MaxChunkBytes int64 = 32 << 20 )
Variables ¶
var MeasureVolume = measureVolume
MeasureVolume reads free space for path. Tests may replace it.
Functions ¶
func Admit ¶
func Admit(input AdmitInput) error
Admit rejects an upload that would pass the organization cap or the disk reserve.
func CheckQuota ¶
func CheckQuota(input QuotaInput) error
CheckQuota rejects an object that would pass the organization or file cap.
func CoveredBytes ¶
CoveredBytes is the number of bytes contained in spans.
func Deadline ¶
Deadline returns when a new object expires. Permanent objects and a non-positive day count do not expire.
func NormalizeChunk ¶
NormalizeChunk clamps one request body. Zero uses the default.
func Reserve ¶
Reserve creates the upload file and asks the filesystem to keep size bytes when it can. The boolean is false when the file is only sparse, so later chunks must recheck free space.
Types ¶
type AdmitInput ¶
type AdmitInput struct {
Used int64
Incoming int64
MaxBytes int64
MaxFile int64
Available int64
Reserve int64
DiskKnown bool
}
AdmitInput is the quota and disk check performed before bytes are accepted.
type ContentRange ¶
ContentRange is an inclusive byte range.
func ParseContentRange ¶
func ParseContentRange(header string) (ContentRange, error)
ParseContentRange reads "bytes START-END/TOTAL". The end byte is inclusive.
func (ContentRange) Length ¶
func (r ContentRange) Length() int64
Length is the number of bytes in the inclusive range.
type HTTPClient ¶
type HTTPClient struct {
Client *http.Client
BaseURL string
Token string
Parallel int
ChunkSize int64
}
HTTPClient uploads and downloads share objects with parallel byte ranges.
type HTTPItem ¶
type HTTPItem struct {
ID int64 `json:"id"`
Name string `json:"name"`
Size int64 `json:"size"`
Link string `json:"link"`
}
HTTPItem is one object created by PutFile.
type LimitError ¶
type LimitError struct {
Code string
Used int64
Limit int64
Incoming int64
Available int64
Reserve int64
}
LimitError is a refusal that happened before any new chunk was stored.
func (*LimitError) Error ¶
func (e *LimitError) Error() string
type QuotaInput ¶
QuotaInput is the size check before a new object is accepted.
type Span ¶
Span is a half-open byte interval [Start, End).
func AddSpan ¶
AddSpan merges a chunk into the covered set. A chunk that is already covered is ignored so a retry can be repeated. A partial overlap is rejected so two writers cannot tear the same bytes.
func PlanChunks ¶
PlanChunks splits size into chunks of chunk bytes. The last chunk is shorter.