| 24 | } |
| 25 | |
| 26 | func (node *Node) initParts(partsCount string, compressionFormat string) (err error) { |
| 27 | // Function should only be called with a postive integer or string 'unknown' |
| 28 | count, cerr := strconv.Atoi(partsCount) |
| 29 | if partsCount != "unknown" && cerr != nil { |
| 30 | return cerr |
| 31 | } |
| 32 | if err = os.MkdirAll(fmt.Sprintf("%s/parts", node.Path()), 0777); err != nil { |
| 33 | return err |
| 34 | } |
| 35 | |
| 36 | varlen := false |
| 37 | if partsCount == "unknown" { |
| 38 | count = 0 |
| 39 | varlen = true |
| 40 | } |
| 41 | |
| 42 | node.Type = "parts" |
| 43 | node.Parts = &PartsList{ |
| 44 | Count: count, |
| 45 | Length: 0, |
| 46 | VarLen: varlen, |
| 47 | Parts: make([]partsFile, count), |
| 48 | Compression: compressionFormat, |
| 49 | } |
| 50 | |
| 51 | return |
| 52 | } |
| 53 | |
| 54 | func (node *Node) addVirtualParts(ids []string) (err error) { |
| 55 | nodes := Nodes{} |