(file file.FormFile)
| 17 | ) |
| 18 | |
| 19 | func (node *Node) SetFile(file file.FormFile) (err error) { |
| 20 | fileStat, err := os.Stat(file.Path) |
| 21 | if err != nil { |
| 22 | return |
| 23 | } |
| 24 | |
| 25 | os.Rename(file.Path, node.FilePath()) |
| 26 | node.File.Name = file.Name |
| 27 | node.File.Size = fileStat.Size() |
| 28 | node.File.Checksum = file.Checksum |
| 29 | node.File.CreatedOn = fileStat.ModTime() |
| 30 | |
| 31 | //fill size index info |
| 32 | totalunits := node.File.Size / conf.CHUNK_SIZE |
| 33 | m := node.File.Size % conf.CHUNK_SIZE |
| 34 | if m != 0 { |
| 35 | totalunits += 1 |
| 36 | } |
| 37 | node.Indexes["size"] = &IdxInfo{ |
| 38 | Type: "size", |
| 39 | TotalUnits: totalunits, |
| 40 | AvgUnitSize: conf.CHUNK_SIZE, |
| 41 | Format: "dynamic", |
| 42 | CreatedOn: time.Now(), |
| 43 | } |
| 44 | |
| 45 | return |
| 46 | } |
| 47 | |
| 48 | func (node *Node) SetFileFromSubset(subsetIndices file.FormFile) (err error) { |
| 49 | // load parent node |
no test coverage detected