diff --git a/apiclient/types/onedrive.go b/apiclient/types/onedrive.go index 838d24de6..aadf4fff7 100644 --- a/apiclient/types/onedrive.go +++ b/apiclient/types/onedrive.go @@ -7,7 +7,7 @@ type OneDriveLinks struct { SharedLinks []string `json:"sharedLinks,omitempty"` ThreadID string `json:"threadID,omitempty"` RunID string `json:"runID,omitempty"` - Status string `json:"output,omitempty"` + Status string `json:"status,omitempty"` Error string `json:"error,omitempty"` Folders FolderSet `json:"folders,omitempty"` } diff --git a/pkg/controller/handlers/uploads/onedrive.go b/pkg/controller/handlers/uploads/onedrive.go index 8ef43efe7..197d60f3b 100644 --- a/pkg/controller/handlers/uploads/onedrive.go +++ b/pkg/controller/handlers/uploads/onedrive.go @@ -6,6 +6,7 @@ import ( "errors" "fmt" "path/filepath" + "time" "github.com/acorn-io/baaah/pkg/apply" "github.com/acorn-io/baaah/pkg/router" @@ -202,9 +203,8 @@ func (u *UploadHandler) HandleUploadRun(req router.Request, resp router.Response var run v1.Run if err := req.Get(&run, oneDriveLinks.Namespace, oneDriveLinks.Status.RunName); apierrors.IsNotFound(err) { - // Might not be in the cache yet. return nil - } else if err != nil || !run.Status.State.IsTerminal() { + } else if err != nil { return err } @@ -213,6 +213,23 @@ func (u *UploadHandler) HandleUploadRun(req router.Request, resp router.Response return err } + if !run.Status.State.IsTerminal() { + file, err := u.workspaceClient.OpenFile(req.Ctx, thread.Spec.WorkspaceID, ".metadata.json") + if err != nil { + return err + } + defer file.Close() + + var output map[string]v1.OneDriveLinksConnectorStatus + if err = json.NewDecoder(file).Decode(&output); err != nil { + return err + } + oneDriveLinks.Status.Status = output["output"].Status + oneDriveLinks.Status.Error = output["output"].Error + resp.RetryAfter(5 * time.Second) + return nil + } + ws, err := knowledgeWorkspaceFromParent(req, oneDriveLinks) if err != nil { return err diff --git a/pkg/storage/apis/otto.gptscript.ai/v1/upload.go b/pkg/storage/apis/otto.gptscript.ai/v1/upload.go index 06d8a738b..3a7118ad0 100644 --- a/pkg/storage/apis/otto.gptscript.ai/v1/upload.go +++ b/pkg/storage/apis/otto.gptscript.ai/v1/upload.go @@ -47,14 +47,14 @@ type OnedriveLinksStatus struct { Conditions []metav1.Condition `json:"conditions,omitempty"` ThreadName string `json:"threadName,omitempty"` RunName string `json:"runName,omitempty"` - Status string `json:"output,omitempty"` + Status string `json:"status,omitempty"` Error string `json:"error,omitempty"` Folders types.FolderSet `json:"folders,omitempty"` LastReSyncStarted metav1.Time `json:"lastReSyncStarted,omitempty"` } type OneDriveLinksConnectorStatus struct { - Status string `json:"output,omitempty"` + Status string `json:"status,omitempty"` Error string `json:"error,omitempty"` Files map[string]types.FileDetails `json:"files,omitempty"` Folders types.FolderSet `json:"folders,omitempty"` diff --git a/pkg/storage/openapi/generated/openapi_generated.go b/pkg/storage/openapi/generated/openapi_generated.go index cbc7a34b4..f0dd0005e 100644 --- a/pkg/storage/openapi/generated/openapi_generated.go +++ b/pkg/storage/openapi/generated/openapi_generated.go @@ -900,7 +900,7 @@ func schema_gptscript_ai_otto_apiclient_types_OneDriveLinks(ref common.Reference Format: "", }, }, - "output": { + "status": { SchemaProps: spec.SchemaProps{ Type: []string{"string"}, Format: "", @@ -2440,7 +2440,7 @@ func schema_storage_apis_ottogptscriptai_v1_OneDriveLinksConnectorStatus(ref com SchemaProps: spec.SchemaProps{ Type: []string{"object"}, Properties: map[string]spec.Schema{ - "output": { + "status": { SchemaProps: spec.SchemaProps{ Type: []string{"string"}, Format: "", @@ -2605,7 +2605,7 @@ func schema_storage_apis_ottogptscriptai_v1_OnedriveLinksStatus(ref common.Refer Format: "", }, }, - "output": { + "status": { SchemaProps: spec.SchemaProps{ Type: []string{"string"}, Format: "", @@ -2617,6 +2617,12 @@ func schema_storage_apis_ottogptscriptai_v1_OnedriveLinksStatus(ref common.Refer Format: "", }, }, + "authUrl": { + SchemaProps: spec.SchemaProps{ + Type: []string{"string"}, + Format: "", + }, + }, "folders": { SchemaProps: spec.SchemaProps{ Type: []string{"object"},