MCPcopy
hub / github.com/NVIDIA/aistore / SaveReaderSafe

Function SaveReaderSafe

cmn/cos/io.go:527–537  ·  view source on GitHub ↗

same as above, plus rename

(tmpfqn, fqn string, reader io.Reader, buf []byte, cksumType string,
	size int64, dirMustExist string)

Source from the content-addressed store, hash-verified

525
526// same as above, plus rename
527func SaveReaderSafe(tmpfqn, fqn string, reader io.Reader, buf []byte, cksumType string,
528 size int64, dirMustExist string) (cksum *CksumHash, err error) {
529 if cksum, err = SaveReader(tmpfqn, reader, buf, cksumType, size, dirMustExist); err != nil {
530 return nil, err
531 }
532 if err := Rename(tmpfqn, fqn); err != nil {
533 os.Remove(tmpfqn)
534 return nil, err
535 }
536 return cksum, nil
537}
538
539// Read only the first line of a file.
540// Do not use for big files: it reads all the content and then extracts the first

Callers 1

WriteMethod · 0.92

Calls 3

SaveReaderFunction · 0.85
RenameFunction · 0.85
RemoveMethod · 0.45

Tested by

no test coverage detected