Skip to content

Commit

Permalink
Update documation and expose remaing bytes in chunk upload
Browse files Browse the repository at this point in the history
  • Loading branch information
atiwari0101 committed Nov 22, 2022
1 parent 2f456f8 commit 76f66a9
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 7 deletions.
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

0 comments on commit 76f66a9

Please sign in to comment.