Skip to content

Commit

Permalink
Refactor datastore.GetSubject() to report not found errors. (Velocide…
Browse files Browse the repository at this point in the history
  • Loading branch information
scudette authored Mar 27, 2021
1 parent 31ded06 commit 614e732
Show file tree
Hide file tree
Showing 40 changed files with 577 additions and 865 deletions.
4 changes: 2 additions & 2 deletions .github/workflows/windows.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,10 @@ jobs:
name: Windows Test
runs-on: windows-latest
steps:
- name: Set up Go 1.14
- name: Set up Go 1.16
uses: actions/setup-go@v2
with:
go-version: 1.14
go-version: 1.16
id: go

- name: Check out code into the Go module directory
Expand Down
17 changes: 0 additions & 17 deletions api/api.go
Original file line number Diff line number Diff line change
Expand Up @@ -613,23 +613,6 @@ func (self *ApiServer) SetGUIOptions(
return &empty.Empty{}, users.SetUserOptions(self.config, user_info.Name, in)
}

func (self *ApiServer) GetUserNotifications(
ctx context.Context,
in *api_proto.GetUserNotificationsRequest) (
*api_proto.GetUserNotificationsResponse, error) {
result, err := users.GetUserNotifications(
self.config, GetGRPCUserInfo(self.config, ctx).Name, in.ClearPending)
return result, err
}

func (self *ApiServer) GetUserNotificationCount(
ctx context.Context,
in *empty.Empty) (*api_proto.UserNotificationCount, error) {
n, err := users.GetUserNotificationCount(
self.config, GetGRPCUserInfo(self.config, ctx).Name)
return &api_proto.UserNotificationCount{Count: n}, err
}

func (self *ApiServer) VFSListDirectory(
ctx context.Context,
in *flows_proto.VFSListRequest) (*flows_proto.VFSListResponse, error) {
Expand Down
7 changes: 3 additions & 4 deletions api/clients.go
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ package api

import (
"errors"
"io"
"io/fs"
"net"
"regexp"
"strings"
Expand Down Expand Up @@ -74,8 +74,7 @@ func GetApiClient(
result.Labels = services.GetLabeler().GetClientLabels(config_obj, client_id)

client_info := &actions_proto.ClientInfo{}
err = db.GetSubject(config_obj,
client_path_manager.Path(), client_info)
err = db.GetSubject(config_obj, client_path_manager.Path(), client_info)
if err != nil {
return nil, err
}
Expand Down Expand Up @@ -169,7 +168,7 @@ func (self *ApiServer) GetClientMetadata(

result := &api_proto.ClientMetadata{}
err = db.GetSubject(self.config, client_path_manager.Metadata(), result)
if err != nil && err == io.EOF {
if errors.Is(err, fs.ErrNotExist) {
// Metadata not set, start with empty set.
err = nil
}
Expand Down
3 changes: 2 additions & 1 deletion api/download.go
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ package api
import (
"archive/zip"
"io"
"io/fs"
"io/ioutil"
"net/http"
"net/url"
Expand Down Expand Up @@ -434,7 +435,7 @@ func vfsGetBuffer(
}

n, err := reader_at.ReadAt(result.Data, int64(offset))
if err != nil && errors.Cause(err) != io.EOF &&
if err != nil && errors.Is(err, fs.ErrNotExist) &&
errors.Cause(err) != io.ErrUnexpectedEOF {
return nil, err
}
Expand Down
8 changes: 4 additions & 4 deletions api/notebooks.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import (
"encoding/base64"
"encoding/binary"
"fmt"
"io"
"io/fs"
"path"
"strings"
"time"
Expand Down Expand Up @@ -78,7 +78,7 @@ func (self *ApiServer) GetNotebooks(

// Handle the EOF especially: it means there is no such
// notebook and return an empty result set.
if errors.Cause(err) == io.EOF {
if errors.Is(err, fs.ErrNotExist) || notebook.NotebookId == "" {
return result, nil
}
if err != nil {
Expand Down Expand Up @@ -443,12 +443,12 @@ func (self *ApiServer) GetNotebookCell(
notebook)

// Cell does not exist, make it a default cell.
if err == io.EOF {
if errors.Is(err, fs.ErrNotExist) {
return &api_proto.NotebookCell{
Input: "",
Output: "",
Data: "{}",
CellId: notebook.CellId,
CellId: in.CellId,
Type: "Markdown",
}, nil
}
Expand Down
782 changes: 379 additions & 403 deletions api/proto/api.pb.go

Large diffs are not rendered by default.

Loading

0 comments on commit 614e732

Please sign in to comment.