mirror of
https://github.com/rclone/rclone.git
synced 2024-11-22 16:34:30 +01:00
Rename NewFsObject to NewObject
This commit is contained in:
parent
1a87b69376
commit
b1f131964e
@ -215,7 +215,7 @@ func NewFs(name, root string) (fs.Fs, error) {
|
|||||||
// No root so return old f
|
// No root so return old f
|
||||||
return f, nil
|
return f, nil
|
||||||
}
|
}
|
||||||
obj := newF.newFsObjectWithInfo(remote, nil)
|
obj := newF.newObjectWithInfo(remote, nil)
|
||||||
if obj == nil {
|
if obj == nil {
|
||||||
// File doesn't exist so return old f
|
// File doesn't exist so return old f
|
||||||
return f, nil
|
return f, nil
|
||||||
@ -226,10 +226,10 @@ func NewFs(name, root string) (fs.Fs, error) {
|
|||||||
return f, nil
|
return f, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
// Return an FsObject from a path
|
// Return an Object from a path
|
||||||
//
|
//
|
||||||
// May return nil if an error occurred
|
// May return nil if an error occurred
|
||||||
func (f *Fs) newFsObjectWithInfo(remote string, info *acd.Node) fs.Object {
|
func (f *Fs) newObjectWithInfo(remote string, info *acd.Node) fs.Object {
|
||||||
o := &Object{
|
o := &Object{
|
||||||
fs: f,
|
fs: f,
|
||||||
remote: remote,
|
remote: remote,
|
||||||
@ -247,11 +247,11 @@ func (f *Fs) newFsObjectWithInfo(remote string, info *acd.Node) fs.Object {
|
|||||||
return o
|
return o
|
||||||
}
|
}
|
||||||
|
|
||||||
// NewFsObject returns an FsObject from a path
|
// NewObject returns an Object from a path
|
||||||
//
|
//
|
||||||
// May return nil if an error occurred
|
// May return nil if an error occurred
|
||||||
func (f *Fs) NewFsObject(remote string) fs.Object {
|
func (f *Fs) NewObject(remote string) fs.Object {
|
||||||
return f.newFsObjectWithInfo(remote, nil)
|
return f.newObjectWithInfo(remote, nil)
|
||||||
}
|
}
|
||||||
|
|
||||||
// FindLeaf finds a directory of name leaf in the folder with ID pathID
|
// FindLeaf finds a directory of name leaf in the folder with ID pathID
|
||||||
@ -384,7 +384,7 @@ func (f *Fs) ListDir(out fs.ListOpts, job dircache.ListDirJob) (jobs []dircache.
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
case fileKind:
|
case fileKind:
|
||||||
if o := f.newFsObjectWithInfo(remote, node); o != nil {
|
if o := f.newObjectWithInfo(remote, node); o != nil {
|
||||||
if out.Add(o) {
|
if out.Add(o) {
|
||||||
return true
|
return true
|
||||||
}
|
}
|
||||||
@ -557,7 +557,7 @@ func (f *Fs) Hashes() fs.HashSet {
|
|||||||
// if err != nil {
|
// if err != nil {
|
||||||
// return nil, err
|
// return nil, err
|
||||||
// }
|
// }
|
||||||
// return f.NewFsObject(remote), nil
|
// return f.NewObject(remote), nil
|
||||||
//}
|
//}
|
||||||
|
|
||||||
// Purge deletes all the files and the container
|
// Purge deletes all the files and the container
|
||||||
|
@ -25,7 +25,7 @@ func TestFsRmdirNotFound(t *testing.T) { fstests.TestFsRmdirNotFound(t) }
|
|||||||
func TestFsMkdir(t *testing.T) { fstests.TestFsMkdir(t) }
|
func TestFsMkdir(t *testing.T) { fstests.TestFsMkdir(t) }
|
||||||
func TestFsListEmpty(t *testing.T) { fstests.TestFsListEmpty(t) }
|
func TestFsListEmpty(t *testing.T) { fstests.TestFsListEmpty(t) }
|
||||||
func TestFsListDirEmpty(t *testing.T) { fstests.TestFsListDirEmpty(t) }
|
func TestFsListDirEmpty(t *testing.T) { fstests.TestFsListDirEmpty(t) }
|
||||||
func TestFsNewFsObjectNotFound(t *testing.T) { fstests.TestFsNewFsObjectNotFound(t) }
|
func TestFsNewObjectNotFound(t *testing.T) { fstests.TestFsNewObjectNotFound(t) }
|
||||||
func TestFsPutFile1(t *testing.T) { fstests.TestFsPutFile1(t) }
|
func TestFsPutFile1(t *testing.T) { fstests.TestFsPutFile1(t) }
|
||||||
func TestFsPutFile2(t *testing.T) { fstests.TestFsPutFile2(t) }
|
func TestFsPutFile2(t *testing.T) { fstests.TestFsPutFile2(t) }
|
||||||
func TestFsUpdateFile1(t *testing.T) { fstests.TestFsUpdateFile1(t) }
|
func TestFsUpdateFile1(t *testing.T) { fstests.TestFsUpdateFile1(t) }
|
||||||
@ -34,7 +34,7 @@ func TestFsListDirRoot(t *testing.T) { fstests.TestFsListDirRoot(t) }
|
|||||||
func TestFsListSubdir(t *testing.T) { fstests.TestFsListSubdir(t) }
|
func TestFsListSubdir(t *testing.T) { fstests.TestFsListSubdir(t) }
|
||||||
func TestFsListLevel2(t *testing.T) { fstests.TestFsListLevel2(t) }
|
func TestFsListLevel2(t *testing.T) { fstests.TestFsListLevel2(t) }
|
||||||
func TestFsListFile1(t *testing.T) { fstests.TestFsListFile1(t) }
|
func TestFsListFile1(t *testing.T) { fstests.TestFsListFile1(t) }
|
||||||
func TestFsNewFsObject(t *testing.T) { fstests.TestFsNewFsObject(t) }
|
func TestFsNewObject(t *testing.T) { fstests.TestFsNewObject(t) }
|
||||||
func TestFsListFile1and2(t *testing.T) { fstests.TestFsListFile1and2(t) }
|
func TestFsListFile1and2(t *testing.T) { fstests.TestFsListFile1and2(t) }
|
||||||
func TestFsCopy(t *testing.T) { fstests.TestFsCopy(t) }
|
func TestFsCopy(t *testing.T) { fstests.TestFsCopy(t) }
|
||||||
func TestFsMove(t *testing.T) { fstests.TestFsMove(t) }
|
func TestFsMove(t *testing.T) { fstests.TestFsMove(t) }
|
||||||
|
14
b2/b2.go
14
b2/b2.go
@ -237,7 +237,7 @@ func NewFs(name, root string) (fs.Fs, error) {
|
|||||||
} else {
|
} else {
|
||||||
f.root += "/"
|
f.root += "/"
|
||||||
}
|
}
|
||||||
obj := f.NewFsObject(remote)
|
obj := f.NewObject(remote)
|
||||||
if obj != nil {
|
if obj != nil {
|
||||||
// return an error with an fs which points to the parent
|
// return an error with an fs which points to the parent
|
||||||
return f, fs.ErrorIsFile
|
return f, fs.ErrorIsFile
|
||||||
@ -319,10 +319,10 @@ func (f *Fs) clearUploadURL() {
|
|||||||
f.uploadMu.Unlock()
|
f.uploadMu.Unlock()
|
||||||
}
|
}
|
||||||
|
|
||||||
// Return an FsObject from a path
|
// Return an Object from a path
|
||||||
//
|
//
|
||||||
// May return nil if an error occurred
|
// May return nil if an error occurred
|
||||||
func (f *Fs) newFsObjectWithInfo(remote string, info *api.File) fs.Object {
|
func (f *Fs) newObjectWithInfo(remote string, info *api.File) fs.Object {
|
||||||
o := &Object{
|
o := &Object{
|
||||||
fs: f,
|
fs: f,
|
||||||
remote: remote,
|
remote: remote,
|
||||||
@ -343,11 +343,11 @@ func (f *Fs) newFsObjectWithInfo(remote string, info *api.File) fs.Object {
|
|||||||
return o
|
return o
|
||||||
}
|
}
|
||||||
|
|
||||||
// NewFsObject returns an FsObject from a path
|
// NewObject returns an Object from a path
|
||||||
//
|
//
|
||||||
// May return nil if an error occurred
|
// May return nil if an error occurred
|
||||||
func (f *Fs) NewFsObject(remote string) fs.Object {
|
func (f *Fs) NewObject(remote string) fs.Object {
|
||||||
return f.newFsObjectWithInfo(remote, nil)
|
return f.newObjectWithInfo(remote, nil)
|
||||||
}
|
}
|
||||||
|
|
||||||
// sendDir works out given a lastDir and a remote which directories should be sent
|
// sendDir works out given a lastDir and a remote which directories should be sent
|
||||||
@ -495,7 +495,7 @@ func (f *Fs) listFiles(out fs.ListOpts, dir string) {
|
|||||||
return fs.ErrorListAborted
|
return fs.ErrorListAborted
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
if o := f.newFsObjectWithInfo(remote, object); o != nil {
|
if o := f.newObjectWithInfo(remote, object); o != nil {
|
||||||
if out.Add(o) {
|
if out.Add(o) {
|
||||||
return fs.ErrorListAborted
|
return fs.ErrorListAborted
|
||||||
}
|
}
|
||||||
|
@ -25,7 +25,7 @@ func TestFsRmdirNotFound(t *testing.T) { fstests.TestFsRmdirNotFound(t) }
|
|||||||
func TestFsMkdir(t *testing.T) { fstests.TestFsMkdir(t) }
|
func TestFsMkdir(t *testing.T) { fstests.TestFsMkdir(t) }
|
||||||
func TestFsListEmpty(t *testing.T) { fstests.TestFsListEmpty(t) }
|
func TestFsListEmpty(t *testing.T) { fstests.TestFsListEmpty(t) }
|
||||||
func TestFsListDirEmpty(t *testing.T) { fstests.TestFsListDirEmpty(t) }
|
func TestFsListDirEmpty(t *testing.T) { fstests.TestFsListDirEmpty(t) }
|
||||||
func TestFsNewFsObjectNotFound(t *testing.T) { fstests.TestFsNewFsObjectNotFound(t) }
|
func TestFsNewObjectNotFound(t *testing.T) { fstests.TestFsNewObjectNotFound(t) }
|
||||||
func TestFsPutFile1(t *testing.T) { fstests.TestFsPutFile1(t) }
|
func TestFsPutFile1(t *testing.T) { fstests.TestFsPutFile1(t) }
|
||||||
func TestFsPutFile2(t *testing.T) { fstests.TestFsPutFile2(t) }
|
func TestFsPutFile2(t *testing.T) { fstests.TestFsPutFile2(t) }
|
||||||
func TestFsUpdateFile1(t *testing.T) { fstests.TestFsUpdateFile1(t) }
|
func TestFsUpdateFile1(t *testing.T) { fstests.TestFsUpdateFile1(t) }
|
||||||
@ -34,7 +34,7 @@ func TestFsListDirRoot(t *testing.T) { fstests.TestFsListDirRoot(t) }
|
|||||||
func TestFsListSubdir(t *testing.T) { fstests.TestFsListSubdir(t) }
|
func TestFsListSubdir(t *testing.T) { fstests.TestFsListSubdir(t) }
|
||||||
func TestFsListLevel2(t *testing.T) { fstests.TestFsListLevel2(t) }
|
func TestFsListLevel2(t *testing.T) { fstests.TestFsListLevel2(t) }
|
||||||
func TestFsListFile1(t *testing.T) { fstests.TestFsListFile1(t) }
|
func TestFsListFile1(t *testing.T) { fstests.TestFsListFile1(t) }
|
||||||
func TestFsNewFsObject(t *testing.T) { fstests.TestFsNewFsObject(t) }
|
func TestFsNewObject(t *testing.T) { fstests.TestFsNewObject(t) }
|
||||||
func TestFsListFile1and2(t *testing.T) { fstests.TestFsListFile1and2(t) }
|
func TestFsListFile1and2(t *testing.T) { fstests.TestFsListFile1and2(t) }
|
||||||
func TestFsCopy(t *testing.T) { fstests.TestFsCopy(t) }
|
func TestFsCopy(t *testing.T) { fstests.TestFsCopy(t) }
|
||||||
func TestFsMove(t *testing.T) { fstests.TestFsMove(t) }
|
func TestFsMove(t *testing.T) { fstests.TestFsMove(t) }
|
||||||
|
@ -337,7 +337,7 @@ func NewFs(name, path string) (fs.Fs, error) {
|
|||||||
// No root so return old f
|
// No root so return old f
|
||||||
return f, nil
|
return f, nil
|
||||||
}
|
}
|
||||||
_, err := newF.newFsObjectWithInfoErr(remote, nil)
|
_, err := newF.newObjectWithInfoErr(remote, nil)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
// File doesn't exist so return old f
|
// File doesn't exist so return old f
|
||||||
return f, nil
|
return f, nil
|
||||||
@ -349,8 +349,8 @@ func NewFs(name, path string) (fs.Fs, error) {
|
|||||||
return f, nil
|
return f, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
// Return an FsObject from a path
|
// Return an Object from a path
|
||||||
func (f *Fs) newFsObjectWithInfoErr(remote string, info *drive.File) (fs.Object, error) {
|
func (f *Fs) newObjectWithInfoErr(remote string, info *drive.File) (fs.Object, error) {
|
||||||
o := &Object{
|
o := &Object{
|
||||||
fs: f,
|
fs: f,
|
||||||
remote: remote,
|
remote: remote,
|
||||||
@ -366,22 +366,22 @@ func (f *Fs) newFsObjectWithInfoErr(remote string, info *drive.File) (fs.Object,
|
|||||||
return o, nil
|
return o, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
// Return an FsObject from a path
|
// Return an Object from a path
|
||||||
//
|
//
|
||||||
// May return nil if an error occurred
|
// May return nil if an error occurred
|
||||||
func (f *Fs) newFsObjectWithInfo(remote string, info *drive.File) fs.Object {
|
func (f *Fs) newObjectWithInfo(remote string, info *drive.File) fs.Object {
|
||||||
o, err := f.newFsObjectWithInfoErr(remote, info)
|
o, err := f.newObjectWithInfoErr(remote, info)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
fs.Log(o, "Failed to read metadata: %v", err)
|
fs.Log(o, "Failed to read metadata: %v", err)
|
||||||
}
|
}
|
||||||
return o
|
return o
|
||||||
}
|
}
|
||||||
|
|
||||||
// NewFsObject returns an FsObject from a path
|
// NewObject returns an Object from a path
|
||||||
//
|
//
|
||||||
// May return nil if an error occurred
|
// May return nil if an error occurred
|
||||||
func (f *Fs) NewFsObject(remote string) fs.Object {
|
func (f *Fs) NewObject(remote string) fs.Object {
|
||||||
return f.newFsObjectWithInfo(remote, nil)
|
return f.newObjectWithInfo(remote, nil)
|
||||||
}
|
}
|
||||||
|
|
||||||
// FindLeaf finds a directory of name leaf in the folder with ID pathID
|
// FindLeaf finds a directory of name leaf in the folder with ID pathID
|
||||||
@ -478,7 +478,7 @@ func (f *Fs) ListDir(out fs.ListOpts, job dircache.ListDirJob) (jobs []dircache.
|
|||||||
}
|
}
|
||||||
case item.Md5Checksum != "":
|
case item.Md5Checksum != "":
|
||||||
// If item has MD5 sum it is a file stored on drive
|
// If item has MD5 sum it is a file stored on drive
|
||||||
if o := f.newFsObjectWithInfo(remote, item); o != nil {
|
if o := f.newObjectWithInfo(remote, item); o != nil {
|
||||||
if out.Add(o) {
|
if out.Add(o) {
|
||||||
return true
|
return true
|
||||||
}
|
}
|
||||||
@ -489,7 +489,7 @@ func (f *Fs) ListDir(out fs.ListOpts, job dircache.ListDirJob) (jobs []dircache.
|
|||||||
if extension == "" {
|
if extension == "" {
|
||||||
fs.Debug(remote, "No export formats found")
|
fs.Debug(remote, "No export formats found")
|
||||||
} else {
|
} else {
|
||||||
if o := f.newFsObjectWithInfo(remote+"."+extension, item); o != nil {
|
if o := f.newObjectWithInfo(remote+"."+extension, item); o != nil {
|
||||||
obj := o.(*Object)
|
obj := o.(*Object)
|
||||||
obj.isDocument = true
|
obj.isDocument = true
|
||||||
obj.url = link
|
obj.url = link
|
||||||
@ -547,7 +547,7 @@ func (f *Fs) createFileInfo(remote string, modTime time.Time, size int64) (*Obje
|
|||||||
//
|
//
|
||||||
// The new object may have been created if an error is returned
|
// The new object may have been created if an error is returned
|
||||||
func (f *Fs) Put(in io.Reader, src fs.ObjectInfo) (fs.Object, error) {
|
func (f *Fs) Put(in io.Reader, src fs.ObjectInfo) (fs.Object, error) {
|
||||||
exisitingObj, err := f.newFsObjectWithInfoErr(src.Remote(), nil)
|
exisitingObj, err := f.newObjectWithInfoErr(src.Remote(), nil)
|
||||||
switch err {
|
switch err {
|
||||||
case nil:
|
case nil:
|
||||||
return exisitingObj, exisitingObj.Update(in, src)
|
return exisitingObj, exisitingObj.Update(in, src)
|
||||||
@ -726,7 +726,7 @@ func (f *Fs) Move(src fs.Object, remote string) (fs.Object, error) {
|
|||||||
return nil, errors.New("can't move a Google document")
|
return nil, errors.New("can't move a Google document")
|
||||||
}
|
}
|
||||||
|
|
||||||
// Temporary FsObject under construction
|
// Temporary Object under construction
|
||||||
dstObj, dstInfo, err := f.createFileInfo(remote, srcObj.ModTime(), srcObj.bytes)
|
dstObj, dstInfo, err := f.createFileInfo(remote, srcObj.ModTime(), srcObj.bytes)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
|
@ -25,7 +25,7 @@ func TestFsRmdirNotFound(t *testing.T) { fstests.TestFsRmdirNotFound(t) }
|
|||||||
func TestFsMkdir(t *testing.T) { fstests.TestFsMkdir(t) }
|
func TestFsMkdir(t *testing.T) { fstests.TestFsMkdir(t) }
|
||||||
func TestFsListEmpty(t *testing.T) { fstests.TestFsListEmpty(t) }
|
func TestFsListEmpty(t *testing.T) { fstests.TestFsListEmpty(t) }
|
||||||
func TestFsListDirEmpty(t *testing.T) { fstests.TestFsListDirEmpty(t) }
|
func TestFsListDirEmpty(t *testing.T) { fstests.TestFsListDirEmpty(t) }
|
||||||
func TestFsNewFsObjectNotFound(t *testing.T) { fstests.TestFsNewFsObjectNotFound(t) }
|
func TestFsNewObjectNotFound(t *testing.T) { fstests.TestFsNewObjectNotFound(t) }
|
||||||
func TestFsPutFile1(t *testing.T) { fstests.TestFsPutFile1(t) }
|
func TestFsPutFile1(t *testing.T) { fstests.TestFsPutFile1(t) }
|
||||||
func TestFsPutFile2(t *testing.T) { fstests.TestFsPutFile2(t) }
|
func TestFsPutFile2(t *testing.T) { fstests.TestFsPutFile2(t) }
|
||||||
func TestFsUpdateFile1(t *testing.T) { fstests.TestFsUpdateFile1(t) }
|
func TestFsUpdateFile1(t *testing.T) { fstests.TestFsUpdateFile1(t) }
|
||||||
@ -34,7 +34,7 @@ func TestFsListDirRoot(t *testing.T) { fstests.TestFsListDirRoot(t) }
|
|||||||
func TestFsListSubdir(t *testing.T) { fstests.TestFsListSubdir(t) }
|
func TestFsListSubdir(t *testing.T) { fstests.TestFsListSubdir(t) }
|
||||||
func TestFsListLevel2(t *testing.T) { fstests.TestFsListLevel2(t) }
|
func TestFsListLevel2(t *testing.T) { fstests.TestFsListLevel2(t) }
|
||||||
func TestFsListFile1(t *testing.T) { fstests.TestFsListFile1(t) }
|
func TestFsListFile1(t *testing.T) { fstests.TestFsListFile1(t) }
|
||||||
func TestFsNewFsObject(t *testing.T) { fstests.TestFsNewFsObject(t) }
|
func TestFsNewObject(t *testing.T) { fstests.TestFsNewObject(t) }
|
||||||
func TestFsListFile1and2(t *testing.T) { fstests.TestFsListFile1and2(t) }
|
func TestFsListFile1and2(t *testing.T) { fstests.TestFsListFile1and2(t) }
|
||||||
func TestFsCopy(t *testing.T) { fstests.TestFsCopy(t) }
|
func TestFsCopy(t *testing.T) { fstests.TestFsCopy(t) }
|
||||||
func TestFsMove(t *testing.T) { fstests.TestFsMove(t) }
|
func TestFsMove(t *testing.T) { fstests.TestFsMove(t) }
|
||||||
|
@ -196,10 +196,10 @@ func (f *Fs) setRoot(root string) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Return an FsObject from a path
|
// Return an Object from a path
|
||||||
//
|
//
|
||||||
// May return nil if an error occurred
|
// May return nil if an error occurred
|
||||||
func (f *Fs) newFsObjectWithInfo(remote string, info *dropbox.Entry) fs.Object {
|
func (f *Fs) newObjectWithInfo(remote string, info *dropbox.Entry) fs.Object {
|
||||||
o := &Object{
|
o := &Object{
|
||||||
fs: f,
|
fs: f,
|
||||||
remote: remote,
|
remote: remote,
|
||||||
@ -216,11 +216,11 @@ func (f *Fs) newFsObjectWithInfo(remote string, info *dropbox.Entry) fs.Object {
|
|||||||
return o
|
return o
|
||||||
}
|
}
|
||||||
|
|
||||||
// NewFsObject returns an FsObject from a path
|
// NewObject returns an Object from a path
|
||||||
//
|
//
|
||||||
// May return nil if an error occurred
|
// May return nil if an error occurred
|
||||||
func (f *Fs) NewFsObject(remote string) fs.Object {
|
func (f *Fs) NewObject(remote string) fs.Object {
|
||||||
return f.newFsObjectWithInfo(remote, nil)
|
return f.newObjectWithInfo(remote, nil)
|
||||||
}
|
}
|
||||||
|
|
||||||
// Strips the root off path and returns it
|
// Strips the root off path and returns it
|
||||||
@ -247,7 +247,7 @@ func (f *Fs) stripRoot(path string) (string, error) {
|
|||||||
return strip(path, f.slashRootSlash)
|
return strip(path, f.slashRootSlash)
|
||||||
}
|
}
|
||||||
|
|
||||||
// Walk the root returning a channel of FsObjects
|
// Walk the root returning a channel of Objects
|
||||||
func (f *Fs) list(out fs.ListOpts, dir string) {
|
func (f *Fs) list(out fs.ListOpts, dir string) {
|
||||||
// Track path component case, it could be different for entries coming from DropBox API
|
// Track path component case, it could be different for entries coming from DropBox API
|
||||||
// See https://www.dropboxforum.com/hc/communities/public/questions/201665409-Wrong-character-case-of-folder-name-when-calling-listFolder-using-Sync-API?locale=en-us
|
// See https://www.dropboxforum.com/hc/communities/public/questions/201665409-Wrong-character-case-of-folder-name-when-calling-listFolder-using-Sync-API?locale=en-us
|
||||||
@ -322,7 +322,7 @@ func (f *Fs) list(out fs.ListOpts, dir string) {
|
|||||||
out.SetError(err)
|
out.SetError(err)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
if o := f.newFsObjectWithInfo(path, entry); o != nil {
|
if o := f.newObjectWithInfo(path, entry); o != nil {
|
||||||
if out.Add(o) {
|
if out.Add(o) {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
@ -345,7 +345,7 @@ func (f *Fs) list(out fs.ListOpts, dir string) {
|
|||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
if o := f.newFsObjectWithInfo(path, entry); o != nil {
|
if o := f.newObjectWithInfo(path, entry); o != nil {
|
||||||
if out.Add(o) {
|
if out.Add(o) {
|
||||||
return fs.ErrorListAborted
|
return fs.ErrorListAborted
|
||||||
}
|
}
|
||||||
@ -387,7 +387,7 @@ func (f *Fs) listOneLevel(out fs.ListOpts, dir string) {
|
|||||||
return
|
return
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
if o := f.newFsObjectWithInfo(remote, entry); o != nil {
|
if o := f.newObjectWithInfo(remote, entry); o != nil {
|
||||||
if out.Add(o) {
|
if out.Add(o) {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
@ -396,7 +396,7 @@ func (f *Fs) listOneLevel(out fs.ListOpts, dir string) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// List walks the path returning a channel of FsObjects
|
// List walks the path returning a channel of Objects
|
||||||
func (f *Fs) List(out fs.ListOpts, dir string) {
|
func (f *Fs) List(out fs.ListOpts, dir string) {
|
||||||
defer out.Finished()
|
defer out.Finished()
|
||||||
level := out.Level()
|
level := out.Level()
|
||||||
|
@ -25,7 +25,7 @@ func TestFsRmdirNotFound(t *testing.T) { fstests.TestFsRmdirNotFound(t) }
|
|||||||
func TestFsMkdir(t *testing.T) { fstests.TestFsMkdir(t) }
|
func TestFsMkdir(t *testing.T) { fstests.TestFsMkdir(t) }
|
||||||
func TestFsListEmpty(t *testing.T) { fstests.TestFsListEmpty(t) }
|
func TestFsListEmpty(t *testing.T) { fstests.TestFsListEmpty(t) }
|
||||||
func TestFsListDirEmpty(t *testing.T) { fstests.TestFsListDirEmpty(t) }
|
func TestFsListDirEmpty(t *testing.T) { fstests.TestFsListDirEmpty(t) }
|
||||||
func TestFsNewFsObjectNotFound(t *testing.T) { fstests.TestFsNewFsObjectNotFound(t) }
|
func TestFsNewObjectNotFound(t *testing.T) { fstests.TestFsNewObjectNotFound(t) }
|
||||||
func TestFsPutFile1(t *testing.T) { fstests.TestFsPutFile1(t) }
|
func TestFsPutFile1(t *testing.T) { fstests.TestFsPutFile1(t) }
|
||||||
func TestFsPutFile2(t *testing.T) { fstests.TestFsPutFile2(t) }
|
func TestFsPutFile2(t *testing.T) { fstests.TestFsPutFile2(t) }
|
||||||
func TestFsUpdateFile1(t *testing.T) { fstests.TestFsUpdateFile1(t) }
|
func TestFsUpdateFile1(t *testing.T) { fstests.TestFsUpdateFile1(t) }
|
||||||
@ -34,7 +34,7 @@ func TestFsListDirRoot(t *testing.T) { fstests.TestFsListDirRoot(t) }
|
|||||||
func TestFsListSubdir(t *testing.T) { fstests.TestFsListSubdir(t) }
|
func TestFsListSubdir(t *testing.T) { fstests.TestFsListSubdir(t) }
|
||||||
func TestFsListLevel2(t *testing.T) { fstests.TestFsListLevel2(t) }
|
func TestFsListLevel2(t *testing.T) { fstests.TestFsListLevel2(t) }
|
||||||
func TestFsListFile1(t *testing.T) { fstests.TestFsListFile1(t) }
|
func TestFsListFile1(t *testing.T) { fstests.TestFsListFile1(t) }
|
||||||
func TestFsNewFsObject(t *testing.T) { fstests.TestFsNewFsObject(t) }
|
func TestFsNewObject(t *testing.T) { fstests.TestFsNewObject(t) }
|
||||||
func TestFsListFile1and2(t *testing.T) { fstests.TestFsListFile1and2(t) }
|
func TestFsListFile1and2(t *testing.T) { fstests.TestFsListFile1and2(t) }
|
||||||
func TestFsCopy(t *testing.T) { fstests.TestFsCopy(t) }
|
func TestFsCopy(t *testing.T) { fstests.TestFsCopy(t) }
|
||||||
func TestFsMove(t *testing.T) { fstests.TestFsMove(t) }
|
func TestFsMove(t *testing.T) { fstests.TestFsMove(t) }
|
||||||
|
4
fs/fs.go
4
fs/fs.go
@ -117,8 +117,8 @@ type Fs interface {
|
|||||||
Info
|
Info
|
||||||
ListFser
|
ListFser
|
||||||
|
|
||||||
// NewFsObject finds the Object at remote. Returns nil if can't be found
|
// NewObject finds the Object at remote. Returns nil if can't be found
|
||||||
NewFsObject(remote string) Object
|
NewObject(remote string) Object
|
||||||
|
|
||||||
// Put in to the remote path with the modTime given of the given size
|
// Put in to the remote path with the modTime given of the given size
|
||||||
//
|
//
|
||||||
|
@ -168,10 +168,10 @@ func TestFsListDirEmpty(t *testing.T) {
|
|||||||
assert.Equal(t, []string{}, dirsToNames(dirs))
|
assert.Equal(t, []string{}, dirsToNames(dirs))
|
||||||
}
|
}
|
||||||
|
|
||||||
// TestFsNewFsObjectNotFound tests not finding a object
|
// TestFsNewObjectNotFound tests not finding a object
|
||||||
func TestFsNewFsObjectNotFound(t *testing.T) {
|
func TestFsNewObjectNotFound(t *testing.T) {
|
||||||
skipIfNotOk(t)
|
skipIfNotOk(t)
|
||||||
if remote.NewFsObject("potato") != nil {
|
if remote.NewObject("potato") != nil {
|
||||||
t.Fatal("Didn't expect to find object")
|
t.Fatal("Didn't expect to find object")
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -179,7 +179,7 @@ func TestFsNewFsObjectNotFound(t *testing.T) {
|
|||||||
func findObject(t *testing.T, Name string) fs.Object {
|
func findObject(t *testing.T, Name string) fs.Object {
|
||||||
var obj fs.Object
|
var obj fs.Object
|
||||||
for i := 1; i <= eventualConsistencyRetries; i++ {
|
for i := 1; i <= eventualConsistencyRetries; i++ {
|
||||||
obj = remote.NewFsObject(Name)
|
obj = remote.NewObject(Name)
|
||||||
if obj != nil {
|
if obj != nil {
|
||||||
break
|
break
|
||||||
}
|
}
|
||||||
@ -304,8 +304,8 @@ func TestFsListFile1(t *testing.T) {
|
|||||||
fstest.CheckListing(t, remote, []fstest.Item{file1, file2})
|
fstest.CheckListing(t, remote, []fstest.Item{file1, file2})
|
||||||
}
|
}
|
||||||
|
|
||||||
// TestFsNewFsObject tests NewFsObject
|
// TestFsNewObject tests NewObject
|
||||||
func TestFsNewFsObject(t *testing.T) {
|
func TestFsNewObject(t *testing.T) {
|
||||||
skipIfNotOk(t)
|
skipIfNotOk(t)
|
||||||
obj := findObject(t, file1.Path)
|
obj := findObject(t, file1.Path)
|
||||||
file1.Check(t, obj, remote.Precision())
|
file1.Check(t, obj, remote.Precision())
|
||||||
|
@ -265,10 +265,10 @@ func NewFs(name, root string) (fs.Fs, error) {
|
|||||||
return f, nil
|
return f, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
// Return an FsObject from a path
|
// Return an Object from a path
|
||||||
//
|
//
|
||||||
// May return nil if an error occurred
|
// May return nil if an error occurred
|
||||||
func (f *Fs) newFsObjectWithInfo(remote string, info *storage.Object) fs.Object {
|
func (f *Fs) newObjectWithInfo(remote string, info *storage.Object) fs.Object {
|
||||||
o := &Object{
|
o := &Object{
|
||||||
fs: f,
|
fs: f,
|
||||||
remote: remote,
|
remote: remote,
|
||||||
@ -285,11 +285,11 @@ func (f *Fs) newFsObjectWithInfo(remote string, info *storage.Object) fs.Object
|
|||||||
return o
|
return o
|
||||||
}
|
}
|
||||||
|
|
||||||
// NewFsObject returns an FsObject from a path
|
// NewObject returns an Object from a path
|
||||||
//
|
//
|
||||||
// May return nil if an error occurred
|
// May return nil if an error occurred
|
||||||
func (f *Fs) NewFsObject(remote string) fs.Object {
|
func (f *Fs) NewObject(remote string) fs.Object {
|
||||||
return f.newFsObjectWithInfo(remote, nil)
|
return f.newObjectWithInfo(remote, nil)
|
||||||
}
|
}
|
||||||
|
|
||||||
// listFn is called from list to handle an object.
|
// listFn is called from list to handle an object.
|
||||||
@ -369,7 +369,7 @@ func (f *Fs) listFiles(out fs.ListOpts, dir string) {
|
|||||||
return fs.ErrorListAborted
|
return fs.ErrorListAborted
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
if o := f.newFsObjectWithInfo(remote, object); o != nil {
|
if o := f.newObjectWithInfo(remote, object); o != nil {
|
||||||
if out.Add(o) {
|
if out.Add(o) {
|
||||||
return fs.ErrorListAborted
|
return fs.ErrorListAborted
|
||||||
}
|
}
|
||||||
|
@ -25,7 +25,7 @@ func TestFsRmdirNotFound(t *testing.T) { fstests.TestFsRmdirNotFound(t) }
|
|||||||
func TestFsMkdir(t *testing.T) { fstests.TestFsMkdir(t) }
|
func TestFsMkdir(t *testing.T) { fstests.TestFsMkdir(t) }
|
||||||
func TestFsListEmpty(t *testing.T) { fstests.TestFsListEmpty(t) }
|
func TestFsListEmpty(t *testing.T) { fstests.TestFsListEmpty(t) }
|
||||||
func TestFsListDirEmpty(t *testing.T) { fstests.TestFsListDirEmpty(t) }
|
func TestFsListDirEmpty(t *testing.T) { fstests.TestFsListDirEmpty(t) }
|
||||||
func TestFsNewFsObjectNotFound(t *testing.T) { fstests.TestFsNewFsObjectNotFound(t) }
|
func TestFsNewObjectNotFound(t *testing.T) { fstests.TestFsNewObjectNotFound(t) }
|
||||||
func TestFsPutFile1(t *testing.T) { fstests.TestFsPutFile1(t) }
|
func TestFsPutFile1(t *testing.T) { fstests.TestFsPutFile1(t) }
|
||||||
func TestFsPutFile2(t *testing.T) { fstests.TestFsPutFile2(t) }
|
func TestFsPutFile2(t *testing.T) { fstests.TestFsPutFile2(t) }
|
||||||
func TestFsUpdateFile1(t *testing.T) { fstests.TestFsUpdateFile1(t) }
|
func TestFsUpdateFile1(t *testing.T) { fstests.TestFsUpdateFile1(t) }
|
||||||
@ -34,7 +34,7 @@ func TestFsListDirRoot(t *testing.T) { fstests.TestFsListDirRoot(t) }
|
|||||||
func TestFsListSubdir(t *testing.T) { fstests.TestFsListSubdir(t) }
|
func TestFsListSubdir(t *testing.T) { fstests.TestFsListSubdir(t) }
|
||||||
func TestFsListLevel2(t *testing.T) { fstests.TestFsListLevel2(t) }
|
func TestFsListLevel2(t *testing.T) { fstests.TestFsListLevel2(t) }
|
||||||
func TestFsListFile1(t *testing.T) { fstests.TestFsListFile1(t) }
|
func TestFsListFile1(t *testing.T) { fstests.TestFsListFile1(t) }
|
||||||
func TestFsNewFsObject(t *testing.T) { fstests.TestFsNewFsObject(t) }
|
func TestFsNewObject(t *testing.T) { fstests.TestFsNewObject(t) }
|
||||||
func TestFsListFile1and2(t *testing.T) { fstests.TestFsListFile1and2(t) }
|
func TestFsListFile1and2(t *testing.T) { fstests.TestFsListFile1and2(t) }
|
||||||
func TestFsCopy(t *testing.T) { fstests.TestFsCopy(t) }
|
func TestFsCopy(t *testing.T) { fstests.TestFsCopy(t) }
|
||||||
func TestFsMove(t *testing.T) { fstests.TestFsMove(t) }
|
func TestFsMove(t *testing.T) { fstests.TestFsMove(t) }
|
||||||
|
@ -25,7 +25,7 @@ func TestFsRmdirNotFound(t *testing.T) { fstests.TestFsRmdirNotFound(t) }
|
|||||||
func TestFsMkdir(t *testing.T) { fstests.TestFsMkdir(t) }
|
func TestFsMkdir(t *testing.T) { fstests.TestFsMkdir(t) }
|
||||||
func TestFsListEmpty(t *testing.T) { fstests.TestFsListEmpty(t) }
|
func TestFsListEmpty(t *testing.T) { fstests.TestFsListEmpty(t) }
|
||||||
func TestFsListDirEmpty(t *testing.T) { fstests.TestFsListDirEmpty(t) }
|
func TestFsListDirEmpty(t *testing.T) { fstests.TestFsListDirEmpty(t) }
|
||||||
func TestFsNewFsObjectNotFound(t *testing.T) { fstests.TestFsNewFsObjectNotFound(t) }
|
func TestFsNewObjectNotFound(t *testing.T) { fstests.TestFsNewObjectNotFound(t) }
|
||||||
func TestFsPutFile1(t *testing.T) { fstests.TestFsPutFile1(t) }
|
func TestFsPutFile1(t *testing.T) { fstests.TestFsPutFile1(t) }
|
||||||
func TestFsPutFile2(t *testing.T) { fstests.TestFsPutFile2(t) }
|
func TestFsPutFile2(t *testing.T) { fstests.TestFsPutFile2(t) }
|
||||||
func TestFsUpdateFile1(t *testing.T) { fstests.TestFsUpdateFile1(t) }
|
func TestFsUpdateFile1(t *testing.T) { fstests.TestFsUpdateFile1(t) }
|
||||||
@ -34,7 +34,7 @@ func TestFsListDirRoot(t *testing.T) { fstests.TestFsListDirRoot(t) }
|
|||||||
func TestFsListSubdir(t *testing.T) { fstests.TestFsListSubdir(t) }
|
func TestFsListSubdir(t *testing.T) { fstests.TestFsListSubdir(t) }
|
||||||
func TestFsListLevel2(t *testing.T) { fstests.TestFsListLevel2(t) }
|
func TestFsListLevel2(t *testing.T) { fstests.TestFsListLevel2(t) }
|
||||||
func TestFsListFile1(t *testing.T) { fstests.TestFsListFile1(t) }
|
func TestFsListFile1(t *testing.T) { fstests.TestFsListFile1(t) }
|
||||||
func TestFsNewFsObject(t *testing.T) { fstests.TestFsNewFsObject(t) }
|
func TestFsNewObject(t *testing.T) { fstests.TestFsNewObject(t) }
|
||||||
func TestFsListFile1and2(t *testing.T) { fstests.TestFsListFile1and2(t) }
|
func TestFsListFile1and2(t *testing.T) { fstests.TestFsListFile1and2(t) }
|
||||||
func TestFsCopy(t *testing.T) { fstests.TestFsCopy(t) }
|
func TestFsCopy(t *testing.T) { fstests.TestFsCopy(t) }
|
||||||
func TestFsMove(t *testing.T) { fstests.TestFsMove(t) }
|
func TestFsMove(t *testing.T) { fstests.TestFsMove(t) }
|
||||||
|
@ -78,7 +78,7 @@ func NewFs(name, root string) (fs.Fs, error) {
|
|||||||
// It is a file, so use the parent as the root
|
// It is a file, so use the parent as the root
|
||||||
var remote string
|
var remote string
|
||||||
f.root, remote = getDirFile(f.root)
|
f.root, remote = getDirFile(f.root)
|
||||||
obj := f.NewFsObject(remote)
|
obj := f.NewObject(remote)
|
||||||
if obj == nil {
|
if obj == nil {
|
||||||
return nil, errors.Errorf("failed to make object for %q in %q", remote, f.root)
|
return nil, errors.Errorf("failed to make object for %q in %q", remote, f.root)
|
||||||
}
|
}
|
||||||
@ -103,8 +103,8 @@ func (f *Fs) String() string {
|
|||||||
return fmt.Sprintf("Local file system at %s", f.root)
|
return fmt.Sprintf("Local file system at %s", f.root)
|
||||||
}
|
}
|
||||||
|
|
||||||
// newFsObject makes a half completed Object
|
// newObject makes a half completed Object
|
||||||
func (f *Fs) newFsObject(remote string) *Object {
|
func (f *Fs) newObject(remote string) *Object {
|
||||||
remote = normString(remote)
|
remote = normString(remote)
|
||||||
remote = filepath.ToSlash(remote)
|
remote = filepath.ToSlash(remote)
|
||||||
dstPath := f.filterPath(filepath.Join(f.root, f.cleanUtf8(remote)))
|
dstPath := f.filterPath(filepath.Join(f.root, f.cleanUtf8(remote)))
|
||||||
@ -115,11 +115,11 @@ func (f *Fs) newFsObject(remote string) *Object {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Return an FsObject from a path
|
// Return an Object from a path
|
||||||
//
|
//
|
||||||
// May return nil if an error occurred
|
// May return nil if an error occurred
|
||||||
func (f *Fs) newFsObjectWithInfo(remote string, info os.FileInfo) fs.Object {
|
func (f *Fs) newObjectWithInfo(remote string, info os.FileInfo) fs.Object {
|
||||||
o := f.newFsObject(remote)
|
o := f.newObject(remote)
|
||||||
if info != nil {
|
if info != nil {
|
||||||
o.info = info
|
o.info = info
|
||||||
} else {
|
} else {
|
||||||
@ -132,11 +132,11 @@ func (f *Fs) newFsObjectWithInfo(remote string, info os.FileInfo) fs.Object {
|
|||||||
return o
|
return o
|
||||||
}
|
}
|
||||||
|
|
||||||
// NewFsObject returns an FsObject from a path
|
// NewObject returns an Object from a path
|
||||||
//
|
//
|
||||||
// May return nil if an error occurred
|
// May return nil if an error occurred
|
||||||
func (f *Fs) NewFsObject(remote string) fs.Object {
|
func (f *Fs) NewObject(remote string) fs.Object {
|
||||||
return f.newFsObjectWithInfo(remote, nil)
|
return f.newObjectWithInfo(remote, nil)
|
||||||
}
|
}
|
||||||
|
|
||||||
// listArgs is the arguments that a new list takes
|
// listArgs is the arguments that a new list takes
|
||||||
@ -192,7 +192,7 @@ func (f *Fs) list(out fs.ListOpts, remote string, dirpath string, level int) (su
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
if fso := f.newFsObjectWithInfo(newRemote, fi); fso != nil {
|
if fso := f.newObjectWithInfo(newRemote, fi); fso != nil {
|
||||||
if fso.Storable() && out.Add(fso) {
|
if fso.Storable() && out.Add(fso) {
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
@ -272,11 +272,11 @@ func (f *Fs) cleanUtf8(name string) string {
|
|||||||
return name
|
return name
|
||||||
}
|
}
|
||||||
|
|
||||||
// Put the FsObject to the local filesystem
|
// Put the Object to the local filesystem
|
||||||
func (f *Fs) Put(in io.Reader, src fs.ObjectInfo) (fs.Object, error) {
|
func (f *Fs) Put(in io.Reader, src fs.ObjectInfo) (fs.Object, error) {
|
||||||
remote := src.Remote()
|
remote := src.Remote()
|
||||||
// Temporary FsObject under construction - info filled in by Update()
|
// Temporary Object under construction - info filled in by Update()
|
||||||
o := f.newFsObject(remote)
|
o := f.newObject(remote)
|
||||||
err := o.Update(in, src)
|
err := o.Update(in, src)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
@ -389,8 +389,8 @@ func (f *Fs) Move(src fs.Object, remote string) (fs.Object, error) {
|
|||||||
return nil, fs.ErrorCantMove
|
return nil, fs.ErrorCantMove
|
||||||
}
|
}
|
||||||
|
|
||||||
// Temporary FsObject under construction
|
// Temporary Object under construction
|
||||||
dstObj := f.newFsObject(remote)
|
dstObj := f.newObject(remote)
|
||||||
|
|
||||||
// Check it is a file if it exists
|
// Check it is a file if it exists
|
||||||
err := dstObj.lstat()
|
err := dstObj.lstat()
|
||||||
@ -636,7 +636,7 @@ func (o *Object) Update(in io.Reader, src fs.ObjectInfo) error {
|
|||||||
return o.lstat()
|
return o.lstat()
|
||||||
}
|
}
|
||||||
|
|
||||||
// Stat a FsObject into info
|
// Stat a Object into info
|
||||||
func (o *Object) lstat() error {
|
func (o *Object) lstat() error {
|
||||||
info, err := os.Lstat(o.path)
|
info, err := os.Lstat(o.path)
|
||||||
o.info = info
|
o.info = info
|
||||||
|
@ -25,7 +25,7 @@ func TestFsRmdirNotFound(t *testing.T) { fstests.TestFsRmdirNotFound(t) }
|
|||||||
func TestFsMkdir(t *testing.T) { fstests.TestFsMkdir(t) }
|
func TestFsMkdir(t *testing.T) { fstests.TestFsMkdir(t) }
|
||||||
func TestFsListEmpty(t *testing.T) { fstests.TestFsListEmpty(t) }
|
func TestFsListEmpty(t *testing.T) { fstests.TestFsListEmpty(t) }
|
||||||
func TestFsListDirEmpty(t *testing.T) { fstests.TestFsListDirEmpty(t) }
|
func TestFsListDirEmpty(t *testing.T) { fstests.TestFsListDirEmpty(t) }
|
||||||
func TestFsNewFsObjectNotFound(t *testing.T) { fstests.TestFsNewFsObjectNotFound(t) }
|
func TestFsNewObjectNotFound(t *testing.T) { fstests.TestFsNewObjectNotFound(t) }
|
||||||
func TestFsPutFile1(t *testing.T) { fstests.TestFsPutFile1(t) }
|
func TestFsPutFile1(t *testing.T) { fstests.TestFsPutFile1(t) }
|
||||||
func TestFsPutFile2(t *testing.T) { fstests.TestFsPutFile2(t) }
|
func TestFsPutFile2(t *testing.T) { fstests.TestFsPutFile2(t) }
|
||||||
func TestFsUpdateFile1(t *testing.T) { fstests.TestFsUpdateFile1(t) }
|
func TestFsUpdateFile1(t *testing.T) { fstests.TestFsUpdateFile1(t) }
|
||||||
@ -34,7 +34,7 @@ func TestFsListDirRoot(t *testing.T) { fstests.TestFsListDirRoot(t) }
|
|||||||
func TestFsListSubdir(t *testing.T) { fstests.TestFsListSubdir(t) }
|
func TestFsListSubdir(t *testing.T) { fstests.TestFsListSubdir(t) }
|
||||||
func TestFsListLevel2(t *testing.T) { fstests.TestFsListLevel2(t) }
|
func TestFsListLevel2(t *testing.T) { fstests.TestFsListLevel2(t) }
|
||||||
func TestFsListFile1(t *testing.T) { fstests.TestFsListFile1(t) }
|
func TestFsListFile1(t *testing.T) { fstests.TestFsListFile1(t) }
|
||||||
func TestFsNewFsObject(t *testing.T) { fstests.TestFsNewFsObject(t) }
|
func TestFsNewObject(t *testing.T) { fstests.TestFsNewObject(t) }
|
||||||
func TestFsListFile1and2(t *testing.T) { fstests.TestFsListFile1and2(t) }
|
func TestFsListFile1and2(t *testing.T) { fstests.TestFsListFile1and2(t) }
|
||||||
func TestFsCopy(t *testing.T) { fstests.TestFsCopy(t) }
|
func TestFsCopy(t *testing.T) { fstests.TestFsCopy(t) }
|
||||||
func TestFsMove(t *testing.T) { fstests.TestFsMove(t) }
|
func TestFsMove(t *testing.T) { fstests.TestFsMove(t) }
|
||||||
|
@ -246,10 +246,10 @@ func (f *Fs) newObjectWithInfo(remote string, info *api.Item) fs.Object {
|
|||||||
return o
|
return o
|
||||||
}
|
}
|
||||||
|
|
||||||
// NewFsObject returns an Object from a path
|
// NewObject returns an Object from a path
|
||||||
//
|
//
|
||||||
// May return nil if an error occurred
|
// May return nil if an error occurred
|
||||||
func (f *Fs) NewFsObject(remote string) fs.Object {
|
func (f *Fs) NewObject(remote string) fs.Object {
|
||||||
return f.newObjectWithInfo(remote, nil)
|
return f.newObjectWithInfo(remote, nil)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -25,7 +25,7 @@ func TestFsRmdirNotFound(t *testing.T) { fstests.TestFsRmdirNotFound(t) }
|
|||||||
func TestFsMkdir(t *testing.T) { fstests.TestFsMkdir(t) }
|
func TestFsMkdir(t *testing.T) { fstests.TestFsMkdir(t) }
|
||||||
func TestFsListEmpty(t *testing.T) { fstests.TestFsListEmpty(t) }
|
func TestFsListEmpty(t *testing.T) { fstests.TestFsListEmpty(t) }
|
||||||
func TestFsListDirEmpty(t *testing.T) { fstests.TestFsListDirEmpty(t) }
|
func TestFsListDirEmpty(t *testing.T) { fstests.TestFsListDirEmpty(t) }
|
||||||
func TestFsNewFsObjectNotFound(t *testing.T) { fstests.TestFsNewFsObjectNotFound(t) }
|
func TestFsNewObjectNotFound(t *testing.T) { fstests.TestFsNewObjectNotFound(t) }
|
||||||
func TestFsPutFile1(t *testing.T) { fstests.TestFsPutFile1(t) }
|
func TestFsPutFile1(t *testing.T) { fstests.TestFsPutFile1(t) }
|
||||||
func TestFsPutFile2(t *testing.T) { fstests.TestFsPutFile2(t) }
|
func TestFsPutFile2(t *testing.T) { fstests.TestFsPutFile2(t) }
|
||||||
func TestFsUpdateFile1(t *testing.T) { fstests.TestFsUpdateFile1(t) }
|
func TestFsUpdateFile1(t *testing.T) { fstests.TestFsUpdateFile1(t) }
|
||||||
@ -34,7 +34,7 @@ func TestFsListDirRoot(t *testing.T) { fstests.TestFsListDirRoot(t) }
|
|||||||
func TestFsListSubdir(t *testing.T) { fstests.TestFsListSubdir(t) }
|
func TestFsListSubdir(t *testing.T) { fstests.TestFsListSubdir(t) }
|
||||||
func TestFsListLevel2(t *testing.T) { fstests.TestFsListLevel2(t) }
|
func TestFsListLevel2(t *testing.T) { fstests.TestFsListLevel2(t) }
|
||||||
func TestFsListFile1(t *testing.T) { fstests.TestFsListFile1(t) }
|
func TestFsListFile1(t *testing.T) { fstests.TestFsListFile1(t) }
|
||||||
func TestFsNewFsObject(t *testing.T) { fstests.TestFsNewFsObject(t) }
|
func TestFsNewObject(t *testing.T) { fstests.TestFsNewObject(t) }
|
||||||
func TestFsListFile1and2(t *testing.T) { fstests.TestFsListFile1and2(t) }
|
func TestFsListFile1and2(t *testing.T) { fstests.TestFsListFile1and2(t) }
|
||||||
func TestFsCopy(t *testing.T) { fstests.TestFsCopy(t) }
|
func TestFsCopy(t *testing.T) { fstests.TestFsCopy(t) }
|
||||||
func TestFsMove(t *testing.T) { fstests.TestFsMove(t) }
|
func TestFsMove(t *testing.T) { fstests.TestFsMove(t) }
|
||||||
|
16
s3/s3.go
16
s3/s3.go
@ -340,10 +340,10 @@ func NewFs(name, root string) (fs.Fs, error) {
|
|||||||
return f, nil
|
return f, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
// Return an FsObject from a path
|
// Return an Object from a path
|
||||||
//
|
//
|
||||||
// May return nil if an error occurred
|
// May return nil if an error occurred
|
||||||
func (f *Fs) newFsObjectWithInfo(remote string, info *s3.Object) fs.Object {
|
func (f *Fs) newObjectWithInfo(remote string, info *s3.Object) fs.Object {
|
||||||
o := &Object{
|
o := &Object{
|
||||||
fs: f,
|
fs: f,
|
||||||
remote: remote,
|
remote: remote,
|
||||||
@ -368,11 +368,11 @@ func (f *Fs) newFsObjectWithInfo(remote string, info *s3.Object) fs.Object {
|
|||||||
return o
|
return o
|
||||||
}
|
}
|
||||||
|
|
||||||
// NewFsObject returns an FsObject from a path
|
// NewObject returns an Object from a path
|
||||||
//
|
//
|
||||||
// May return nil if an error occurred
|
// May return nil if an error occurred
|
||||||
func (f *Fs) NewFsObject(remote string) fs.Object {
|
func (f *Fs) NewObject(remote string) fs.Object {
|
||||||
return f.newFsObjectWithInfo(remote, nil)
|
return f.newObjectWithInfo(remote, nil)
|
||||||
}
|
}
|
||||||
|
|
||||||
// listFn is called from list to handle an object.
|
// listFn is called from list to handle an object.
|
||||||
@ -482,7 +482,7 @@ func (f *Fs) listFiles(out fs.ListOpts, dir string) {
|
|||||||
return fs.ErrorListAborted
|
return fs.ErrorListAborted
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
if o := f.newFsObjectWithInfo(remote, object); o != nil {
|
if o := f.newObjectWithInfo(remote, object); o != nil {
|
||||||
if out.Add(o) {
|
if out.Add(o) {
|
||||||
return fs.ErrorListAborted
|
return fs.ErrorListAborted
|
||||||
}
|
}
|
||||||
@ -536,7 +536,7 @@ func (f *Fs) List(out fs.ListOpts, dir string) {
|
|||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
// Put the FsObject into the bucket
|
// Put the Object into the bucket
|
||||||
func (f *Fs) Put(in io.Reader, src fs.ObjectInfo) (fs.Object, error) {
|
func (f *Fs) Put(in io.Reader, src fs.ObjectInfo) (fs.Object, error) {
|
||||||
// Temporary Object under construction
|
// Temporary Object under construction
|
||||||
fs := &Object{
|
fs := &Object{
|
||||||
@ -634,7 +634,7 @@ func (f *Fs) Copy(src fs.Object, remote string) (fs.Object, error) {
|
|||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
return f.NewFsObject(remote), err
|
return f.NewObject(remote), err
|
||||||
}
|
}
|
||||||
|
|
||||||
// Hashes returns the supported hash sets.
|
// Hashes returns the supported hash sets.
|
||||||
|
@ -25,7 +25,7 @@ func TestFsRmdirNotFound(t *testing.T) { fstests.TestFsRmdirNotFound(t) }
|
|||||||
func TestFsMkdir(t *testing.T) { fstests.TestFsMkdir(t) }
|
func TestFsMkdir(t *testing.T) { fstests.TestFsMkdir(t) }
|
||||||
func TestFsListEmpty(t *testing.T) { fstests.TestFsListEmpty(t) }
|
func TestFsListEmpty(t *testing.T) { fstests.TestFsListEmpty(t) }
|
||||||
func TestFsListDirEmpty(t *testing.T) { fstests.TestFsListDirEmpty(t) }
|
func TestFsListDirEmpty(t *testing.T) { fstests.TestFsListDirEmpty(t) }
|
||||||
func TestFsNewFsObjectNotFound(t *testing.T) { fstests.TestFsNewFsObjectNotFound(t) }
|
func TestFsNewObjectNotFound(t *testing.T) { fstests.TestFsNewObjectNotFound(t) }
|
||||||
func TestFsPutFile1(t *testing.T) { fstests.TestFsPutFile1(t) }
|
func TestFsPutFile1(t *testing.T) { fstests.TestFsPutFile1(t) }
|
||||||
func TestFsPutFile2(t *testing.T) { fstests.TestFsPutFile2(t) }
|
func TestFsPutFile2(t *testing.T) { fstests.TestFsPutFile2(t) }
|
||||||
func TestFsUpdateFile1(t *testing.T) { fstests.TestFsUpdateFile1(t) }
|
func TestFsUpdateFile1(t *testing.T) { fstests.TestFsUpdateFile1(t) }
|
||||||
@ -34,7 +34,7 @@ func TestFsListDirRoot(t *testing.T) { fstests.TestFsListDirRoot(t) }
|
|||||||
func TestFsListSubdir(t *testing.T) { fstests.TestFsListSubdir(t) }
|
func TestFsListSubdir(t *testing.T) { fstests.TestFsListSubdir(t) }
|
||||||
func TestFsListLevel2(t *testing.T) { fstests.TestFsListLevel2(t) }
|
func TestFsListLevel2(t *testing.T) { fstests.TestFsListLevel2(t) }
|
||||||
func TestFsListFile1(t *testing.T) { fstests.TestFsListFile1(t) }
|
func TestFsListFile1(t *testing.T) { fstests.TestFsListFile1(t) }
|
||||||
func TestFsNewFsObject(t *testing.T) { fstests.TestFsNewFsObject(t) }
|
func TestFsNewObject(t *testing.T) { fstests.TestFsNewObject(t) }
|
||||||
func TestFsListFile1and2(t *testing.T) { fstests.TestFsListFile1and2(t) }
|
func TestFsListFile1and2(t *testing.T) { fstests.TestFsListFile1and2(t) }
|
||||||
func TestFsCopy(t *testing.T) { fstests.TestFsCopy(t) }
|
func TestFsCopy(t *testing.T) { fstests.TestFsCopy(t) }
|
||||||
func TestFsMove(t *testing.T) { fstests.TestFsMove(t) }
|
func TestFsMove(t *testing.T) { fstests.TestFsMove(t) }
|
||||||
|
@ -221,10 +221,10 @@ func NewFs(name, root string) (fs.Fs, error) {
|
|||||||
return NewFsWithConnection(name, root, c)
|
return NewFsWithConnection(name, root, c)
|
||||||
}
|
}
|
||||||
|
|
||||||
// Return an FsObject from a path
|
// Return an Object from a path
|
||||||
//
|
//
|
||||||
// May return nil if an error occurred
|
// May return nil if an error occurred
|
||||||
func (f *Fs) newFsObjectWithInfo(remote string, info *swift.Object) fs.Object {
|
func (f *Fs) newObjectWithInfo(remote string, info *swift.Object) fs.Object {
|
||||||
o := &Object{
|
o := &Object{
|
||||||
fs: f,
|
fs: f,
|
||||||
remote: remote,
|
remote: remote,
|
||||||
@ -248,11 +248,11 @@ func (f *Fs) newFsObjectWithInfo(remote string, info *swift.Object) fs.Object {
|
|||||||
return o
|
return o
|
||||||
}
|
}
|
||||||
|
|
||||||
// NewFsObject returns an FsObject from a path
|
// NewObject returns an Object from a path
|
||||||
//
|
//
|
||||||
// May return nil if an error occurred
|
// May return nil if an error occurred
|
||||||
func (f *Fs) NewFsObject(remote string) fs.Object {
|
func (f *Fs) NewObject(remote string) fs.Object {
|
||||||
return f.newFsObjectWithInfo(remote, nil)
|
return f.newObjectWithInfo(remote, nil)
|
||||||
}
|
}
|
||||||
|
|
||||||
// listFn is called from list and listContainerRoot to handle an object.
|
// listFn is called from list and listContainerRoot to handle an object.
|
||||||
@ -312,7 +312,7 @@ func (f *Fs) list(dir string, level int, fn listFn) error {
|
|||||||
return f.listContainerRoot(f.container, f.root, dir, level, fn)
|
return f.listContainerRoot(f.container, f.root, dir, level, fn)
|
||||||
}
|
}
|
||||||
|
|
||||||
// listFiles walks the path returning a channel of FsObjects
|
// listFiles walks the path returning a channel of Objects
|
||||||
func (f *Fs) listFiles(out fs.ListOpts, dir string) {
|
func (f *Fs) listFiles(out fs.ListOpts, dir string) {
|
||||||
defer out.Finished()
|
defer out.Finished()
|
||||||
if f.container == "" {
|
if f.container == "" {
|
||||||
@ -331,7 +331,7 @@ func (f *Fs) listFiles(out fs.ListOpts, dir string) {
|
|||||||
return fs.ErrorListAborted
|
return fs.ErrorListAborted
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
if o := f.newFsObjectWithInfo(remote, object); o != nil {
|
if o := f.newObjectWithInfo(remote, object); o != nil {
|
||||||
// Storable does a full metadata read on 0 size objects which might be dynamic large objects
|
// Storable does a full metadata read on 0 size objects which might be dynamic large objects
|
||||||
if o.Storable() {
|
if o.Storable() {
|
||||||
if out.Add(o) {
|
if out.Add(o) {
|
||||||
@ -437,7 +437,7 @@ func (f *Fs) Purge() error {
|
|||||||
go func() {
|
go func() {
|
||||||
err = f.list("", fs.MaxLevel, func(remote string, object *swift.Object, isDirectory bool) error {
|
err = f.list("", fs.MaxLevel, func(remote string, object *swift.Object, isDirectory bool) error {
|
||||||
if !isDirectory {
|
if !isDirectory {
|
||||||
if o := f.newFsObjectWithInfo(remote, object); o != nil {
|
if o := f.newObjectWithInfo(remote, object); o != nil {
|
||||||
toBeDeleted <- o
|
toBeDeleted <- o
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -472,7 +472,7 @@ func (f *Fs) Copy(src fs.Object, remote string) (fs.Object, error) {
|
|||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
return f.NewFsObject(remote), nil
|
return f.NewObject(remote), nil
|
||||||
}
|
}
|
||||||
|
|
||||||
// Hashes returns the supported hash sets.
|
// Hashes returns the supported hash sets.
|
||||||
|
@ -25,7 +25,7 @@ func TestFsRmdirNotFound(t *testing.T) { fstests.TestFsRmdirNotFound(t) }
|
|||||||
func TestFsMkdir(t *testing.T) { fstests.TestFsMkdir(t) }
|
func TestFsMkdir(t *testing.T) { fstests.TestFsMkdir(t) }
|
||||||
func TestFsListEmpty(t *testing.T) { fstests.TestFsListEmpty(t) }
|
func TestFsListEmpty(t *testing.T) { fstests.TestFsListEmpty(t) }
|
||||||
func TestFsListDirEmpty(t *testing.T) { fstests.TestFsListDirEmpty(t) }
|
func TestFsListDirEmpty(t *testing.T) { fstests.TestFsListDirEmpty(t) }
|
||||||
func TestFsNewFsObjectNotFound(t *testing.T) { fstests.TestFsNewFsObjectNotFound(t) }
|
func TestFsNewObjectNotFound(t *testing.T) { fstests.TestFsNewObjectNotFound(t) }
|
||||||
func TestFsPutFile1(t *testing.T) { fstests.TestFsPutFile1(t) }
|
func TestFsPutFile1(t *testing.T) { fstests.TestFsPutFile1(t) }
|
||||||
func TestFsPutFile2(t *testing.T) { fstests.TestFsPutFile2(t) }
|
func TestFsPutFile2(t *testing.T) { fstests.TestFsPutFile2(t) }
|
||||||
func TestFsUpdateFile1(t *testing.T) { fstests.TestFsUpdateFile1(t) }
|
func TestFsUpdateFile1(t *testing.T) { fstests.TestFsUpdateFile1(t) }
|
||||||
@ -34,7 +34,7 @@ func TestFsListDirRoot(t *testing.T) { fstests.TestFsListDirRoot(t) }
|
|||||||
func TestFsListSubdir(t *testing.T) { fstests.TestFsListSubdir(t) }
|
func TestFsListSubdir(t *testing.T) { fstests.TestFsListSubdir(t) }
|
||||||
func TestFsListLevel2(t *testing.T) { fstests.TestFsListLevel2(t) }
|
func TestFsListLevel2(t *testing.T) { fstests.TestFsListLevel2(t) }
|
||||||
func TestFsListFile1(t *testing.T) { fstests.TestFsListFile1(t) }
|
func TestFsListFile1(t *testing.T) { fstests.TestFsListFile1(t) }
|
||||||
func TestFsNewFsObject(t *testing.T) { fstests.TestFsNewFsObject(t) }
|
func TestFsNewObject(t *testing.T) { fstests.TestFsNewObject(t) }
|
||||||
func TestFsListFile1and2(t *testing.T) { fstests.TestFsListFile1and2(t) }
|
func TestFsListFile1and2(t *testing.T) { fstests.TestFsListFile1and2(t) }
|
||||||
func TestFsCopy(t *testing.T) { fstests.TestFsCopy(t) }
|
func TestFsCopy(t *testing.T) { fstests.TestFsCopy(t) }
|
||||||
func TestFsMove(t *testing.T) { fstests.TestFsMove(t) }
|
func TestFsMove(t *testing.T) { fstests.TestFsMove(t) }
|
||||||
|
@ -243,7 +243,7 @@ func (f *Fs) list(dir string, fn listFn) error {
|
|||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
// List walks the path returning a channel of FsObjects
|
// List walks the path returning a channel of Objects
|
||||||
func (f *Fs) List(out fs.ListOpts, dir string) {
|
func (f *Fs) List(out fs.ListOpts, dir string) {
|
||||||
defer out.Finished()
|
defer out.Finished()
|
||||||
|
|
||||||
@ -263,7 +263,7 @@ func (f *Fs) List(out fs.ListOpts, dir string) {
|
|||||||
return fs.ErrorListAborted
|
return fs.ErrorListAborted
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
if o := f.newFsObjectWithInfo(remote, object); o != nil {
|
if o := f.newObjectWithInfo(remote, object); o != nil {
|
||||||
if out.Add(o) {
|
if out.Add(o) {
|
||||||
return fs.ErrorListAborted
|
return fs.ErrorListAborted
|
||||||
}
|
}
|
||||||
@ -295,17 +295,17 @@ func (f *Fs) List(out fs.ListOpts, dir string) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// NewFsObject returns an Object from a path
|
// NewObject returns an Object from a path
|
||||||
//
|
//
|
||||||
// May return nil if an error occurred
|
// May return nil if an error occurred
|
||||||
func (f *Fs) NewFsObject(remote string) fs.Object {
|
func (f *Fs) NewObject(remote string) fs.Object {
|
||||||
return f.newFsObjectWithInfo(remote, nil)
|
return f.newObjectWithInfo(remote, nil)
|
||||||
}
|
}
|
||||||
|
|
||||||
// Return an FsObject from a path
|
// Return an Object from a path
|
||||||
//
|
//
|
||||||
// May return nil if an error occurred
|
// May return nil if an error occurred
|
||||||
func (f *Fs) newFsObjectWithInfo(remote string, info *yandex.ResourceInfoResponse) fs.Object {
|
func (f *Fs) newObjectWithInfo(remote string, info *yandex.ResourceInfoResponse) fs.Object {
|
||||||
o := &Object{
|
o := &Object{
|
||||||
fs: f,
|
fs: f,
|
||||||
remote: remote,
|
remote: remote,
|
||||||
|
@ -25,7 +25,7 @@ func TestFsRmdirNotFound(t *testing.T) { fstests.TestFsRmdirNotFound(t) }
|
|||||||
func TestFsMkdir(t *testing.T) { fstests.TestFsMkdir(t) }
|
func TestFsMkdir(t *testing.T) { fstests.TestFsMkdir(t) }
|
||||||
func TestFsListEmpty(t *testing.T) { fstests.TestFsListEmpty(t) }
|
func TestFsListEmpty(t *testing.T) { fstests.TestFsListEmpty(t) }
|
||||||
func TestFsListDirEmpty(t *testing.T) { fstests.TestFsListDirEmpty(t) }
|
func TestFsListDirEmpty(t *testing.T) { fstests.TestFsListDirEmpty(t) }
|
||||||
func TestFsNewFsObjectNotFound(t *testing.T) { fstests.TestFsNewFsObjectNotFound(t) }
|
func TestFsNewObjectNotFound(t *testing.T) { fstests.TestFsNewObjectNotFound(t) }
|
||||||
func TestFsPutFile1(t *testing.T) { fstests.TestFsPutFile1(t) }
|
func TestFsPutFile1(t *testing.T) { fstests.TestFsPutFile1(t) }
|
||||||
func TestFsPutFile2(t *testing.T) { fstests.TestFsPutFile2(t) }
|
func TestFsPutFile2(t *testing.T) { fstests.TestFsPutFile2(t) }
|
||||||
func TestFsUpdateFile1(t *testing.T) { fstests.TestFsUpdateFile1(t) }
|
func TestFsUpdateFile1(t *testing.T) { fstests.TestFsUpdateFile1(t) }
|
||||||
@ -34,7 +34,7 @@ func TestFsListDirRoot(t *testing.T) { fstests.TestFsListDirRoot(t) }
|
|||||||
func TestFsListSubdir(t *testing.T) { fstests.TestFsListSubdir(t) }
|
func TestFsListSubdir(t *testing.T) { fstests.TestFsListSubdir(t) }
|
||||||
func TestFsListLevel2(t *testing.T) { fstests.TestFsListLevel2(t) }
|
func TestFsListLevel2(t *testing.T) { fstests.TestFsListLevel2(t) }
|
||||||
func TestFsListFile1(t *testing.T) { fstests.TestFsListFile1(t) }
|
func TestFsListFile1(t *testing.T) { fstests.TestFsListFile1(t) }
|
||||||
func TestFsNewFsObject(t *testing.T) { fstests.TestFsNewFsObject(t) }
|
func TestFsNewObject(t *testing.T) { fstests.TestFsNewObject(t) }
|
||||||
func TestFsListFile1and2(t *testing.T) { fstests.TestFsListFile1and2(t) }
|
func TestFsListFile1and2(t *testing.T) { fstests.TestFsListFile1and2(t) }
|
||||||
func TestFsCopy(t *testing.T) { fstests.TestFsCopy(t) }
|
func TestFsCopy(t *testing.T) { fstests.TestFsCopy(t) }
|
||||||
func TestFsMove(t *testing.T) { fstests.TestFsMove(t) }
|
func TestFsMove(t *testing.T) { fstests.TestFsMove(t) }
|
||||||
|
Loading…
Reference in New Issue
Block a user