mirror of
https://github.com/rclone/rclone.git
synced 2024-11-25 17:57:44 +08:00
fs: rename BasicInfo to DirEntry
This commit is contained in:
parent
e7e9aa0dfa
commit
e2d7d413ef
4
b2/b2.go
4
b2/b2.go
|
@ -518,8 +518,8 @@ func (f *Fs) list(dir string, recurse bool, prefix string, limit int, hidden boo
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
// Convert a list item into a BasicInfo
|
// Convert a list item into a DirEntry
|
||||||
func (f *Fs) itemToDirEntry(remote string, object *api.File, isDirectory bool, last *string) (fs.BasicInfo, error) {
|
func (f *Fs) itemToDirEntry(remote string, object *api.File, isDirectory bool, last *string) (fs.DirEntry, error) {
|
||||||
if isDirectory {
|
if isDirectory {
|
||||||
d := &fs.Dir{
|
d := &fs.Dir{
|
||||||
Name: remote,
|
Name: remote,
|
||||||
|
|
|
@ -21,7 +21,7 @@ import (
|
||||||
//
|
//
|
||||||
// node may be nil, but o may not
|
// node may be nil, but o may not
|
||||||
type DirEntry struct {
|
type DirEntry struct {
|
||||||
o fs.BasicInfo
|
o fs.DirEntry
|
||||||
node fusefs.Node
|
node fusefs.Node
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -16,7 +16,7 @@ import (
|
||||||
//
|
//
|
||||||
// node may be nil, but o may not
|
// node may be nil, but o may not
|
||||||
type DirEntry struct {
|
type DirEntry struct {
|
||||||
Obj fs.BasicInfo
|
Obj fs.DirEntry
|
||||||
Node Node
|
Node Node
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -123,7 +123,7 @@ func (d *Dir) rename(newParent *Dir, fsDir *fs.Dir) {
|
||||||
// addObject adds a new object or directory to the directory
|
// addObject adds a new object or directory to the directory
|
||||||
//
|
//
|
||||||
// note that we add new objects rather than updating old ones
|
// note that we add new objects rather than updating old ones
|
||||||
func (d *Dir) addObject(o fs.BasicInfo, node Node) *DirEntry {
|
func (d *Dir) addObject(o fs.DirEntry, node Node) *DirEntry {
|
||||||
item := &DirEntry{
|
item := &DirEntry{
|
||||||
Obj: o,
|
Obj: o,
|
||||||
Node: node,
|
Node: node,
|
||||||
|
@ -414,7 +414,7 @@ func (d *Dir) Rename(oldName, newName string, destDir *Dir) error {
|
||||||
fs.Errorf(oldPath, "Dir.Rename error: %v", err)
|
fs.Errorf(oldPath, "Dir.Rename error: %v", err)
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
var newObj fs.BasicInfo
|
var newObj fs.DirEntry
|
||||||
oldNode := oldItem.Node
|
oldNode := oldItem.Node
|
||||||
switch x := oldItem.Obj.(type) {
|
switch x := oldItem.Obj.(type) {
|
||||||
case fs.Object:
|
case fs.Object:
|
||||||
|
|
14
fs/fs.go
14
fs/fs.go
|
@ -178,7 +178,7 @@ type Object interface {
|
||||||
|
|
||||||
// ObjectInfo provides read only information about an object.
|
// ObjectInfo provides read only information about an object.
|
||||||
type ObjectInfo interface {
|
type ObjectInfo interface {
|
||||||
BasicInfo
|
DirEntry
|
||||||
|
|
||||||
// Fs returns read only access to the Fs that this object is part of
|
// Fs returns read only access to the Fs that this object is part of
|
||||||
Fs() Info
|
Fs() Info
|
||||||
|
@ -191,9 +191,10 @@ type ObjectInfo interface {
|
||||||
Storable() bool
|
Storable() bool
|
||||||
}
|
}
|
||||||
|
|
||||||
// BasicInfo provides read only information about the common subset of
|
// DirEntry provides read only information about the common subset of
|
||||||
// a Dir or Object.
|
// a Dir or Object. These are returned from directory listings - type
|
||||||
type BasicInfo interface {
|
// assert them into the correct type.
|
||||||
|
type DirEntry interface {
|
||||||
// String returns a description of the Object
|
// String returns a description of the Object
|
||||||
String() string
|
String() string
|
||||||
|
|
||||||
|
@ -576,10 +577,7 @@ func (d *Dir) Size() int64 {
|
||||||
}
|
}
|
||||||
|
|
||||||
// Check interface
|
// Check interface
|
||||||
var _ BasicInfo = (*Dir)(nil)
|
var _ DirEntry = (*Dir)(nil)
|
||||||
|
|
||||||
// DirChan is a channel of Dir objects
|
|
||||||
type DirChan chan *Dir
|
|
||||||
|
|
||||||
// Find looks for an Info object for the name passed in
|
// Find looks for an Info object for the name passed in
|
||||||
//
|
//
|
||||||
|
|
|
@ -525,7 +525,7 @@ func readFilesFn(fs Fs, includeAll bool, dir string, add func(Object) error) (er
|
||||||
}
|
}
|
||||||
|
|
||||||
// DirEntries is a slice of Object or *Dir
|
// DirEntries is a slice of Object or *Dir
|
||||||
type DirEntries []BasicInfo
|
type DirEntries []DirEntry
|
||||||
|
|
||||||
// Len is part of sort.Interface.
|
// Len is part of sort.Interface.
|
||||||
func (ds DirEntries) Len() int {
|
func (ds DirEntries) Len() int {
|
||||||
|
|
|
@ -952,7 +952,7 @@ func TestListDirSorted(t *testing.T) {
|
||||||
var items fs.DirEntries
|
var items fs.DirEntries
|
||||||
var err error
|
var err error
|
||||||
|
|
||||||
// Turn the BasicInfo into a name, ending with a / if it is a
|
// Turn the DirEntry into a name, ending with a / if it is a
|
||||||
// dir
|
// dir
|
||||||
str := func(i int) string {
|
str := func(i int) string {
|
||||||
item := items[i]
|
item := items[i]
|
||||||
|
|
|
@ -738,7 +738,7 @@ func (s *syncCopyMove) run() error {
|
||||||
}
|
}
|
||||||
|
|
||||||
// Have an object which is in the destination only
|
// Have an object which is in the destination only
|
||||||
func (s *syncCopyMove) dstOnly(dst BasicInfo, job listDirJob, jobs *[]listDirJob) {
|
func (s *syncCopyMove) dstOnly(dst DirEntry, job listDirJob, jobs *[]listDirJob) {
|
||||||
if s.deleteMode == DeleteModeOff {
|
if s.deleteMode == DeleteModeOff {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
@ -771,7 +771,7 @@ func (s *syncCopyMove) dstOnly(dst BasicInfo, job listDirJob, jobs *[]listDirJob
|
||||||
}
|
}
|
||||||
|
|
||||||
// Have an object which is in the source only
|
// Have an object which is in the source only
|
||||||
func (s *syncCopyMove) srcOnly(src BasicInfo, job listDirJob, jobs *[]listDirJob) {
|
func (s *syncCopyMove) srcOnly(src DirEntry, job listDirJob, jobs *[]listDirJob) {
|
||||||
if s.deleteMode == DeleteModeOnly {
|
if s.deleteMode == DeleteModeOnly {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
@ -799,7 +799,7 @@ func (s *syncCopyMove) srcOnly(src BasicInfo, job listDirJob, jobs *[]listDirJob
|
||||||
}
|
}
|
||||||
|
|
||||||
// Given a src and a dst, transfer the src to dst
|
// Given a src and a dst, transfer the src to dst
|
||||||
func (s *syncCopyMove) transfer(dst, src BasicInfo, job listDirJob, jobs *[]listDirJob) {
|
func (s *syncCopyMove) transfer(dst, src DirEntry, job listDirJob, jobs *[]listDirJob) {
|
||||||
switch srcX := src.(type) {
|
switch srcX := src.(type) {
|
||||||
case Object:
|
case Object:
|
||||||
if s.deleteMode == DeleteModeOnly {
|
if s.deleteMode == DeleteModeOnly {
|
||||||
|
@ -878,7 +878,7 @@ func (s *syncCopyMove) _run(job listDirJob) (jobs []listDirJob) {
|
||||||
if s.aborting() {
|
if s.aborting() {
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
var src, dst BasicInfo
|
var src, dst DirEntry
|
||||||
if iSrc < len(srcList) {
|
if iSrc < len(srcList) {
|
||||||
src = srcList[iSrc]
|
src = srcList[iSrc]
|
||||||
}
|
}
|
||||||
|
|
|
@ -187,13 +187,13 @@ func parentDir(entryPath string) string {
|
||||||
}
|
}
|
||||||
|
|
||||||
// add an entry to the tree
|
// add an entry to the tree
|
||||||
func (dt DirTree) add(entry BasicInfo) {
|
func (dt DirTree) add(entry DirEntry) {
|
||||||
dirPath := parentDir(entry.Remote())
|
dirPath := parentDir(entry.Remote())
|
||||||
dt[dirPath] = append(dt[dirPath], entry)
|
dt[dirPath] = append(dt[dirPath], entry)
|
||||||
}
|
}
|
||||||
|
|
||||||
// add a directory entry to the tree
|
// add a directory entry to the tree
|
||||||
func (dt DirTree) addDir(entry BasicInfo) {
|
func (dt DirTree) addDir(entry DirEntry) {
|
||||||
dt.add(entry)
|
dt.add(entry)
|
||||||
// create the directory itself if it doesn't exist already
|
// create the directory itself if it doesn't exist already
|
||||||
dirPath := entry.Remote()
|
dirPath := entry.Remote()
|
||||||
|
@ -402,7 +402,7 @@ func (lh *ListRHelper) send(max int) (err error) {
|
||||||
|
|
||||||
// Add an entry to the stored entries and send them if there are more
|
// Add an entry to the stored entries and send them if there are more
|
||||||
// than a certain amount
|
// than a certain amount
|
||||||
func (lh *ListRHelper) Add(entry BasicInfo) error {
|
func (lh *ListRHelper) Add(entry DirEntry) error {
|
||||||
if entry == nil {
|
if entry == nil {
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
|
@ -360,8 +360,8 @@ func (f *Fs) list(dir string, recurse bool, fn listFn) error {
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
// Convert a list item into a BasicInfo
|
// Convert a list item into a DirEntry
|
||||||
func (f *Fs) itemToDirEntry(remote string, object *storage.Object, isDirectory bool) (fs.BasicInfo, error) {
|
func (f *Fs) itemToDirEntry(remote string, object *storage.Object, isDirectory bool) (fs.DirEntry, error) {
|
||||||
if isDirectory {
|
if isDirectory {
|
||||||
d := &fs.Dir{
|
d := &fs.Dir{
|
||||||
Name: remote,
|
Name: remote,
|
||||||
|
|
4
s3/s3.go
4
s3/s3.go
|
@ -548,8 +548,8 @@ func (f *Fs) list(dir string, recurse bool, fn listFn) error {
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
// Convert a list item into a BasicInfo
|
// Convert a list item into a DirEntry
|
||||||
func (f *Fs) itemToDirEntry(remote string, object *s3.Object, isDirectory bool) (fs.BasicInfo, error) {
|
func (f *Fs) itemToDirEntry(remote string, object *s3.Object, isDirectory bool) (fs.DirEntry, error) {
|
||||||
if isDirectory {
|
if isDirectory {
|
||||||
size := int64(0)
|
size := int64(0)
|
||||||
if object.Size != nil {
|
if object.Size != nil {
|
||||||
|
|
|
@ -315,7 +315,7 @@ func (f *Fs) listContainerRoot(container, root string, dir string, recurse bool,
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
type addEntryFn func(fs.BasicInfo) error
|
type addEntryFn func(fs.DirEntry) error
|
||||||
|
|
||||||
// list the objects into the function supplied
|
// list the objects into the function supplied
|
||||||
func (f *Fs) list(dir string, recurse bool, fn addEntryFn) error {
|
func (f *Fs) list(dir string, recurse bool, fn addEntryFn) error {
|
||||||
|
@ -347,7 +347,7 @@ func (f *Fs) listDir(dir string) (entries fs.DirEntries, err error) {
|
||||||
return nil, fs.ErrorListBucketRequired
|
return nil, fs.ErrorListBucketRequired
|
||||||
}
|
}
|
||||||
// List the objects
|
// List the objects
|
||||||
err = f.list(dir, false, func(entry fs.BasicInfo) error {
|
err = f.list(dir, false, func(entry fs.DirEntry) error {
|
||||||
entries = append(entries, entry)
|
entries = append(entries, entry)
|
||||||
return nil
|
return nil
|
||||||
})
|
})
|
||||||
|
@ -417,7 +417,7 @@ func (f *Fs) ListR(dir string, callback fs.ListRCallback) (err error) {
|
||||||
return errors.New("container needed for recursive list")
|
return errors.New("container needed for recursive list")
|
||||||
}
|
}
|
||||||
list := fs.NewListRHelper(callback)
|
list := fs.NewListRHelper(callback)
|
||||||
err = f.list(dir, true, func(entry fs.BasicInfo) error {
|
err = f.list(dir, true, func(entry fs.DirEntry) error {
|
||||||
return list.Add(entry)
|
return list.Add(entry)
|
||||||
})
|
})
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
@ -493,7 +493,7 @@ func (f *Fs) Purge() error {
|
||||||
go func() {
|
go func() {
|
||||||
delErr <- fs.DeleteFiles(toBeDeleted)
|
delErr <- fs.DeleteFiles(toBeDeleted)
|
||||||
}()
|
}()
|
||||||
err := f.list("", true, func(entry fs.BasicInfo) error {
|
err := f.list("", true, func(entry fs.DirEntry) error {
|
||||||
if o, ok := entry.(*Object); ok {
|
if o, ok := entry.(*Object); ok {
|
||||||
toBeDeleted <- o
|
toBeDeleted <- o
|
||||||
}
|
}
|
||||||
|
|
|
@ -166,8 +166,8 @@ func (f *Fs) setRoot(root string) {
|
||||||
f.diskRoot = diskRoot
|
f.diskRoot = diskRoot
|
||||||
}
|
}
|
||||||
|
|
||||||
// Convert a list item into a BasicInfo
|
// Convert a list item into a DirEntry
|
||||||
func (f *Fs) itemToDirEntry(remote string, object *yandex.ResourceInfoResponse) (fs.BasicInfo, error) {
|
func (f *Fs) itemToDirEntry(remote string, object *yandex.ResourceInfoResponse) (fs.DirEntry, error) {
|
||||||
switch object.ResourceType {
|
switch object.ResourceType {
|
||||||
case "dir":
|
case "dir":
|
||||||
t, err := time.Parse(time.RFC3339Nano, object.Modified)
|
t, err := time.Parse(time.RFC3339Nano, object.Modified)
|
||||||
|
|
Loading…
Reference in New Issue
Block a user