upload_utils

package
v1.1.2 Latest Latest
Warning

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

Go to latest
Published: Aug 23, 2024 License: Apache-2.0 Imports: 29 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func FindMinMissingInteger added in v1.1.0

func FindMinMissingInteger(arr []int) int

FindMinMissingInteger finds the minimum missing integer in a sorted array

Types

type AddFileMsg

type AddFileMsg struct {
	Name string
}

AddFileMsg is a message that is used to add a file to the upload status monitor

func (AddFileMsg) UpdateStatus

func (msg AddFileMsg) UpdateStatus(m *UploadStatusMonitor)

type CanUpdateStatus added in v1.1.0

type CanUpdateStatus interface {
	UpdateStatus(m *UploadStatusMonitor)
}

type FileInfo

type FileInfo struct {
	Path   string
	Size   int64
	Sha256 string
}

FileInfo contains the path, size and sha256 of a file.

type IntHeap added in v1.1.0

type IntHeap []int

An IntHeap is a min-heap of ints.

func NewHeap added in v1.1.0

func NewHeap(s []int) *IntHeap

func (IntHeap) Len added in v1.1.0

func (h IntHeap) Len() int

func (IntHeap) Less added in v1.1.0

func (h IntHeap) Less(i, j int) bool

func (*IntHeap) Peek added in v1.1.0

func (h *IntHeap) Peek() int

func (*IntHeap) Pop added in v1.1.0

func (h *IntHeap) Pop() any

func (*IntHeap) Push added in v1.1.0

func (h *IntHeap) Push(x any)

func (*IntHeap) Remove added in v1.1.0

func (h *IntHeap) Remove(x any)

func (IntHeap) Swap added in v1.1.0

func (h IntHeap) Swap(i, j int)

type MultipartOpts added in v1.1.0

type MultipartOpts struct {
	Threads uint
	Size    string
}

func (*MultipartOpts) Valid added in v1.1.0

func (opt *MultipartOpts) Valid() error

type UpdateStatusMsg

type UpdateStatusMsg struct {
	Name     string
	Total    int64
	Uploaded int64
	Status   UploadStatusEnum
}

func (UpdateStatusMsg) UpdateStatus

func (msg UpdateStatusMsg) UpdateStatus(m *UploadStatusMonitor)

type UploadDB added in v1.1.0

type UploadDB struct {
	*bolt.DB
}

func NewUploadDB added in v1.1.0

func NewUploadDB(filename string, recordId string, hash string) (*UploadDB, error)

func (*UploadDB) BatchPut added in v1.1.0

func (db *UploadDB) BatchPut(kvs map[string][]byte) error

BatchPut puts a batch of key-value pairs into the database.

func (*UploadDB) Delete added in v1.1.0

func (db *UploadDB) Delete() error

Delete removes the database file from the filesystem.

func (*UploadDB) Get added in v1.1.0

func (db *UploadDB) Get(key string) ([]byte, error)

Get retrieves the value of a key from the database. if the key does not exist, it returns nil.

func (*UploadDB) Reset added in v1.1.1

func (db *UploadDB) Reset() error

Reset removes all the keys from the database multipart_uploads bucket.

type UploadManager

type UploadManager struct {
	StatusMonitor *tea.Program

	FileInfos map[string]FileInfo
	Errs      map[string]error
	sync.WaitGroup
	// contains filtered or unexported fields
}

UploadManager is a manager for uploading files through minio client. Note that it's user's responsibility to check the Errs field after Wait() to see if there's any error.

func NewUploadManager

func NewUploadManager(client *minio.Client, hideMonitor bool, opts *MultipartOpts) *UploadManager

func NewUploadManagerFromConfig added in v1.1.0

func NewUploadManagerFromConfig(pm *config.ProfileManager, proj *name.Project, timeout time.Duration, hideMonitor bool, multiOpts *MultipartOpts) (*UploadManager, error)

func (*UploadManager) AddErr

func (um *UploadManager) AddErr(path string, err error)

AddErr adds an error to the manager.

func (*UploadManager) Debugf added in v1.1.0

func (um *UploadManager) Debugf(format string, args ...interface{})

func (*UploadManager) FMultipartPutObject

func (um *UploadManager) FMultipartPutObject(ctx context.Context, bucket string, key string, filePath string, fileSize int64, fileSha256 string, opts minio.PutObjectOptions) (err error)

func (*UploadManager) FPutObject

func (um *UploadManager) FPutObject(absPath string, bucket string, key string, userTags map[string]string)

FPutObject uploads a file to a bucket with a key and sha256. If the file size is larger than minPartSize, it will use multipart upload.

func (*UploadManager) PrintErrs added in v1.1.0

func (um *UploadManager) PrintErrs()

PrintErrs prints all errors.

func (*UploadManager) UpdateMonitor added in v1.1.2

func (um *UploadManager) UpdateMonitor(msg interface{})

func (*UploadManager) UploadFileThroughUrl added in v1.1.0

func (um *UploadManager) UploadFileThroughUrl(file string, uploadUrl string) error

UploadFileThroughUrl uploads a single file to the given uploadUrl. um is the upload manager to use. file is the absolute path of the file to be uploaded. uploadUrl is the pre-signed url to upload the file to.

func (*UploadManager) Wait

func (um *UploadManager) Wait()

Wait waits for all uploads to finish. And wait for status monitor to finish.

type UploadStatusEnum

type UploadStatusEnum int

UploadStatusEnum is used to keep track of the state of a file upload

const (
	// Unprocessed is used to indicate that the file has not been processed yet
	Unprocessed UploadStatusEnum = iota

	// PreviouslyUploaded is used to indicate that the file has been uploaded before
	PreviouslyUploaded

	// UploadInProgress is used to indicate that the file upload is in progress
	UploadInProgress

	// UploadCompleted is used to indicate that the file upload has completed
	UploadCompleted

	// MultipartCompletionInProgress is used to indicate that the multipart upload completion is in progress
	MultipartCompletionInProgress

	// UploadFailed is used to indicate that the file upload has failed
	UploadFailed
)

type UploadStatusMonitor

type UploadStatusMonitor struct {
	ManualQuit bool
	// contains filtered or unexported fields
}

UploadStatusMonitor is a bubbletea model that is used to monitor the progress of file uploads

func NewUploadStatusMonitor

func NewUploadStatusMonitor(startSignal *sync.WaitGroup) *UploadStatusMonitor

func (*UploadStatusMonitor) Init

func (m *UploadStatusMonitor) Init() tea.Cmd

func (*UploadStatusMonitor) Update

func (m *UploadStatusMonitor) Update(msg tea.Msg) (tea.Model, tea.Cmd)

func (*UploadStatusMonitor) View

func (m *UploadStatusMonitor) View() string

Jump to

Keyboard shortcuts

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