forked from TrueCloudLab/rclone
http: Fix comments, remove optional methods which don't work
This commit is contained in:
parent
6b89e6c381
commit
d5d635b7f3
1 changed files with 11 additions and 27 deletions
38
http/http.go
38
http/http.go
|
@ -1,4 +1,7 @@
|
||||||
// Package http provides a filesystem interface using golang.org/net/http
|
// Package http provides a filesystem interface using golang.org/net/http
|
||||||
|
//
|
||||||
|
// It treads HTML pages served from the endpoint as directory
|
||||||
|
// listings, and includes any links found as files.
|
||||||
|
|
||||||
// +build !plan9
|
// +build !plan9
|
||||||
|
|
||||||
|
@ -40,7 +43,7 @@ func init() {
|
||||||
fs.Register(fsi)
|
fs.Register(fsi)
|
||||||
}
|
}
|
||||||
|
|
||||||
// Fs stores the interface to the remote SFTP files
|
// Fs stores the interface to the remote HTTP files
|
||||||
type Fs struct {
|
type Fs struct {
|
||||||
name string
|
name string
|
||||||
root string
|
root string
|
||||||
|
@ -214,14 +217,6 @@ func parseTime(n *html.Node) (t time.Time) {
|
||||||
return t
|
return t
|
||||||
}
|
}
|
||||||
|
|
||||||
// CheckClose is a utility function used to check the return from
|
|
||||||
// Close in a defer statement.
|
|
||||||
func CheckClose(c io.Closer, err *error) {
|
|
||||||
cerr := c.Close()
|
|
||||||
if *err == nil {
|
|
||||||
*err = cerr
|
|
||||||
}
|
|
||||||
}
|
|
||||||
func (f *Fs) readDir(path string) ([]*entry, error) {
|
func (f *Fs) readDir(path string) ([]*entry, error) {
|
||||||
entries := make([]*entry, 0)
|
entries := make([]*entry, 0)
|
||||||
res, err := f.httpClient.Get(urlJoin(f.endpoint, path))
|
res, err := f.httpClient.Get(urlJoin(f.endpoint, path))
|
||||||
|
@ -229,9 +224,10 @@ func (f *Fs) readDir(path string) ([]*entry, error) {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
if res.Body == nil || res.StatusCode != http.StatusOK {
|
if res.Body == nil || res.StatusCode != http.StatusOK {
|
||||||
|
//return nil, errors.Errorf("directory listing failed with error: % (%d)", res.Status, res.StatusCode)
|
||||||
return nil, nil
|
return nil, nil
|
||||||
}
|
}
|
||||||
defer CheckClose(res.Body, &err)
|
defer fs.CheckClose(res.Body, &err)
|
||||||
|
|
||||||
switch strings.SplitN(res.Header.Get("Content-Type"), ";", 2)[0] {
|
switch strings.SplitN(res.Header.Get("Content-Type"), ";", 2)[0] {
|
||||||
case "text/html":
|
case "text/html":
|
||||||
|
@ -365,7 +361,7 @@ func (o *Object) Fs() fs.Info {
|
||||||
return o.fs
|
return o.fs
|
||||||
}
|
}
|
||||||
|
|
||||||
// String returns the URL to the remote SFTP file
|
// String returns the URL to the remote HTTP file
|
||||||
func (o *Object) String() string {
|
func (o *Object) String() string {
|
||||||
if o == nil {
|
if o == nil {
|
||||||
return "<nil>"
|
return "<nil>"
|
||||||
|
@ -373,12 +369,12 @@ func (o *Object) String() string {
|
||||||
return o.remote
|
return o.remote
|
||||||
}
|
}
|
||||||
|
|
||||||
// Remote the name of the remote SFTP file, relative to the fs root
|
// Remote the name of the remote HTTP file, relative to the fs root
|
||||||
func (o *Object) Remote() string {
|
func (o *Object) Remote() string {
|
||||||
return o.remote
|
return o.remote
|
||||||
}
|
}
|
||||||
|
|
||||||
// Hash returns "" since SFTP (in Go or OpenSSH) doesn't support remote calculation of hashes
|
// Hash returns "" since HTTP (in Go or OpenSSH) doesn't support remote calculation of hashes
|
||||||
func (o *Object) Hash(r fs.HashType) (string, error) {
|
func (o *Object) Hash(r fs.HashType) (string, error) {
|
||||||
return "", fs.ErrHashUnsupported
|
return "", fs.ErrHashUnsupported
|
||||||
}
|
}
|
||||||
|
@ -511,25 +507,13 @@ func (f *Fs) Rmdir(dir string) error {
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
// Move renames a remote http file object
|
|
||||||
func (f *Fs) Move(src fs.Object, remote string) (fs.Object, error) {
|
|
||||||
return nil, nil
|
|
||||||
}
|
|
||||||
|
|
||||||
// Update a remote http file using the data <in> and ModTime from <src>
|
// Update a remote http file using the data <in> and ModTime from <src>
|
||||||
func (o *Object) Update(in io.Reader, src fs.ObjectInfo) error {
|
func (o *Object) Update(in io.Reader, src fs.ObjectInfo) error {
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
// DirMove moves dir
|
|
||||||
func (f *Fs) DirMove(src fs.Fs, srcRemote, dstRemote string) error {
|
|
||||||
return nil
|
|
||||||
}
|
|
||||||
|
|
||||||
// Check the interfaces are satisfied
|
// Check the interfaces are satisfied
|
||||||
var (
|
var (
|
||||||
_ fs.Fs = &Fs{}
|
_ fs.Fs = &Fs{}
|
||||||
_ fs.Mover = &Fs{}
|
_ fs.Object = &Object{}
|
||||||
_ fs.DirMover = &Fs{}
|
|
||||||
_ fs.Object = &Object{}
|
|
||||||
)
|
)
|
||||||
|
|
Loading…
Reference in a new issue