@@ -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
199200type 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
303304func (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
601603type 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
658660func (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
0 commit comments