Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .github/workflows/build.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ jobs:
with:
go-version: 1.21
- name: Lint
uses: golangci/golangci-lint-action@v3
uses: golangci/golangci-lint-action@v6
with:
version: latest
build:
Expand Down
2 changes: 1 addition & 1 deletion .golangci.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ linters:
- dogsled
- errname
- errorlint
- exportloopref
- copyloopvar
- forcetypeassert
- gocognit
- goconst
Expand Down
6 changes: 4 additions & 2 deletions deprecated/v1/sifi/sifi.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,10 @@ import (
)

const (
PortNumber = 7434 // PortNumber is the default port for `sifid` (sifi on a keypad).
ServiceName = "sifid" // ServiceName is the public name of the SIFI service.
// PortNumber is the default port for `sifid` (sifi on a keypad).
PortNumber = 7434
// ServiceName is the public name of the SIFI service.
ServiceName = "sifid"
)

// path returns a URL path with the correct prefix appended.
Expand Down
12 changes: 8 additions & 4 deletions manifold/manifold.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,12 @@
package manifold

const (
APIPrefix = "/manifold-api" // APIPrefix is the prefix for all API paths.
APIVersion = "v3-preview" // APIVersion is the prefix for all API paths (without the leading slash).
PortNumber = 7434 // PortNumber is the default port for `sifid` (sifi on a keypad).
ServiceName = "sifid" // ServiceName is the public name of the manifold-api service.
// APIPrefix is the prefix for all API paths.
APIPrefix = "/manifold-api"
// APIVersion is the prefix for all API paths (without the leading slash).
APIVersion = "v3-preview"
// PortNumber is the default port for `sifid` (sifi on a keypad).
PortNumber = 7434
// ServiceName is the public name of the manifold-api service.
ServiceName = "sifid"
)
7 changes: 6 additions & 1 deletion metal/responses.go
Original file line number Diff line number Diff line change
Expand Up @@ -212,7 +212,12 @@ type NetInterfaceInfo struct {
MAC string `json:"mac"` // The network's MAC address
MTU uint16 `json:"mtu"` // The network's maximum transmission unit
LinkSpeedMbs uint `json:"link_speed_Mbs"`
Link bool `json:"link"`
Link bool `json:"link"` // true when the link status is up
VendorID string `json:"vendor_id"` // the link device Vendor ID (from e.g PCI info)
DeviceID string `json:"device_id"` // the link device ID (from e.g PCI info)
Vendor string `json:"vendor"` // the link device vendor (name)
Device string `json:"device"` // the link device (name)
BusInfo string `json:"bus_info"` // the link bus info/address (from e.g PCI info)
}

// BcacheInfo is the information we can get for a single bcache device.
Expand Down
18 changes: 16 additions & 2 deletions upload/service.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ import (
"errors"
"fmt"
"io"
"math"
"net/http"
"os"
"path/filepath"
Expand Down Expand Up @@ -106,7 +107,11 @@ func (s Service) Upload(ctx context.Context, path string) (*UploadResponse, erro
}

upload.Offset = status.Offset
upload.Completed = int64(status.Offset) == stat.Size()
size := stat.Size()
if size < 0 {
return nil, errors.New("invalid stat.Size()")
}
upload.Completed = (status.Offset == uint64(size))

return &upload, nil
}
Expand All @@ -130,15 +135,24 @@ func (s Service) Resume(ctx context.Context, id, path string) (*ResumeResponse,
}
defer fin.Close()

if status.Offset > math.MaxInt64 {
return nil, errors.New("offset too large")
}

status, err = s.upload(ctx, id, int64(status.Offset), fin)
if err != nil {
return nil, err
}

size := stat.Size()
if size < 0 {
return nil, errors.New("invalid stat.Size()")
}

resume := ResumeResponse{
Version: status.Version,
Offset: status.Offset,
Completed: int64(status.Offset) == stat.Size(),
Completed: status.Offset == uint64(size),
}

return &resume, nil
Expand Down