baidu_netdisk

package
v1.1.1 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Feb 7, 2025 License: MIT Imports: 38 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (

	// QuickXorHashType is the hash.Type for OneDrive
	QuickXorHashType hash.Type
)

Globals

Functions

func Config

func Config(ctx context.Context, name string, m configmap.Mapper, config fs.ConfigIn) (*fs.ConfigOut, error)

func NewFs

func NewFs(ctx context.Context, name, root string, m configmap.Mapper) (fs.Fs, error)

NewFs root is linux path ,maybe "" "/" "/1/2" is not be "\1" "\\1" .root may be file path. need to fix

func SplitPath

func SplitPath(pathStr string) (dir, file string)

Types

type BaiduClient

type BaiduClient struct {
	*rest.Client
	Channel    string
	Web        string
	AppId      string
	Bdstoken   string
	LogId      string
	ClientType string
	DpLogId    string
	// contains filtered or unexported fields
}

func NewBaiduClient

func NewBaiduClient(client *rest.Client, logId string) *BaiduClient

func (*BaiduClient) AddParam

func (b *BaiduClient) AddParam(opts *rest.Opts) *rest.Opts

func (*BaiduClient) Call

func (b *BaiduClient) Call(ctx context.Context, opts *rest.Opts) (*http.Response, error)

func (*BaiduClient) CallJSON

func (b *BaiduClient) CallJSON(ctx context.Context, opts *rest.Opts, request interface{}, response ErrnoResponse) (*http.Response, error)

func (*BaiduClient) CallJSONBase

func (b *BaiduClient) CallJSONBase(ctx context.Context, opts *rest.Opts, request interface{}, response interface{}) (*http.Response, error)

func (*BaiduClient) CallJSONIgnore

func (b *BaiduClient) CallJSONIgnore(ctx context.Context, opts *rest.Opts, request interface{}, response ErrnoResponse, ignoreList []int) (*http.Response, error)

type Dir

type Dir struct {
	// contains filtered or unexported fields
}

Dir describes an unspecialized directory for directory/container/bucket lists

func NewDir

func NewDir(fs *Fs, remote string, modTime time.Time) *Dir

NewDir creates an unspecialized Directory object

If the modTime is unknown pass in time.Time{}

func (*Dir) Fs

func (d *Dir) Fs() fs.Info

func (*Dir) ID

func (d *Dir) ID() string

ID gets the optional ID

func (*Dir) Items

func (d *Dir) Items() int64

Items returns the count of items in this directory or this directory and subdirectories if known, -1 for unknown

func (*Dir) ModTime

func (d *Dir) ModTime(ctx context.Context) time.Time

ModTime returns the modification date of the file

If one isn't available it returns the configured --default-dir-time

func (*Dir) ParentID

func (d *Dir) ParentID() string

ParentID returns the IDs of the Dir parent if known

func (*Dir) Remote

func (d *Dir) Remote() string

Remote returns the remote path

func (*Dir) SetID

func (d *Dir) SetID(id string) *Dir

SetID sets the optional ID

func (*Dir) SetItems

func (d *Dir) SetItems(items int64) *Dir

SetItems sets the number of items in the directory

func (*Dir) SetParentID

func (d *Dir) SetParentID(parent string) *Dir

SetParentID sets the optional parent ID of the Dir

func (*Dir) SetRemote

func (d *Dir) SetRemote(remote string) *Dir

SetRemote sets the remote

func (*Dir) SetSize

func (d *Dir) SetSize(size int64) *Dir

SetSize sets the size of the directory

func (*Dir) Size

func (d *Dir) Size() int64

Size returns the size of the file

func (*Dir) String

func (d *Dir) String() string

String returns the name

type ErrnoResponse

type ErrnoResponse interface {
	GetErrno() int
}

type Fs

type Fs struct {
	UserId  int64  // ID to use for querying Microsoft Graph
	VipType string // https://developer.microsoft.com/en-us/graph/docs/api-reference/v1.0/resources/drive
	// contains filtered or unexported fields
}

Fs represents a remote OneDrive

func (*Fs) Copy

func (f *Fs) Copy(ctx context.Context, src fs.Object, remote string) (fs.Object, error)

Copy src to this remote using server-side copy operations.

This is stored with the remote path given.

It returns the destination Object and a possible error.

Will only be called if src.Fs().Name() == f.Name()

If it isn't possible then return fs.ErrorCantCopy

func (*Fs) Create

func (f *Fs) Create(ctx context.Context, path string, preCreateFileData *api.PreCreateFileData, uploadId string) (info *api.CreateVO, err error)

Create {"ctime":1713679787,"from_type":1,"fs_id":908199638643457,"isdir":0,"md5":"cd46789bbnf14a0f4de795dd13a70ca3","mtime":1713679787,"path":"/test/999/111/8e3dc4f3a75d1e13f428a1dd15e57fb7.png","size":30051726,"errno":0,"name":"\/test\/999\/111\/8e3dc4f3a75d1e13f428a1dd15e57fb7.png","category":3}

func (*Fs) CreateDir

func (f *Fs) CreateDir(ctx context.Context, pathID, leaf string) (newID string, err error)

func (*Fs) CreateDirForce

func (f *Fs) CreateDirForce(ctx context.Context, path string) (err error)

CreateDirForce force to create file ,if exists , not do anything

func (*Fs) DeleteDirOrFile

func (f *Fs) DeleteDirOrFile(ctx context.Context, filePath string) (err error)

func (*Fs) DeleteDirsOrFiles

func (f *Fs) DeleteDirsOrFiles(ctx context.Context, fileList []string) (err error)

func (*Fs) DirMove

func (f *Fs) DirMove(ctx context.Context, src fs.Fs, srcRemote, dstRemote string) error

DirMove moves src, srcRemote to this remote at dstRemote using server-side move operations.

Will only be called if src.Fs().Name() == f.Name()

If it isn't possible then return fs.ErrorCantDirMove

If destination exists then return fs.ErrorDirExists

srcRemote is absolute path,dstRemote is absolute path,can not end with "/"

func (*Fs) DownFile

func (f *Fs) DownFile(ctx context.Context, path string, size int64, options []fs.OpenOption) (in io.ReadCloser, err error)

有多少切片就开多少线程去下载

func (*Fs) DownFileBySlice

func (f *Fs) DownFileBySlice(ctx context.Context, downUrl string, beginIndex int64, endIndex int64) (resp *http.Response, err error)

DownFileBySlice 手机app设定的分片值为32768,或许可以设置更大一些,需要测试

func (*Fs) DownFileDisguiseBaiduClient

func (f *Fs) DownFileDisguiseBaiduClient(ctx context.Context, path string, options []fs.OpenOption) (resp *http.Response, err error)

func (*Fs) DownFileSe

func (f *Fs) DownFileSe(ctx context.Context, path string, size int64, options []fs.OpenOption) (in io.ReadCloser, err error)

固定线程去下载

func (*Fs) DownFileSerial

func (f *Fs) DownFileSerial(ctx context.Context, path string, size int64, options []fs.OpenOption) (in io.ReadCloser, err error)

串行执行

func (*Fs) Features

func (f *Fs) Features() *fs.Features

Features returns the optional features of this Fs

func (*Fs) FindLeaf

func (f *Fs) FindLeaf(ctx context.Context, pathID, leaf string) (pathIDOut string, found bool, err error)

func (*Fs) GetDownUrl

func (f *Fs) GetDownUrl(ctx context.Context, path string) (url string, err error)

func (*Fs) GetFileMeta

func (f *Fs) GetFileMeta(ctx context.Context, path string, needDownLink bool, needTextLink bool) (item *api.Item, resp *http.Response, err error)

GetFileMeta 返回单个文件或文件夹信息,经过处理

func (*Fs) GetFileMetas

func (f *Fs) GetFileMetas(ctx context.Context, path []string, needDownLink bool, needTextLink bool) (itemList []*api.Item, resp *http.Response, err error)

GetFileMetas 返回多个文件或文件夹信息(注意是path只能一一对应,并且无法获取到时不会报错,而是返回的info里没有对应的文件或文件夹时errno为-9,外层为0)

func (*Fs) GetTemplateVariable

func (f *Fs) GetTemplateVariable(ctx context.Context) (*api.TemplateInfo, error)

func (*Fs) Hashes

func (f *Fs) Hashes() hash.Set

Hashes returns the supported hash sets.

func (*Fs) List

func (f *Fs) List(ctx context.Context, dir string) (entries fs.DirEntries, err error)

List entries normal need to implement fs.Directory or fs.Object ,dir is relative path.

func (*Fs) ListDirAllFiles

func (f *Fs) ListDirAllFiles(ctx context.Context, path string) (itemList []*api.Item, err error)

func (*Fs) ListDirFilesPage

func (f *Fs) ListDirFilesPage(ctx context.Context, path string, page int, num int) (itemList []*api.Item, resp *http.Response, err error)

func (*Fs) Mkdir

func (f *Fs) Mkdir(ctx context.Context, dir string) error

func (*Fs) Move

func (f *Fs) Move(ctx context.Context, src fs.Object, remote string) (fs.Object, error)

Move src to this remote using server-side move operations.

This is stored with the remote path given.

It returns the destination Object and a possible error.

Will only be called if src.Fs().Name() == f.Name()

If it isn't possible then return fs.ErrorCantMove

func (*Fs) MoveOrCopyDirOrFile

func (f *Fs) MoveOrCopyDirOrFile(ctx context.Context, fileParamList api.FileManagerParam, operate api.Operate) (err error)

func (*Fs) MoveOrCopyDirsOrFiles

func (f *Fs) MoveOrCopyDirsOrFiles(ctx context.Context, fileParamList []api.FileManagerParam, operate api.Operate) (err error)

func (*Fs) Name

func (f *Fs) Name() string

Name of the remote (as passed into NewFs)

func (*Fs) NewObject

func (f *Fs) NewObject(ctx context.Context, remote string) (fs.Object, error)

NewObject finds the Object at remote. If it can't be found it returns the error fs.ErrorObjectNotFound.

func (*Fs) NewObjectFromBaseItem

func (f *Fs) NewObjectFromBaseItem(item *api.BaseItem) (*Object, error)

func (*Fs) PreCreate

func (f *Fs) PreCreate(ctx context.Context, reader *readers.RepeatableReader, localCtime int64, localMtime int64, size int64, path string) (preCreateFileData *api.PreCreateFileData, info *api.PreCreateVO, err error)

PreCreate {"path":"/test/999/111/1234.exe","return_type":1,"block_list":["5910a591dd8fc18c32a8f3df4fdc1761","a5fc157d78e6ad1c7e114b056c92821e"],"errno":0,"request_id":278285463311322051} { "return_type": 2, "errno": 0, "info": { "md5": "5ddc05b01g7f6ae7d6adc90d912c983d", "category": 6, "fs_id": 166064416325948, "request_id": 280244028406040000, "from_type": 1, "size": 112060240, "isdir": 0, "mtime": 1713672326, "ctime": 1713672326, "path": "/test/999/111/1234_20240421_120525.exe" }, "request_id": 280244028406040573 } return_type 1 无法秒传,准备上传 2 秒传成功 3 文件已存在(仅一刻相册,在百度网盘中只会返回2) 文件名中不能包含?|"><:*等特殊字符

func (*Fs) Precision

func (f *Fs) Precision() time.Duration

Precision return the precision of this Fs

func (*Fs) Purge

func (f *Fs) Purge(ctx context.Context, dir string) error

func (*Fs) Put

func (f *Fs) Put(ctx context.Context, in io.Reader, src fs.ObjectInfo, options ...fs.OpenOption) (fs.Object, error)

Put in to the remote path with the modTime given of the given size

When called from outside an Fs by rclone, src.Size() will always be >= 0. But for unknown-sized objects (indicated by src.Size() == -1), Put should either return an error or upload it properly (rather than e.g. calling panic).

May create the object even if it returns an error - if so will return the object and the error, otherwise will return nil and the error

func (*Fs) RenameDirOrFile

func (f *Fs) RenameDirOrFile(ctx context.Context, fileParamList api.FileManagerParam) (err error)

func (*Fs) RenameDirsOrFiles

func (f *Fs) RenameDirsOrFiles(ctx context.Context, fileParamList []api.FileManagerParam) (err error)

func (*Fs) Rmdir

func (f *Fs) Rmdir(ctx context.Context, dir string) error

func (*Fs) Root

func (f *Fs) Root() string

Root of the remote (as passed into NewFs)

func (*Fs) String

func (f *Fs) String() string

String converts this Fs to a string

func (*Fs) ToAbsoluteFilePath

func (f *Fs) ToAbsoluteFilePath(relativePath string, fileName string) string

func (*Fs) ToAbsolutePath

func (f *Fs) ToAbsolutePath(relativePath string) string

func (*Fs) ToAbsolutePathFromNative

func (f *Fs) ToAbsolutePathFromNative(relativePath string) string

func (*Fs) ToAbsolutePathFromStandard

func (f *Fs) ToAbsolutePathFromStandard(relativePath string) string

func (*Fs) ToRelativeFilePath

func (f *Fs) ToRelativeFilePath(relativePath string, fileName string) string

func (*Fs) ToRelativePath

func (f *Fs) ToRelativePath(absolutePath string) (string, error)

func (*Fs) UploadFile

func (f *Fs) UploadFile(ctx context.Context, in io.Reader, localCtime int64, localMtime int64, size int64, path string) (*api.BaseItem, error)

type Object

type Object struct {
	// contains filtered or unexported fields
}

Object describes a OneDrive object

Will definitely have info but maybe not meta

func (*Object) Fs

func (o *Object) Fs() fs.Info

Fs returns the parent Fs

func (*Object) Hash

func (o *Object) Hash(ctx context.Context, t hash.Type) (string, error)

Hash returns the SHA-1 of an object returning a lowercase hex string

func (*Object) ID

func (o *Object) ID() string

ID returns the ID of the Object if known, or "" if not

func (*Object) MimeType

func (o *Object) MimeType(ctx context.Context) string

MimeType of an Object if known, "" otherwise

func (*Object) ModTime

func (o *Object) ModTime(ctx context.Context) time.Time

ModTime returns the modification time of the object

It attempts to read the objects mtime and if that isn't present the LastModified returned in the http headers

func (*Object) Open

func (o *Object) Open(ctx context.Context, options ...fs.OpenOption) (in io.ReadCloser, err error)

func (*Object) OpenOld

func (o *Object) OpenOld(ctx context.Context, options ...fs.OpenOption) (in io.ReadCloser, err error)

Open an object for read

func (*Object) Remote

func (o *Object) Remote() string

Remote returns the remote path

func (*Object) Remove

func (o *Object) Remove(ctx context.Context) error

Remove an object

func (*Object) SetModTime

func (o *Object) SetModTime(ctx context.Context, modTime time.Time) error

SetModTime sets the modification time of the local fs object

func (*Object) Size

func (o *Object) Size() int64

Size returns the size of an object in bytes

func (*Object) Storable

func (o *Object) Storable() bool

Storable returns a boolean showing whether this object storable

func (*Object) String

func (o *Object) String() string

Return a string version

func (*Object) Update

func (o *Object) Update(ctx context.Context, in io.Reader, src fs.ObjectInfo, options ...fs.OpenOption) (err error)

Update the object with the contents of the io.Reader, modTime and size

The new object may have been created if an error is returned

type Options

type Options struct {
	Region                  string               `config:"region"`
	ChunkSize               fs.SizeSuffix        `config:"chunk_size"`
	UserID                  int64                `config:"drive_id"`
	VipType                 string               `config:"drive_type"`
	RootFolderID            string               `config:"root_folder_id"`
	DisableSitePermission   bool                 `config:"disable_site_permission"`
	AccessScopes            fs.SpaceSepList      `config:"access_scopes"`
	ExposeOneNoteFiles      bool                 `config:"expose_onenote_files"`
	ServerSideAcrossConfigs bool                 `config:"server_side_across_configs"`
	ListChunk               int64                `config:"list_chunk"`
	NoVersions              bool                 `config:"no_versions"`
	LinkScope               string               `config:"link_scope"`
	LinkType                string               `config:"link_type"`
	LinkPassword            string               `config:"link_password"`
	HashType                string               `config:"hash_type"`
	AVOverride              bool                 `config:"av_override"`
	Delta                   bool                 `config:"delta"`
	Enc                     encoder.MultiEncoder `config:"encoding"`
}

Options defines the configuration for this backend

type TaskResult

type TaskResult struct {
	// contains filtered or unexported fields
}

Directories

Path Synopsis
Package quickxorhash provides the quickXorHash algorithm which is a quick, simple non-cryptographic hash algorithm that works by XORing the bytes in a circular-shifting fashion.
Package quickxorhash provides the quickXorHash algorithm which is a quick, simple non-cryptographic hash algorithm that works by XORing the bytes in a circular-shifting fashion.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL