MCPcopy Create free account
hub / github.com/MG-RAST/Shock / setSizes

Method setSizes

shock-client/chunk.go:84–118  ·  view source on GitHub ↗
(c string)

Source from the content-addressed store, hash-verified

82}
83
84func (cu *chunkUploader) setSizes(c string) {
85 fi, err := os.Stat(cu.file)
86 if err != nil {
87 exitError(err.Error())
88 }
89 matched := chunkRegex.FindStringSubmatch(c)
90 if len(matched) == 0 {
91 exitError("chunk format is invalid")
92 }
93
94 chunkBytes, _ := strconv.ParseInt(matched[1], 10, 64)
95 switch matched[2] {
96 case "K":
97 chunkBytes = chunkBytes * 1024
98 case "M":
99 chunkBytes = chunkBytes * 1024 * 1024
100 case "G":
101 chunkBytes = chunkBytes * 1024 * 1024 * 1024
102 }
103
104 quotient := fi.Size() / chunkBytes
105 remainder := fi.Size() % chunkBytes
106 if quotient > 100 {
107 exitError("too many part uploads created, please specify a larger chunk size")
108 }
109
110 var calcParts int
111 if remainder == 0 {
112 calcParts = int(quotient)
113 } else {
114 calcParts = int(quotient + 1)
115 }
116 cu.parts = calcParts
117 cu.chunk = chunkBytes
118}
119
120func (cu *chunkUploader) setMd5() {
121 f, err := os.Open(cu.file)

Callers 1

newChunkUploaderFunction · 0.80

Calls 3

exitErrorFunction · 0.85
StatMethod · 0.65
ErrorMethod · 0.45

Tested by

no test coverage detected