(c string)
| 82 | } |
| 83 | |
| 84 | func (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 | |
| 120 | func (cu *chunkUploader) setMd5() { |
| 121 | f, err := os.Open(cu.file) |
no test coverage detected