Skip to content

Commit

Permalink
style: shorten name operations to op
Browse files Browse the repository at this point in the history
  • Loading branch information
xhofe committed Aug 31, 2022
1 parent 9ec6d5b commit 7ac1d14
Show file tree
Hide file tree
Showing 35 changed files with 110 additions and 110 deletions.
4 changes: 2 additions & 2 deletions cmd/lang.go
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ import (
_ "github.com/alist-org/alist/v3/drivers"
"github.com/alist-org/alist/v3/internal/bootstrap/data"
"github.com/alist-org/alist/v3/internal/conf"
"github.com/alist-org/alist/v3/internal/operations"
"github.com/alist-org/alist/v3/internal/op"
"github.com/alist-org/alist/v3/pkg/utils"
"github.com/spf13/cobra"
)
Expand All @@ -37,7 +37,7 @@ func convert(s string) string {
func generateDriversJson() {
drivers := make(Drivers)
drivers["drivers"] = make(KV[interface{}])
driverInfoMap := operations.GetDriverInfoMap()
driverInfoMap := op.GetDriverInfoMap()
for k, v := range driverInfoMap {
drivers["drivers"][k] = convert(k)
items := make(KV[interface{}])
Expand Down
2 changes: 1 addition & 1 deletion drivers/aliyundrive/driver.go
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ func (d *AliDrive) Init(ctx context.Context, storage model.Storage) error {
return err
}
// TODO login / refresh token
//operations.MustSaveDriverStorage(d)
//op.MustSaveDriverStorage(d)
err = d.refreshToken()
if err != nil {
return err
Expand Down
4 changes: 2 additions & 2 deletions drivers/aliyundrive/meta.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ package local

import (
"github.com/alist-org/alist/v3/internal/driver"
"github.com/alist-org/alist/v3/internal/operations"
"github.com/alist-org/alist/v3/internal/op"
)

type Addition struct {
Expand All @@ -23,5 +23,5 @@ func New() driver.Driver {
}

func init() {
operations.RegisterDriver(config, New)
op.RegisterDriver(config, New)
}
4 changes: 2 additions & 2 deletions drivers/aliyundrive/util.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import (
"net/http"

"github.com/alist-org/alist/v3/drivers/base"
"github.com/alist-org/alist/v3/internal/operations"
"github.com/alist-org/alist/v3/internal/op"
"github.com/alist-org/alist/v3/pkg/utils"
"github.com/go-resty/resty/v2"
)
Expand All @@ -30,7 +30,7 @@ func (d *AliDrive) refreshToken() error {
return fmt.Errorf("failed to refresh token: %s", e.Message)
}
d.RefreshToken, d.AccessToken = resp.RefreshToken, resp.AccessToken
operations.MustSaveDriverStorage(d)
op.MustSaveDriverStorage(d)
return nil
}

Expand Down
4 changes: 2 additions & 2 deletions drivers/local/driver.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ import (
"github.com/alist-org/alist/v3/internal/driver"
"github.com/alist-org/alist/v3/internal/errs"
"github.com/alist-org/alist/v3/internal/model"
"github.com/alist-org/alist/v3/internal/operations"
"github.com/alist-org/alist/v3/internal/op"
"github.com/alist-org/alist/v3/pkg/utils"
"github.com/alist-org/alist/v3/server/common"
"github.com/disintegration/imaging"
Expand Down Expand Up @@ -49,7 +49,7 @@ func (d *Local) Init(ctx context.Context, storage model.Storage) error {
}
}
}
operations.MustSaveDriverStorage(d)
op.MustSaveDriverStorage(d)
return err
}

Expand Down
4 changes: 2 additions & 2 deletions drivers/local/meta.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ package local

import (
"github.com/alist-org/alist/v3/internal/driver"
"github.com/alist-org/alist/v3/internal/operations"
"github.com/alist-org/alist/v3/internal/op"
)

type Addition struct {
Expand All @@ -23,5 +23,5 @@ func New() driver.Driver {
}

func init() {
operations.RegisterDriver(config, New)
op.RegisterDriver(config, New)
}
4 changes: 2 additions & 2 deletions drivers/onedrive/meta.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ package onedrive

import (
"github.com/alist-org/alist/v3/internal/driver"
"github.com/alist-org/alist/v3/internal/operations"
"github.com/alist-org/alist/v3/internal/op"
)

type Addition struct {
Expand All @@ -27,5 +27,5 @@ func New() driver.Driver {
}

func init() {
operations.RegisterDriver(config, New)
op.RegisterDriver(config, New)
}
4 changes: 2 additions & 2 deletions drivers/onedrive/util.go
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ import (
"github.com/alist-org/alist/v3/internal/driver"
"github.com/alist-org/alist/v3/internal/errs"
"github.com/alist-org/alist/v3/internal/model"
"github.com/alist-org/alist/v3/internal/operations"
"github.com/alist-org/alist/v3/internal/op"
"github.com/alist-org/alist/v3/pkg/utils"
"github.com/go-resty/resty/v2"
jsoniter "github.com/json-iterator/go"
Expand Down Expand Up @@ -92,7 +92,7 @@ func (d *Onedrive) _refreshToken() error {
return errs.EmptyToken
}
d.RefreshToken, d.AccessToken = resp.RefreshToken, resp.AccessToken
operations.MustSaveDriverStorage(d)
op.MustSaveDriverStorage(d)
return nil
}

Expand Down
4 changes: 2 additions & 2 deletions drivers/pikpak/meta.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ package local

import (
"github.com/alist-org/alist/v3/internal/driver"
"github.com/alist-org/alist/v3/internal/operations"
"github.com/alist-org/alist/v3/internal/op"
)

type Addition struct {
Expand All @@ -22,5 +22,5 @@ func New() driver.Driver {
}

func init() {
operations.RegisterDriver(config, New)
op.RegisterDriver(config, New)
}
8 changes: 4 additions & 4 deletions drivers/pikpak/util.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import (
"net/http"

"github.com/alist-org/alist/v3/drivers/base"
"github.com/alist-org/alist/v3/internal/operations"
"github.com/alist-org/alist/v3/internal/op"
"github.com/go-resty/resty/v2"
jsoniter "github.com/json-iterator/go"
)
Expand Down Expand Up @@ -46,7 +46,7 @@ func (d *PikPak) refreshToken() error {
}).Post(url)
if err != nil {
d.Status = err.Error()
operations.MustSaveDriverStorage(d)
op.MustSaveDriverStorage(d)
return err
}
if e.ErrorCode != 0 {
Expand All @@ -55,14 +55,14 @@ func (d *PikPak) refreshToken() error {
return d.login()
}
d.Status = e.Error
operations.MustSaveDriverStorage(d)
op.MustSaveDriverStorage(d)
return errors.New(e.Error)
}
data := res.Body()
d.Status = "work"
d.RefreshToken = jsoniter.Get(data, "refresh_token").ToString()
d.AccessToken = jsoniter.Get(data, "access_token").ToString()
operations.MustSaveDriverStorage(d)
op.MustSaveDriverStorage(d)
return nil
}

Expand Down
2 changes: 1 addition & 1 deletion drivers/template/driver.go
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ func (d *Template) Init(ctx context.Context, storage model.Storage) error {
return err
}
// TODO login / refresh token
//operations.MustSaveDriverStorage(d)
//op.MustSaveDriverStorage(d)
return err
}

Expand Down
4 changes: 2 additions & 2 deletions drivers/template/meta.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ package local

import (
"github.com/alist-org/alist/v3/internal/driver"
"github.com/alist-org/alist/v3/internal/operations"
"github.com/alist-org/alist/v3/internal/op"
)

type Addition struct {
Expand All @@ -29,5 +29,5 @@ func New() driver.Driver {
}

func init() {
operations.RegisterDriver(config, New)
op.RegisterDriver(config, New)
}
4 changes: 2 additions & 2 deletions drivers/virtual/meta.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ package virtual

import (
"github.com/alist-org/alist/v3/internal/driver"
"github.com/alist-org/alist/v3/internal/operations"
"github.com/alist-org/alist/v3/internal/op"
)

type Addition struct {
Expand All @@ -26,5 +26,5 @@ func New() driver.Driver {
}

func init() {
operations.RegisterDriver(config, New)
op.RegisterDriver(config, New)
}
6 changes: 3 additions & 3 deletions internal/aria2/add.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,15 +7,15 @@ import (

"github.com/alist-org/alist/v3/internal/conf"
"github.com/alist-org/alist/v3/internal/errs"
"github.com/alist-org/alist/v3/internal/operations"
"github.com/alist-org/alist/v3/internal/op"
"github.com/alist-org/alist/v3/pkg/task"
"github.com/google/uuid"
"github.com/pkg/errors"
)

func AddURI(ctx context.Context, uri string, dstDirPath string) error {
// check storage
storage, dstDirActualPath, err := operations.GetStorageAndActualPath(dstDirPath)
storage, dstDirActualPath, err := op.GetStorageAndActualPath(dstDirPath)
if err != nil {
return errors.WithMessage(err, "failed get storage")
}
Expand All @@ -24,7 +24,7 @@ func AddURI(ctx context.Context, uri string, dstDirPath string) error {
return errors.WithStack(errs.UploadNotSupported)
}
// check path is valid
obj, err := operations.Get(ctx, storage, dstDirActualPath)
obj, err := op.Get(ctx, storage, dstDirActualPath)
if err != nil {
if !errs.IsObjectNotFound(err) {
return errors.WithMessage(err, "failed get object")
Expand Down
4 changes: 2 additions & 2 deletions internal/aria2/aria2_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ import (
conf2 "github.com/alist-org/alist/v3/internal/conf"
"github.com/alist-org/alist/v3/internal/db"
"github.com/alist-org/alist/v3/internal/model"
"github.com/alist-org/alist/v3/internal/operations"
"github.com/alist-org/alist/v3/internal/op"
"github.com/alist-org/alist/v3/pkg/task"
"gorm.io/driver/sqlite"
"gorm.io/gorm"
Expand Down Expand Up @@ -39,7 +39,7 @@ func TestConnect(t *testing.T) {

func TestDown(t *testing.T) {
TestConnect(t)
err := operations.CreateStorage(context.Background(), model.Storage{
err := op.CreateStorage(context.Background(), model.Storage{
ID: 0,
MountPath: "/",
Index: 0,
Expand Down
6 changes: 3 additions & 3 deletions internal/aria2/monitor.go
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ import (
"time"

"github.com/alist-org/alist/v3/internal/model"
"github.com/alist-org/alist/v3/internal/operations"
"github.com/alist-org/alist/v3/internal/op"
"github.com/alist-org/alist/v3/pkg/task"
"github.com/pkg/errors"
log "github.com/sirupsen/logrus"
Expand Down Expand Up @@ -114,7 +114,7 @@ var TransferTaskManager = task.NewTaskManager(3, func(k *uint64) {

func (m *Monitor) Complete() error {
// check dstDir again
storage, dstDirActualPath, err := operations.GetStorageAndActualPath(m.dstDirPath)
storage, dstDirActualPath, err := op.GetStorageAndActualPath(m.dstDirPath)
if err != nil {
return errors.WithMessage(err, "failed get storage")
}
Expand Down Expand Up @@ -158,7 +158,7 @@ func (m *Monitor) Complete() error {
ReadCloser: f,
Mimetype: mimetype,
}
return operations.Put(tsk.Ctx, storage, dstDirActualPath, stream, tsk.SetProgress)
return op.Put(tsk.Ctx, storage, dstDirActualPath, stream, tsk.SetProgress)
},
}))
}
Expand Down
4 changes: 2 additions & 2 deletions internal/bootstrap/data/dev.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,12 +7,12 @@ import (
"github.com/alist-org/alist/v3/internal/db"
"github.com/alist-org/alist/v3/internal/message"
"github.com/alist-org/alist/v3/internal/model"
"github.com/alist-org/alist/v3/internal/operations"
"github.com/alist-org/alist/v3/internal/op"
log "github.com/sirupsen/logrus"
)

func initDevData() {
err := operations.CreateStorage(context.Background(), model.Storage{
err := op.CreateStorage(context.Background(), model.Storage{
MountPath: "/",
Index: 0,
Driver: "local",
Expand Down
4 changes: 2 additions & 2 deletions internal/bootstrap/storage.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import (
"github.com/alist-org/alist/v3/internal/conf"
"github.com/alist-org/alist/v3/internal/db"
"github.com/alist-org/alist/v3/internal/model"
"github.com/alist-org/alist/v3/internal/operations"
"github.com/alist-org/alist/v3/internal/op"
"github.com/alist-org/alist/v3/pkg/utils"
)

Expand All @@ -17,7 +17,7 @@ func LoadStorages() {
}
go func(storages []model.Storage) {
for i := range storages {
err := operations.LoadStorage(context.Background(), storages[i])
err := op.LoadStorage(context.Background(), storages[i])
if err != nil {
utils.Log.Errorf("failed get enabled storages: %+v", err)
} else {
Expand Down
4 changes: 2 additions & 2 deletions internal/db/storage.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,8 @@ import (
)

// why don't need `cache` for storage?
// because all storage store in `operations.storagesMap`
// the most of the read operation is from `operations.storagesMap`
// because all storage store in `op.storagesMap`
// the most of the read operation is from `op.storagesMap`
// just for persistence in database

// CreateStorage just insert storage to database
Expand Down
Loading

0 comments on commit 7ac1d14

Please sign in to comment.