preliminary import working
This commit is contained in:
parent
8220d1817c
commit
db079664c9
43
doClean.go
43
doClean.go
|
@ -5,7 +5,9 @@ import (
|
|||
"path/filepath"
|
||||
"strings"
|
||||
|
||||
"go.wit.com/lib/protobuf/chatpb"
|
||||
"go.wit.com/log"
|
||||
"google.golang.org/protobuf/types/known/timestamppb"
|
||||
)
|
||||
|
||||
func doClean() {
|
||||
|
@ -74,14 +76,45 @@ func cleanGeminiFile(fullname string) error {
|
|||
return log.Errorf("not really gemini-api-request")
|
||||
}
|
||||
}
|
||||
// log.Info("PARSE FILE:", fullname)
|
||||
pb, err := parsePB(fullname)
|
||||
if err != nil {
|
||||
log.Info("parsePB() %s err %v\n", fullname, err)
|
||||
return log.Errorf("parsePB() %s err %v", fullname, err)
|
||||
}
|
||||
if pb == nil {
|
||||
log.Info("parsePB() == nil\n")
|
||||
return log.Errorf("parsePB() == nil")
|
||||
}
|
||||
uuid := parts[1]
|
||||
for _, chat := range me.chats.GetChats() {
|
||||
// log.Info(i, chat.Uuid)
|
||||
if chat.Uuid == uuid {
|
||||
log.Info("found uuid", uuid)
|
||||
if chat := me.chats.FindUuid(uuid); chat != nil {
|
||||
log.Info("found uuid in chat", uuid, pb.Model, chat.Uuid)
|
||||
statf, err := os.Stat(fullname)
|
||||
if err == nil {
|
||||
age := statf.ModTime()
|
||||
if chat.AddGeminiRequest(fname, age, pb) {
|
||||
me.chats.ConfigSave()
|
||||
okExit("")
|
||||
}
|
||||
}
|
||||
return nil
|
||||
}
|
||||
id := parts[3]
|
||||
if id == "1" {
|
||||
log.Info("Insert new chat here", fullname, id)
|
||||
statf, err := os.Stat(fullname)
|
||||
if err == nil {
|
||||
age := statf.ModTime()
|
||||
c := new(chatpb.Chat)
|
||||
c.Ctime = timestamppb.New(age)
|
||||
c.Uuid = uuid
|
||||
c.ChatName = "auto clean"
|
||||
log.Info("new chat:", c.Uuid, c.Ctime)
|
||||
me.chats.Append(c)
|
||||
me.chats.ConfigSave()
|
||||
okExit("")
|
||||
}
|
||||
log.Info("gemini JSON file uuid not found", uuid)
|
||||
}
|
||||
log.Info("gemini JSON file uuid not found", fullname, id)
|
||||
return log.Errorf("gemini JSON file uuid %s not found", uuid)
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue