Skip to content

Commit 880a567

Browse files
author
yang.zhao
committed
add deb file
1 parent 2bb7145 commit 880a567

File tree

3 files changed

+51
-27
lines changed

3 files changed

+51
-27
lines changed

.github/workflows/build.yml

Lines changed: 13 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -202,14 +202,24 @@ jobs:
202202
make compile_all
203203
if: matrix.compile_all
204204

205-
- name: Deploy built binaries
205+
- name: Build Packages
206206
run: |
207207
if [[ "${{ matrix.os }}" == "ubuntu-latest" ]]; then make release_dep_linux ; fi
208+
# Use compile_all or a similar flag to generate local packages
209+
VERSION=$(make version)
210+
# We only generate packages for linux in the linux job to save time
211+
if [[ "${{ matrix.job_name }}" == "linux" ]]; then
212+
go run bin/cross-compile.go -include "^linux/amd64$" $VERSION
213+
elif [[ "${{ matrix.job_name }}" == "linux_386" ]]; then
214+
go run bin/cross-compile.go -include "^linux/386$" $VERSION
215+
fi
216+
if: matrix.deploy && (matrix.job_name == 'linux' || matrix.job_name == 'linux_386')
217+
218+
- name: Deploy built binaries
219+
run: |
208220
make ci_beta
209221
env:
210222
RCLONE_CONFIG_PASS: ${{ secrets.RCLONE_CONFIG_PASS }}
211-
# working-directory: '$(modulePath)'
212-
# Deploy binaries if enabled in config && not a PR && not a fork
213223
if: env.RCLONE_CONFIG_PASS != '' && matrix.deploy && github.head_ref == ''
214224

215225
lint:

backend/baidu/baidu.go

Lines changed: 18 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -95,7 +95,7 @@ func Config(ctx context.Context, name string, m configmap.Mapper, c fs.ConfigIn)
9595
return nil, err
9696
}
9797

98-
fmt.Printf("请在浏览器中打开链接:%s ,并在打开的页面中输入:%s 获取授权。\n", auth.VerificationUrl, auth.UserCode)
98+
fmt.Printf("请在浏览器中打开链接:%s ,并在打开的页面中输入:%s 获取授权。\n", auth.VerificationURL, auth.UserCode)
9999

100100
for {
101101
token, err := getAccessToken(ctx, auth.DeviceCode, appKey, secretKey)
@@ -196,6 +196,7 @@ func (f *Fs) reWriteConfig() {
196196
}
197197
}
198198

199+
// Fs represents a remote Baidu server
199200
type Fs struct {
200201
name string
201202
ci *fs.ConfigInfo
@@ -299,7 +300,7 @@ func (f *Fs) Precision() time.Duration {
299300
return time.Second
300301
}
301302

302-
// Returns the supported hash types of the filesystem
303+
// Hashes returns the supported hash types of the filesystem
303304
func (f *Fs) Hashes() hash.Set {
304305
return hash.NewHashSet(hash.None)
305306
}
@@ -322,15 +323,15 @@ func (f *Fs) List(ctx context.Context, dir string) (entries fs.DirEntries, err e
322323
for _, info := range list {
323324
var item fs.DirEntry
324325
if info.IsDir == 1 {
325-
item = fs.NewDir(strings.TrimLeft(info.Path, "/"), time.Unix(int64(info.ServerMtime), 0)).SetID(strconv.FormatUint(info.FsId, 10))
326+
item = fs.NewDir(strings.TrimLeft(info.Path, "/"), time.Unix(info.ServerMtime, 0)).SetID(strconv.FormatUint(info.FsID, 10))
326327
} else {
327328
item = &Object{
328329
fs: f,
329330
remote: strings.TrimLeft(info.Path, "/"),
330331
path: info.Path,
331-
size: int64(info.Size),
332-
id: strconv.FormatUint(info.FsId, 10),
333-
modTime: time.Unix(int64(info.ServerMtime), 0),
332+
size: info.Size,
333+
id: strconv.FormatUint(info.FsID, 10),
334+
modTime: time.Unix(info.ServerMtime, 0),
334335
}
335336
}
336337
entries = append(entries, item)
@@ -598,6 +599,7 @@ func (f *Fs) About(ctx context.Context) (usage *fs.Usage, err error) {
598599
return usage, nil
599600
}
600601

602+
// Object describes a Baidu file
601603
type Object struct {
602604
fs *Fs // what this object is part of
603605
path string
@@ -656,7 +658,7 @@ func (o *Object) Storable() bool {
656658

657659
// Open an object for read
658660
func (o *Object) Open(ctx context.Context, options ...fs.OpenOption) (in io.ReadCloser, err error) {
659-
downloadURL, err := o.fileDownloadUrl(ctx)
661+
downloadURL, err := o.fileDownloadURL(ctx)
660662
if err != nil {
661663
return nil, err
662664
}
@@ -678,7 +680,7 @@ func (o *Object) download(ctx context.Context, downloadURL string, options ...fs
678680
return resp.Body, err
679681
}
680682

681-
func (o *Object) fileDownloadUrl(ctx context.Context) (string, error) {
683+
func (o *Object) fileDownloadURL(ctx context.Context) (string, error) {
682684
opts := &rest.Opts{
683685
Method: "POST",
684686
RootURL: rootURL,
@@ -697,7 +699,7 @@ func (o *Object) fileDownloadUrl(ctx context.Context) (string, error) {
697699
if len(resp.List) == 0 {
698700
return "", errors.New("")
699701
}
700-
return resp.List[0].DLink, nil
702+
return resp.List[0].Dlink, nil
701703
}
702704

703705
// Update the object with the contents of the io.Reader, modTime and size
@@ -731,7 +733,7 @@ func (o *Object) upload(ctx context.Context, in io.Reader, size int64) error {
731733
// 2. 流式切片上传 (方案 A)
732734
var md5s []string
733735
buf := make([]byte, chunkSize)
734-
var uploaded int64 = 0
736+
var uploaded int64
735737

736738
for {
737739
n, err := io.ReadFull(in, buf)
@@ -761,7 +763,7 @@ func (o *Object) upload(ctx context.Context, in io.Reader, size int64) error {
761763
if err != nil {
762764
return fmt.Errorf("合并文件失败: %w", err)
763765
}
764-
o.id = strconv.FormatUint(file.FsId, 10)
766+
o.id = strconv.FormatUint(file.FsID, 10)
765767
o.path = file.Path
766768
return nil
767769
}
@@ -849,7 +851,7 @@ func (o *Object) sliceUpload(ctx context.Context, remote string, in io.Reader, s
849851
}
850852

851853
// 合并上传 (createsuperfile)
852-
func (o *Object) complete(ctx context.Context, remote, md5ListJson string) (FileEntity, error) {
854+
func (o *Object) complete(ctx context.Context, remote, md5ListJSON string) (FileEntity, error) {
853855
opts := &rest.Opts{
854856
Method: "POST",
855857
RootURL: uploadURL,
@@ -859,7 +861,7 @@ func (o *Object) complete(ctx context.Context, remote, md5ListJson string) (File
859861
"path": {remote},
860862
"ondup": {"overwrite"},
861863
},
862-
Body: bytes.NewBuffer([]byte(fmt.Sprintf("param=%s", `{"block_list":`+md5ListJson+`}`))),
864+
Body: bytes.NewBuffer([]byte(fmt.Sprintf("param=%s", `{"block_list":`+md5ListJSON+`}`))),
863865
}
864866
resp := FileEntity{}
865867
err := o.fs.call(ctx, opts, &resp)
@@ -883,9 +885,9 @@ func (o *Object) setMetaData(info *FileEntity) (err error) {
883885
return fs.ErrorIsDir
884886
}
885887
o.hasMetaData = true
886-
o.size = int64(info.Size)
887-
o.modTime = time.Unix(int64(info.ServerMtime), 0)
888-
o.id = strconv.FormatUint(info.FsId, 10)
888+
o.size = info.Size
889+
o.modTime = time.Unix(info.ServerMtime, 0)
890+
o.id = strconv.FormatUint(info.FsID, 10)
889891
o.path = info.Path
890892
o.remote = info.Path
891893
return nil

backend/baidu/entity.go

Lines changed: 20 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,16 @@
11
package baidu
22

3+
// AuthCodeOut is the response for device code request
34
type AuthCodeOut struct {
45
DeviceCode string `json:"device_code"` //设备码,可用于生成单次凭证 Access Token。
56
UserCode string `json:"user_code"` //用户码。 如果选择让用户输入 user code 方式,来引导用户授权,设备需要展示 user code 给用户。
6-
VerificationUrl string `json:"verification_url"` // 用户输入 user code 进行授权的 url。
7-
QrcodeUrl string `json:"qrcode_url"` //二维码url,用户用手机等智能终端扫描该二维码完成授权。
7+
VerificationURL string `json:"verification_url"` // 用户输入 user code 进行授权的 url。
8+
QrcodeURL string `json:"qrcode_url"` //二维码url,用户用手机等智能终端扫描该二维码完成授权。
89
ExpiresIn int `json:"expires_in"` //device_code 的过期时间,单位:秒。到期后 device_code 不能换 Access Token。
910
Interval int `json:"interval"` //device_code 换 Access Token 轮询间隔时间,单位:秒。轮询次数限制小于 expire_in/interval。
1011
}
1112

13+
// AccessTokenOut is the response for access token request
1214
type AccessTokenOut struct {
1315
ExpiresIn int `json:"expires_in"`
1416
RefreshToken string `json:"refresh_token"`
@@ -18,8 +20,9 @@ type AccessTokenOut struct {
1820
Scope string `json:"scope"`
1921
}
2022

23+
// FileEntity represents a single file or directory in Baidu
2124
type FileEntity struct {
22-
FsId uint64 `json:"fs_id"` //文件在云端的唯一标识ID
25+
FsID uint64 `json:"fs_id"` //文件在云端的唯一标识ID
2326
Path string `json:"path"` //文件的绝对路径
2427
ServerFilename string `json:"server_filename"` //文件名称
2528
Size int64 `json:"size"` //文件大小,单位B
@@ -32,47 +35,54 @@ type FileEntity struct {
3235
DirEmpty int `json:"dir_empty"` //该目录是否存在子目录,只有请求参数web=1且该条目为目录时,该字段才存在, 0为存在, 1为不存在
3336
}
3437

38+
// FileListOut is the response for file list request
3539
type FileListOut struct {
3640
ErrorOut
3741
List []FileEntity `json:"list"`
3842
}
3943

44+
// ErrorOut is the common error response from Baidu
4045
type ErrorOut struct {
4146
Errno int `json:"errno"`
4247
ErrMsg string `json:"errmsg"`
4348
}
4449

50+
// MkdirOut is the response for mkdir request
4551
type MkdirOut struct {
4652
ErrorOut
4753
Ctime uint `json:"ctime"`
4854
Mtime uint `json:"mtime"`
49-
FsId uint64 `json:"fs_id"`
55+
FsID uint64 `json:"fs_id"`
5056
IsDir uint `json:"is_dir"`
5157
Path string `json:"path"`
5258
Status uint `json:"status"`
5359
Category uint `json:"category"`
5460
}
5561

62+
// QuotaOut is the response for quota request
5663
type QuotaOut struct {
5764
Total int64 `json:"total"` //总空间大小,单位B
5865
Expire bool `json:"expire"` //7天内是否有容量到期
5966
Used int64 `json:"used"` //已使用大小,单位B
6067
Free int64 `json:"free"` //剩余大小,单位B
6168
}
6269

70+
// PreUploadOut is the response for pre-upload request
6371
type PreUploadOut struct {
6472
ErrorOut
6573
Path string `json:"path"` //文件的绝对路径
66-
UploadId string `json:"uploadid"` //上传唯一ID标识此上传任务
74+
UploadID string `json:"uploadid"` //上传唯一ID标识此上传任务
6775
ReturnType int `json:"return_type"` //返回类型,系统内部状态字段
6876
BlockList []int `json:"block_list"` //需要上传的分片序号列表,索引从0开始
6977
}
7078

79+
// SliceUploadOut is the response for slice upload request
7180
type SliceUploadOut struct {
7281
ErrorOut
7382
Md5 string `json:"md5"` //
7483
}
7584

85+
// RapidUploadOut is the response for rapid upload request
7686
type RapidUploadOut struct {
7787
ErrorOut
7888
Info FileEntity `json:"info"`
@@ -94,11 +104,13 @@ list[0] ["width”] int 图片宽度
94104
list[0] ["date_taken”] int 图片拍摄时间
95105
*/
96106

107+
// FileInfoListOut is the response for file info request
97108
type FileInfoListOut struct {
98109
ErrorOut
99-
List []DownLoadUrl `json:"list"`
110+
List []DownloadURL `json:"list"`
100111
}
101112

102-
type DownLoadUrl struct {
103-
DLink string `json:"dlink"`
113+
// DownloadURL represents a download address
114+
type DownloadURL struct {
115+
Dlink string `json:"dlink"`
104116
}

0 commit comments

Comments
 (0)