mirror of
https://github.com/wavetermdev/backup.git
synced 2026-08-05 13:57:07 -07:00
redo ptybuffer, move to wshutil to help with stdin processing. change wsh to use cobra
This commit is contained in:
@@ -7,6 +7,7 @@ import (
|
||||
"context"
|
||||
"fmt"
|
||||
"log"
|
||||
"reflect"
|
||||
"time"
|
||||
|
||||
"github.com/wavetermdev/thenextwave/pkg/filestore"
|
||||
@@ -157,6 +158,28 @@ func DBSelectORefs(ctx context.Context, orefs []waveobj.ORef) ([]waveobj.WaveObj
|
||||
})
|
||||
}
|
||||
|
||||
func DBResolveEasyOID(ctx context.Context, oid string) (*waveobj.ORef, error) {
|
||||
return WithTxRtn(ctx, func(tx *TxWrap) (*waveobj.ORef, error) {
|
||||
for _, rtype := range AllWaveObjTypes() {
|
||||
otype := reflect.Zero(rtype).Interface().(waveobj.WaveObj).GetOType()
|
||||
table := tableNameFromOType(otype)
|
||||
var fullOID string
|
||||
if len(oid) == 8 {
|
||||
query := fmt.Sprintf("SELECT oid FROM %s WHERE oid LIKE ?", table)
|
||||
fullOID = tx.GetString(query, oid+"%")
|
||||
} else {
|
||||
query := fmt.Sprintf("SELECT oid FROM %s WHERE oid = ?", table)
|
||||
fullOID = tx.GetString(query, oid)
|
||||
}
|
||||
if fullOID != "" {
|
||||
oref := waveobj.MakeORef(otype, fullOID)
|
||||
return &oref, nil
|
||||
}
|
||||
}
|
||||
return nil, ErrNotFound
|
||||
})
|
||||
}
|
||||
|
||||
func DBSelectMap[T waveobj.WaveObj](ctx context.Context, ids []string) (map[string]T, error) {
|
||||
rtnArr, err := dbSelectOIDs(ctx, getOTypeGen[T](), ids)
|
||||
if err != nil {
|
||||
|
||||
Reference in New Issue
Block a user