Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update documation and expose remaing bytes in chunk upload #1

Merged
merged 1 commit into from
Nov 22, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 2 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -109,11 +109,9 @@ Examples

Full documentation
==================
Generate document locally
You can read the documentation at https://egnyte.github.io/egnyte-go-sdk/ and https://pkg.go.dev/github.com/egnyte/egnyte-go-sdk


```
godoc -http=:6060 & open http://localhost:6060/pkg/github.com/egnyte/egnyte-go-sdk/egnyte
```

Command line
============
Expand Down
14 changes: 11 additions & 3 deletions egnyte/chunk_upload.go
Original file line number Diff line number Diff line change
Expand Up @@ -20,14 +20,20 @@ type ChunkUploadInfo struct {
lastChunk []byte
}

// Init chunk for a given file
func (c *ChunkUploadInfo) Init(data io.Reader, size int64, chunkSize int64) {
c.checkSumMap = make(map[int]string)
c.data = data
c.remainingBytes = size
c.chunkSize = chunkSize
c.chunkNum = 0
c.lastChunk = nil

}

func (c *ChunkUploadInfo) GetRemainingBytes() int64 {
c.dataMutex.Lock()
defer c.dataMutex.Unlock()
return c.remainingBytes
}

// GetChunk returns chunk
Expand Down Expand Up @@ -57,6 +63,8 @@ func (c *ChunkUploadInfo) GetChunk() ([]byte, int64, int, error) {
}

func (c *ChunkUploadInfo) GetLastChunk() ([]byte, int) {
c.dataMutex.Lock()
defer c.dataMutex.Unlock()
return c.lastChunk, c.chunkNum
}

Expand All @@ -66,8 +74,8 @@ func (c *ChunkUploadInfo) SetChunkCheckSum(chunkNum int, csum string) {
c.checkSumMap[chunkNum] = csum
}

// GetResultChecksum return final check sum of all chunks
func (c *ChunkUploadInfo) GetResultChecksum() string {
// GetResultCsum return final check sum of all chunks
func (c *ChunkUploadInfo) GetResultCsum() string {
c.resultMutex.Lock()
defer c.resultMutex.Unlock()
res := ""
Expand Down