func NewRecordClone(templateRecordUid string, records []*Record, newRecordUid string) (*Record, error) {
	templateRecord, err := findTemplateRecord(templateRecordUid, records)
	if err != nil {
		return nil, err
	}

	recordKeyBytes, _ := GetRandomBytes(32)
	folderKeyBytesCopy := make([]byte, len(templateRecord.folderKeyBytes))
	copy(folderKeyBytesCopy, templateRecord.folderKeyBytes)
	recordDictCopy := CopyableMap(templateRecord.RecordDict).DeepCopy()

	filesCopy := []*KeeperFile{}
	for _, f := range templateRecord.Files {
		filesCopy = append(filesCopy, f.DeepCopy())
	}

	recordUid := GenerateUid()
	if ruid := strings.TrimSpace(newRecordUid); ruid != "" {
		if numBytes := len(Base64ToBytes(ruid)); numBytes == 16 {
			recordUid = newRecordUid
		}
	}
	if newRecordUid != "" && recordUid != newRecordUid {
		klog.Warning("invalid new record UID provided:", newRecordUid, " - using autogenerated UID:", recordUid)
	}

	rec := &Record{
		RecordKeyBytes: recordKeyBytes,
		Uid:            recordUid,
		folderKeyBytes: folderKeyBytesCopy,
		folderUid:      templateRecord.folderUid,
		Files:          filesCopy,
		Revision:       templateRecord.Revision,
		IsEditable:     templateRecord.IsEditable,
		recordType:     templateRecord.recordType,
		RawJson:        templateRecord.RawJson,
		RecordDict:     recordDictCopy,
	}

	return rec, nil
}
// NewRecordClone returns a deep copy of the template object with new UID and RecordKeyBytes
// generates and uses new random UID if newRecordUid is empty
// returns error if template record is not found
NewRecordClone returns a deep copy of the template object with new UID and RecordKeyBytes
generates and uses new random UID if newRecordUid is empty
returns error if template record is not found
// NewRecordClone returns a deep copy of the template object with new UID and RecordKeyBytes // generates and uses new random UID if newRecordUid is empty // returns error if template record is not found
func NewRecordClone(templateRecordUid string, records []*Record, newRecordUid string) (*Record, error) {
	templateRecord, err := findTemplateRecord(templateRecordUid, records)
	if err != nil {
		return nil, err
	}
	recordKeyBytes, _ := GetRandomBytes(32)
	folderKeyBytesCopy := make([]byte, len(templateRecord.folderKeyBytes))
	copy(folderKeyBytesCopy, templateRecord.folderKeyBytes)
	recordDictCopy := CopyableMap(templateRecord.RecordDict).DeepCopy()
	filesCopy := []*KeeperFile{}
	for _, f := range templateRecord.Files {
		filesCopy = append(filesCopy, f.DeepCopy())
	}
	recordUid := GenerateUid()
	if ruid := strings.TrimSpace(newRecordUid); ruid != "" {
		if numBytes := len(Base64ToBytes(ruid)); numBytes == 16 {
			recordUid = newRecordUid
		}
	}
	if newRecordUid != "" && recordUid != newRecordUid {
		klog.Warning("invalid new record UID provided:", newRecordUid, " - using autogenerated UID:", recordUid)
	}
	rec := &Record{
		RecordKeyBytes: recordKeyBytes,
		Uid:            recordUid,
		folderKeyBytes: folderKeyBytesCopy,
		folderUid:      templateRecord.folderUid,
		Files:          filesCopy,
		Revision:       templateRecord.Revision,
		IsEditable:     templateRecord.IsEditable,
		recordType:     templateRecord.recordType,
		RawJson:        templateRecord.RawJson,
		RecordDict:     recordDictCopy,
	}
	return rec, nil
}
func NewRecordClone ( templateRecordUid string , records [ ] * Record , newRecordUid string ) ( * Record , error ) { templateRecord , err := findTemplateRecord ( templateRecordUid , records ) if err != nil { return nil , err } recordKeyBytes , _ := GetRandomBytes ( 32 ) folderKeyBytesCopy := make ( [ ] byte , len ( templateRecord . folderKeyBytes ) ) copy ( folderKeyBytesCopy , templateRecord . folderKeyBytes ) recordDictCopy := CopyableMap ( templateRecord . RecordDict ) . DeepCopy ( ) filesCopy := [ ] * KeeperFile { } for _ , f := range templateRecord . Files { filesCopy = append ( filesCopy , f . DeepCopy ( ) ) } recordUid := GenerateUid ( ) if ruid := strings . TrimSpace ( newRecordUid ) ; ruid != " " { if numBytes := len ( Base64ToBytes ( ruid ) ) ; numBytes == 16 { recordUid = newRecordUid } } if newRecordUid != " " && recordUid != newRecordUid { klog . Warning ( " " , newRecordUid , " " , recordUid ) } rec := & Record { RecordKeyBytes : recordKeyBytes , Uid : recordUid , folderKeyBytes : folderKeyBytesCopy , folderUid : templateRecord . folderUid , Files : filesCopy , Revision : templateRecord . Revision , IsEditable : templateRecord . IsEditable , recordType : templateRecord . recordType , RawJson : templateRecord . RawJson , RecordDict : recordDictCopy , } return rec , nil }
NewRecordClone returns a deep copy of the template object with new UID and RecordKeyBytes
generates and uses new random UID if newRecordUid is empty
returns error if template record is not found
NewRecordClone returns a deep copy of the template object with new UID and RecordKeyBytes generates and uses new random UID if newRecordUid is empty returns error if template record is not found