From e9535989870aaa8eb0e0893123c731e866ff90ee Mon Sep 17 00:00:00 2001 From: Nick Craig-Wood Date: Tue, 29 Aug 2023 13:02:34 +0100 Subject: [PATCH] build: fix lint errors when re-enabling revive exported & package-comments --- backend/combine/combine.go | 2 +- backend/protondrive/protondrive.go | 21 +++++++++------------ fs/config/flags/flags.go | 1 + fs/features.go | 2 ++ fs/open_options.go | 4 ++++ lib/multipart/multipart.go | 5 +++-- lib/proxy/socks.go | 1 + 7 files changed, 21 insertions(+), 15 deletions(-) diff --git a/backend/combine/combine.go b/backend/combine/combine.go index 9f5713ff2..74384fb48 100644 --- a/backend/combine/combine.go +++ b/backend/combine/combine.go @@ -914,7 +914,7 @@ func (f *Fs) PublicLink(ctx context.Context, remote string, expire fs.Duration, return do(ctx, uRemote, expire, unlink) } -// Put in to the remote path with the modTime given of the given size +// PutUnchecked in to the remote path with the modTime given of the given size // // May create the object even if it returns an error - if so // will return the object and the error, otherwise will return diff --git a/backend/protondrive/protondrive.go b/backend/protondrive/protondrive.go index 187d2529a..04f9573a1 100644 --- a/backend/protondrive/protondrive.go +++ b/backend/protondrive/protondrive.go @@ -1,3 +1,4 @@ +// Package protondrive implements the Proton Drive backend package protondrive import ( @@ -45,8 +46,8 @@ const ( ) var ( - ErrCanNotUploadFileWithUnknownSize = errors.New("proton Drive can't upload files with unknown size") - ErrCanNotPurgeRootDirectory = errors.New("can't purge root directory") + errCanNotUploadFileWithUnknownSize = errors.New("proton Drive can't upload files with unknown size") + errCanNotPurgeRootDirectory = errors.New("can't purge root directory") // for the auth/deauth handler _mapper configmap.Mapper @@ -569,12 +570,10 @@ func (f *Fs) List(ctx context.Context, dir string) (fs.DirEntries, error) { return entries, nil } -// DirCacher describes an interface for doing the low level directory work +// FindLeaf finds a directory of name leaf in the folder with ID pathID // // This should be implemented by the backend and will be called by the // dircache package when appropriate. -// -// FindLeaf finds a directory of name leaf in the folder with ID pathID func (f *Fs) FindLeaf(ctx context.Context, pathID, leaf string) (string, bool, error) { /* f.opt.Enc.FromStandardName(leaf) not required since the DirCache only process sanitized path */ @@ -593,12 +592,10 @@ func (f *Fs) FindLeaf(ctx context.Context, pathID, leaf string) (string, bool, e return link.LinkID, true, nil } -// DirCacher describes an interface for doing the low level directory work +// CreateDir makes a directory with pathID as parent and name leaf // // This should be implemented by the backend and will be called by the // dircache package when appropriate. -// -// CreateDir makes a directory with pathID as parent and name leaf func (f *Fs) CreateDir(ctx context.Context, pathID, leaf string) (string, error) { /* f.opt.Enc.FromStandardName(leaf) not required since the DirCache only process sanitized path */ @@ -626,7 +623,7 @@ func (f *Fs) CreateDir(ctx context.Context, pathID, leaf string) (string, error) func (f *Fs) Put(ctx context.Context, in io.Reader, src fs.ObjectInfo, options ...fs.OpenOption) (fs.Object, error) { size := src.Size() if size < 0 { - return nil, ErrCanNotUploadFileWithUnknownSize + return nil, errCanNotUploadFileWithUnknownSize } existingObj, err := f.NewObject(ctx, src.Remote()) @@ -725,7 +722,7 @@ func (f *Fs) DirCacheFlush() { f.protonDrive.ClearCache() } -// Returns the supported hash types of the filesystem +// Hashes returns the supported hash types of the filesystem func (f *Fs) Hashes() hash.Set { return hash.Set(hash.SHA1) } @@ -887,7 +884,7 @@ func (o *Object) Open(ctx context.Context, options ...fs.OpenOption) (io.ReadClo func (o *Object) Update(ctx context.Context, in io.Reader, src fs.ObjectInfo, options ...fs.OpenOption) error { size := src.Size() if size < 0 { - return ErrCanNotUploadFileWithUnknownSize + return errCanNotUploadFileWithUnknownSize } remote := o.Remote() @@ -945,7 +942,7 @@ func (f *Fs) Purge(ctx context.Context, dir string) error { root := path.Join(f.root, dir) if root == "" { // we can't remove the root directory, but we can list the directory and delete every folder and file in here - return ErrCanNotPurgeRootDirectory + return errCanNotPurgeRootDirectory } folderLinkID, err := f.dirCache.FindDir(ctx, f.sanitizePath(dir), false) diff --git a/fs/config/flags/flags.go b/fs/config/flags/flags.go index b96f37834..ca20402d2 100644 --- a/fs/config/flags/flags.go +++ b/fs/config/flags/flags.go @@ -104,6 +104,7 @@ func (gs *Groups) AllRegistered() map[*pflag.Flag]struct{} { return out } +// All is the global stats Groups var All *Groups // Groups of flags for documentation purposes diff --git a/fs/features.go b/fs/features.go index 560b6edd9..46e7ef424 100644 --- a/fs/features.go +++ b/fs/features.go @@ -639,6 +639,7 @@ type OpenWriterAter interface { // OpenWriterAtFn describes the OpenWriterAt function pointer type OpenWriterAtFn func(ctx context.Context, remote string, size int64) (WriterAtCloser, error) +// OpenChunkWriter is an option interface for Fs to implement chunked writing type OpenChunkWriter interface { // OpenChunkWriter returns the chunk size and a ChunkWriter // @@ -650,6 +651,7 @@ type OpenChunkWriter interface { // OpenChunkWriterFn describes the OpenChunkWriter function pointer type OpenChunkWriterFn func(ctx context.Context, remote string, src ObjectInfo, options ...OpenOption) (chunkSize int64, writer ChunkWriter, err error) +// ChunkWriter is returned by OpenChunkWriter to implement chunked writing type ChunkWriter interface { // WriteChunk will write chunk number with reader bytes, where chunk number >= 0 WriteChunk(ctx context.Context, chunkNumber int, reader io.ReadSeeker) (bytesWritten int64, err error) diff --git a/fs/open_options.go b/fs/open_options.go index 288a36303..26d6d7053 100644 --- a/fs/open_options.go +++ b/fs/open_options.go @@ -276,18 +276,22 @@ func (o MetadataOption) Mandatory() bool { return false } +// ChunkOption defines an Option which returns a preferred chunk size type ChunkOption struct { ChunkSize int64 } +// Header formats the option as an http header func (o *ChunkOption) Header() (key string, value string) { return "chunkSize", fmt.Sprintf("%v", o.ChunkSize) } +// Mandatory returns whether the option must be parsed or can be ignored func (o *ChunkOption) Mandatory() bool { return false } +// String formats the option into human-readable form func (o *ChunkOption) String() string { return fmt.Sprintf("ChunkOption(%v)", o.ChunkSize) } diff --git a/lib/multipart/multipart.go b/lib/multipart/multipart.go index 774076119..e584041ef 100644 --- a/lib/multipart/multipart.go +++ b/lib/multipart/multipart.go @@ -1,3 +1,4 @@ +// Package multipart implements generic multipart uploading. package multipart import ( @@ -37,7 +38,7 @@ func getPool() *pool.Pool { return bufferPool } -// Get a pool.RW using the multipart pool +// NewRW gets a pool.RW using the multipart pool func NewRW() *pool.RW { return pool.NewRW(getPool()) } @@ -50,7 +51,7 @@ type UploadMultipartOptions struct { LeavePartsOnError bool // if set don't delete parts uploaded so far on error } -// Do a generic multipart upload from src using f as OpenChunkWriter. +// UploadMultipart does a generic multipart upload from src using f as OpenChunkWriter. // // in is read seqentially and chunks from it are uploaded in parallel. // diff --git a/lib/proxy/socks.go b/lib/proxy/socks.go index 607bf43a7..1f8e3c40a 100644 --- a/lib/proxy/socks.go +++ b/lib/proxy/socks.go @@ -1,3 +1,4 @@ +// Package proxy enables SOCKS5 proxy dialling package proxy import (