mirror of
https://github.com/PeernetOfficial/core.git
synced 2026-07-17 02:47:51 +01:00
New features (#110)
* added upload status * added changes for progress bar with more logs and bug fixes, Documentation yet to be added * huge changes that need more doucmenting * added possibility to get profile using NodeID * added fix profile listing user profile information * removed profile image from the explore reult struct * saving current changes * added filter to search based on NodeID * Monday bug fixing * updates to the profile * changes for tracing the blockchain profile image not shown * added condition to ensure TAG is not sent and removed debug prints * updated webapi docs
This commit is contained in:
committed by
GitHub
parent
97c3001596
commit
ae5f1d2fd7
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
File Name: Store.go
|
||||
File Username: Store.go
|
||||
Copyright: 2021 Peernet Foundation s.r.o.
|
||||
Author: Peter Kleissner
|
||||
*/
|
||||
@@ -38,7 +38,7 @@ const (
|
||||
|
||||
// CreateFile creates a new file in the warehouse
|
||||
// If fileSize is provided, creating the merkle tree is significantly faster as it will be created on the fly. If the file size is unknown, set the size to 0.
|
||||
func (wh *Warehouse) CreateFile(data io.Reader, fileSize uint64) (hash []byte, status int, err error) {
|
||||
func (wh *Warehouse) CreateFile(data io.Reader, fileSize uint64, uploadStatus io.Writer) (hash []byte, status int, err error) {
|
||||
// create a temporary file to hold the body content
|
||||
tmpFile, err := wh.tempFile()
|
||||
if err != nil {
|
||||
@@ -55,8 +55,14 @@ func (wh *Warehouse) CreateFile(data io.Reader, fileSize uint64) (hash []byte, s
|
||||
// create the hash-writer
|
||||
hashWriter := blake3.New(hashSize, nil)
|
||||
|
||||
// the multi-writer writes to the temp-file and the hash simultaneously
|
||||
mw := io.MultiWriter(tmpFile, hashWriter)
|
||||
var mw io.Writer
|
||||
|
||||
if uploadStatus != nil {
|
||||
// the multi-writer writes to the temp-file and the hash simultaneously
|
||||
mw = io.MultiWriter(tmpFile, hashWriter, uploadStatus)
|
||||
} else {
|
||||
mw = io.MultiWriter(tmpFile, hashWriter)
|
||||
}
|
||||
|
||||
// copy into the multiwriter
|
||||
if _, err = io.Copy(mw, data); err != nil {
|
||||
@@ -132,7 +138,7 @@ func (wh *Warehouse) CreateFileFromPath(file string) (hash []byte, status int, e
|
||||
}
|
||||
|
||||
// create the file using the opened file
|
||||
return wh.CreateFile(fileHandle, fileSize)
|
||||
return wh.CreateFile(fileHandle, fileSize, nil)
|
||||
}
|
||||
|
||||
// ReadFile reads a file from the warehouse and outputs it to the writer
|
||||
|
||||
Reference in New Issue
Block a user