Skip to content
This repository has been archived by the owner on May 15, 2024. It is now read-only.

Commit

Permalink
fix(lint): fix lint checks
Browse files Browse the repository at this point in the history
  • Loading branch information
hannahhoward committed Aug 17, 2023
1 parent ac70cf6 commit 131cb7f
Show file tree
Hide file tree
Showing 4 changed files with 22 additions and 134 deletions.
24 changes: 18 additions & 6 deletions blob/singularity_store.go
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,8 @@ import (
"github.com/data-preservation-programs/singularity/handler/datasource"
)

const MOTION_DATASET_NAME = "MOTION_DATASET"
const MAX_CAR_SIZE = "31.5GiB"
const motionDatasetName = "MOTION_DATASET"
const maxCarSize = "31.5GiB"

type SingularityStore struct {
local *LocalStore
Expand All @@ -34,23 +34,23 @@ func NewSingularityStore(dir string, singularityClient client.Client) *Singulari

func (l *SingularityStore) Start(ctx context.Context) error {
_, err := l.singularityClient.CreateDataset(ctx, dataset.CreateRequest{
Name: MOTION_DATASET_NAME,
MaxSizeStr: MAX_CAR_SIZE,
Name: motionDatasetName,
MaxSizeStr: maxCarSize,
})
var asDuplicatedRecord client.DuplicateRecordError

// return errors, but ignore duplicated record, that means we just already created it
if err != nil && !errors.As(err, &asDuplicatedRecord) {
return err
}
source, err := l.singularityClient.CreateLocalSource(ctx, MOTION_DATASET_NAME, datasource.LocalRequest{
source, err := l.singularityClient.CreateLocalSource(ctx, motionDatasetName, datasource.LocalRequest{
SourcePath: l.local.dir,
RescanInterval: "0",
DeleteAfterExport: false,
})
// handle source already created
if errors.As(err, &asDuplicatedRecord) {
sources, err := l.singularityClient.ListSourcesByDataset(ctx, MOTION_DATASET_NAME)
sources, err := l.singularityClient.ListSourcesByDataset(ctx, motionDatasetName)
if err != nil {
return err
}
Expand Down Expand Up @@ -104,6 +104,9 @@ func (s *SingularityStore) Get(ctx context.Context, id ID) (io.ReadSeekCloser, e
// this is largely artificial -- we're verifying the singularity item, but just reading from
// the local store
idStream, err := os.Open(path.Join(s.local.dir, id.String()+".id"))
if err != nil {
return nil, err
}
itemIDString, err := io.ReadAll(idStream)
if err != nil {
return nil, err
Expand All @@ -122,13 +125,19 @@ func (s *SingularityStore) Get(ctx context.Context, id ID) (io.ReadSeekCloser, e
}
var decoded ID
err = decoded.Decode(strings.TrimSuffix(path.Base(item.Path), path.Ext(item.Path)))
if err != nil {
return nil, err
}
return s.local.Get(ctx, decoded)
}

func (s *SingularityStore) Describe(ctx context.Context, id ID) (*Descriptor, error) {
// this is largely artificial -- we're verifying the singularity item, but just reading from
// the local store
idStream, err := os.Open(path.Join(s.local.dir, id.String()+".id"))
if err != nil {
return nil, err
}
itemIDString, err := io.ReadAll(idStream)
if err != nil {
return nil, err
Expand All @@ -147,5 +156,8 @@ func (s *SingularityStore) Describe(ctx context.Context, id ID) (*Descriptor, er
}
var decoded ID
err = decoded.Decode(strings.TrimSuffix(path.Base(item.Path), path.Ext(item.Path)))
if err != nil {
return nil, err
}
return s.local.Describe(ctx, decoded)
}
4 changes: 2 additions & 2 deletions cmd/motion/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ func main() {
DefaultText: "Local storage is used",
},
&cli.StringFlag{
Name: "remoteSingularityAPIUrl",
Name: "experimentalRemoteSingularityAPIUrl",
Usage: "when using a singularity as the storage engine, if set, uses a remote HTTP API to interface with Singularity",
DefaultText: "use singularity as a code library",
},
Expand Down Expand Up @@ -92,7 +92,7 @@ func main() {
}
store = rbstore
} else if cctx.Bool("experimentalSingularityStore") {
singularityAPIUrl := cctx.String("remoteSingularityAPIUrl")
singularityAPIUrl := cctx.String("experimentalRemoteSingularityAPIUrl")
var client client.Client
if singularityAPIUrl != "" {
client = httpclient.NewHTTPClient(http.DefaultClient, singularityAPIUrl)
Expand Down
25 changes: 2 additions & 23 deletions go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -15,9 +15,7 @@ require (
github.com/ipfs/go-log/v2 v2.5.1
github.com/lotus-web3/ribs v0.0.0-20230720185531-31964053b4be
github.com/multiformats/go-multihash v0.2.3
github.com/rclone/rclone v1.62.2
github.com/urfave/cli/v2 v2.25.7
gorm.io/gorm v1.25.2-0.20230530020048-26663ab9bf55
)

require (
Expand All @@ -34,7 +32,6 @@ require (
github.com/DataDog/zstd v1.4.5 // indirect
github.com/GeertJohan/go.incremental v1.0.0 // indirect
github.com/GeertJohan/go.rice v1.0.3 // indirect
github.com/KyleBanks/depth v1.2.1 // indirect
github.com/Max-Sum/base32768 v0.0.0-20230304063302-18e6ce5945fd // indirect
github.com/Microsoft/go-winio v0.5.2 // indirect
github.com/StackExchange/wmi v1.2.1 // indirect
Expand All @@ -43,7 +40,6 @@ require (
github.com/alecthomas/units v0.0.0-20211218093645-b94a6e3cc137 // indirect
github.com/avast/retry-go v3.0.0+incompatible // indirect
github.com/aws/aws-sdk-go v1.44.269 // indirect
github.com/bcicen/jstream v1.0.1 // indirect
github.com/benbjohnson/clock v1.3.5 // indirect
github.com/beorn7/perks v1.0.1 // indirect
github.com/bep/debounce v1.2.1 // indirect
Expand All @@ -64,14 +60,11 @@ require (
github.com/daaku/go.zipexe v1.0.2 // indirect
github.com/davecgh/go-spew v1.1.1 // indirect
github.com/davidlazar/go-crypto v0.0.0-20200604182044-b73af7476f6c // indirect
github.com/dchest/blake2b v1.0.0 // indirect
github.com/decred/dcrd/dcrec/secp256k1/v4 v4.2.0 // indirect
github.com/dgraph-io/badger/v2 v2.2007.4 // indirect
github.com/dgraph-io/ristretto v0.1.0 // indirect
github.com/dgryski/go-farm v0.0.0-20200201041132-a6ae2369ad13 // indirect
github.com/docker/go-units v0.5.0 // indirect
github.com/drand/kyber v1.1.15 // indirect
github.com/drand/kyber-bls12381 v0.2.3 // indirect
github.com/dropbox/dropbox-sdk-go-unofficial/v6 v6.0.5 // indirect
github.com/dustin/go-humanize v1.0.1 // indirect
github.com/elastic/gosigar v0.14.2 // indirect
Expand Down Expand Up @@ -120,10 +113,6 @@ require (
github.com/go-logr/logr v1.2.4 // indirect
github.com/go-logr/stdr v1.2.2 // indirect
github.com/go-ole/go-ole v1.2.6 // indirect
github.com/go-openapi/jsonpointer v0.19.6 // indirect
github.com/go-openapi/jsonreference v0.20.2 // indirect
github.com/go-openapi/spec v0.20.9 // indirect
github.com/go-openapi/swag v0.22.4 // indirect
github.com/go-sql-driver/mysql v1.7.0 // indirect
github.com/go-task/slim-sprig v0.0.0-20230315185526-52ccab3ef572 // indirect
github.com/godbus/dbus/v5 v5.1.0 // indirect
Expand Down Expand Up @@ -211,14 +200,10 @@ require (
github.com/jinzhu/now v1.1.5 // indirect
github.com/jlaffaye/ftp v0.1.1-0.20230214004652-d84bf4be2b6e // indirect
github.com/jmespath/go-jmespath v0.4.0 // indirect
github.com/joho/godotenv v1.5.1 // indirect
github.com/josharian/intern v1.0.0 // indirect
github.com/jpillora/backoff v1.0.0 // indirect
github.com/jsign/go-filsigner v0.4.1 // indirect
github.com/jtolio/eventkit v0.0.0-20221004135224-074cf276595b // indirect
github.com/jzelinskie/whirlpool v0.0.0-20201016144138-0675e54bb004 // indirect
github.com/kelseyhightower/envconfig v1.4.0 // indirect
github.com/kilic/bls12-381 v0.1.0 // indirect
github.com/klauspost/compress v1.16.5 // indirect
github.com/klauspost/cpuid/v2 v2.2.5 // indirect
github.com/koofr/go-httpclient v0.0.0-20230225102643-5d51a2e9dea6 // indirect
Expand Down Expand Up @@ -247,10 +232,8 @@ require (
github.com/libp2p/go-yamux/v4 v4.0.0 // indirect
github.com/lufia/plan9stats v0.0.0-20211012122336-39d0f177ccd0 // indirect
github.com/magefile/mage v1.9.0 // indirect
github.com/mailru/easyjson v0.7.7 // indirect
github.com/marten-seemann/tcp v0.0.0-20210406111302-dfbc87cc63fd // indirect
github.com/mattn/go-colorable v0.1.13 // indirect
github.com/mattn/go-shellwords v1.0.12 // indirect
github.com/mattn/go-sqlite3 v1.14.17 // indirect
github.com/matttproud/golang_protobuf_extensions v1.0.4 // indirect
github.com/microsoft/go-mssqldb v0.21.0 // indirect
Expand All @@ -260,7 +243,6 @@ require (
github.com/minio/blake2b-simd v0.0.0-20160723061019-3f5f724cb5b1 // indirect
github.com/minio/sha256-simd v1.0.1 // indirect
github.com/mitchellh/go-homedir v1.1.0 // indirect
github.com/mitchellh/mapstructure v1.5.0 // indirect
github.com/mr-tron/base58 v1.2.0 // indirect
github.com/multiformats/go-base32 v0.1.0 // indirect
github.com/multiformats/go-base36 v0.2.0 // indirect
Expand Down Expand Up @@ -300,11 +282,10 @@ require (
github.com/quic-go/webtransport-go v0.5.3 // indirect
github.com/raulk/clock v1.1.0 // indirect
github.com/raulk/go-watchdog v1.3.0 // indirect
github.com/rclone/rclone v1.62.2 // indirect
github.com/remyoudompheng/bigfft v0.0.0-20230129092748-24d4a6f8daec // indirect
github.com/rfjakob/eme v1.1.2 // indirect
github.com/rjNemo/underscore v0.5.0 // indirect
github.com/robfig/cron/v3 v3.0.1 // indirect
github.com/rodaine/table v1.1.0 // indirect
github.com/rogpeppe/go-internal v1.9.0 // indirect
github.com/rs/cors v1.7.0 // indirect
github.com/shirou/gopsutil/v3 v3.23.3 // indirect
Expand All @@ -315,9 +296,6 @@ require (
github.com/spacemonkeygo/monkit/v3 v3.0.19 // indirect
github.com/spaolacci/murmur3 v1.1.0 // indirect
github.com/spf13/pflag v1.0.5 // indirect
github.com/swaggo/echo-swagger v1.4.0 // indirect
github.com/swaggo/files/v2 v2.0.0 // indirect
github.com/swaggo/swag v1.16.1 // indirect
github.com/t3rm1n4l/go-mega v0.0.0-20230228171823-a01a2cda13ca // indirect
github.com/tklauser/go-sysconf v0.3.11 // indirect
github.com/tklauser/numcpus v0.6.0 // indirect
Expand Down Expand Up @@ -358,6 +336,7 @@ require (
gorm.io/driver/postgres v1.5.0 // indirect
gorm.io/driver/sqlite v1.5.2 // indirect
gorm.io/driver/sqlserver v1.4.3 // indirect
gorm.io/gorm v1.25.2-0.20230530020048-26663ab9bf55 // indirect
lukechampine.com/blake3 v1.2.1 // indirect
modernc.org/libc v1.22.3 // indirect
modernc.org/mathutil v1.5.0 // indirect
Expand Down
Loading

0 comments on commit 131cb7f

Please sign in to comment.