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

Method SetFile

shock-server/node/fs.go:19–46  ·  view source on GitHub ↗
(file file.FormFile)

Source from the content-addressed store, hash-verified

17)
18
19func (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
48func (node *Node) SetFileFromSubset(subsetIndices file.FormFile) (err error) {
49 // load parent node

Callers 2

UpdateMethod · 0.95
CreateNodesFromArchiveFunction · 0.80

Calls 2

FilePathMethod · 0.95
StatMethod · 0.65

Tested by

no test coverage detected