New Storage Refactor #404

Merged
sarah merged 33 commits from p2p-interim-new-storage into master 2021-11-25 23:56:51 +00:00
2 changed files with 3 additions and 12 deletions
Showing only changes of commit 781f4a919b - Show all commits

View File

@ -1,15 +1,14 @@
package app
import (
"crypto/rand"
"cwtch.im/cwtch/app/plugins"
"cwtch.im/cwtch/event"
"cwtch.im/cwtch/model"
"cwtch.im/cwtch/model/attr"
"cwtch.im/cwtch/model/constants"
"cwtch.im/cwtch/peer"
"cwtch.im/cwtch/protocol/connections"
"cwtch.im/cwtch/storage"
"encoding/hex"
"fmt"
"git.openprivacy.ca/openprivacy/connectivity"
"git.openprivacy.ca/openprivacy/log"
@ -85,18 +84,11 @@ func (ac *applicationCore) DeletePeer(onion string) {
delete(ac.eventBuses, onion)
}
// GenerateRandomID generates a random 16 byte hex id code
func GenerateRandomID() string {
randBytes := make([]byte, 16)
rand.Read(randBytes)
return path.Join(hex.EncodeToString(randBytes))
}
func (app *application) CreateTaggedPeer(name string, password string, tag string) {
app.appmutex.Lock()
defer app.appmutex.Unlock()
profileDirectory := path.Join(app.directory, "profiles", GenerateRandomID())
profileDirectory := path.Join(app.directory, "profiles", model.GenerateRandomID())
sarah marked this conversation as resolved
Review

uhhh

uhhh
profile, err := peer.CreateEncryptedStorePeer(profileDirectory, name, password)
if err != nil {

View File

@ -6,7 +6,6 @@ import (
"encoding/json"
"golang.org/x/crypto/ed25519"
"io"
"path/filepath"
"sync"
)
@ -67,7 +66,7 @@ func getRandomness(arr *[]byte) {
func GenerateRandomID() string {
randBytes := make([]byte, 16)
dan marked this conversation as resolved
Review

dup? it's also in app

dup? it's also in app
Review

GenerateRandomID is still dupped in model/profile and app/app

GenerateRandomID is still dupped in model/profile and app/app
rand.Read(randBytes)
return filepath.Join(hex.EncodeToString(randBytes))
return hex.EncodeToString(randBytes)
}
// GetCopy returns a full deep copy of the Profile struct and its members (timeline inclusion control by arg)