mirror of
				https://github.com/rclone/rclone.git
				synced 2025-10-30 23:17:59 +02:00 
			
		
		
		
	fs: rename BasicInfo to DirEntry
This commit is contained in:
		
							
								
								
									
										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 | ||||
| } | ||||
|  | ||||
| // Convert a list item into a BasicInfo | ||||
| func (f *Fs) itemToDirEntry(remote string, object *api.File, isDirectory bool, last *string) (fs.BasicInfo, error) { | ||||
| // Convert a list item into a DirEntry | ||||
| func (f *Fs) itemToDirEntry(remote string, object *api.File, isDirectory bool, last *string) (fs.DirEntry, error) { | ||||
| 	if isDirectory { | ||||
| 		d := &fs.Dir{ | ||||
| 			Name:  remote, | ||||
|   | ||||
| @@ -21,7 +21,7 @@ import ( | ||||
| // | ||||
| // node may be nil, but o may not | ||||
| type DirEntry struct { | ||||
| 	o    fs.BasicInfo | ||||
| 	o    fs.DirEntry | ||||
| 	node fusefs.Node | ||||
| } | ||||
|  | ||||
|   | ||||
| @@ -16,7 +16,7 @@ import ( | ||||
| // | ||||
| // node may be nil, but o may not | ||||
| type DirEntry struct { | ||||
| 	Obj  fs.BasicInfo | ||||
| 	Obj  fs.DirEntry | ||||
| 	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 | ||||
| // | ||||
| // 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{ | ||||
| 		Obj:  o, | ||||
| 		Node: node, | ||||
| @@ -414,7 +414,7 @@ func (d *Dir) Rename(oldName, newName string, destDir *Dir) error { | ||||
| 		fs.Errorf(oldPath, "Dir.Rename error: %v", err) | ||||
| 		return err | ||||
| 	} | ||||
| 	var newObj fs.BasicInfo | ||||
| 	var newObj fs.DirEntry | ||||
| 	oldNode := oldItem.Node | ||||
| 	switch x := oldItem.Obj.(type) { | ||||
| 	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. | ||||
| type ObjectInfo interface { | ||||
| 	BasicInfo | ||||
| 	DirEntry | ||||
|  | ||||
| 	// Fs returns read only access to the Fs that this object is part of | ||||
| 	Fs() Info | ||||
| @@ -191,9 +191,10 @@ type ObjectInfo interface { | ||||
| 	Storable() bool | ||||
| } | ||||
|  | ||||
| // BasicInfo provides read only information about the common subset of | ||||
| // a Dir or Object. | ||||
| type BasicInfo interface { | ||||
| // DirEntry provides read only information about the common subset of | ||||
| // a Dir or Object.  These are returned from directory listings - type | ||||
| // assert them into the correct type. | ||||
| type DirEntry interface { | ||||
| 	// String returns a description of the Object | ||||
| 	String() string | ||||
|  | ||||
| @@ -576,10 +577,7 @@ func (d *Dir) Size() int64 { | ||||
| } | ||||
|  | ||||
| // Check interface | ||||
| var _ BasicInfo = (*Dir)(nil) | ||||
|  | ||||
| // DirChan is a channel of Dir objects | ||||
| type DirChan chan *Dir | ||||
| var _ DirEntry = (*Dir)(nil) | ||||
|  | ||||
| // 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 | ||||
| type DirEntries []BasicInfo | ||||
| type DirEntries []DirEntry | ||||
|  | ||||
| // Len is part of sort.Interface. | ||||
| func (ds DirEntries) Len() int { | ||||
|   | ||||
| @@ -952,7 +952,7 @@ func TestListDirSorted(t *testing.T) { | ||||
| 	var items fs.DirEntries | ||||
| 	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 | ||||
| 	str := func(i int) string { | ||||
| 		item := items[i] | ||||
|   | ||||
| @@ -738,7 +738,7 @@ func (s *syncCopyMove) run() error { | ||||
| } | ||||
|  | ||||
| // 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 { | ||||
| 		return | ||||
| 	} | ||||
| @@ -771,7 +771,7 @@ func (s *syncCopyMove) dstOnly(dst BasicInfo, job listDirJob, jobs *[]listDirJob | ||||
| } | ||||
|  | ||||
| // 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 { | ||||
| 		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 | ||||
| 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) { | ||||
| 	case Object: | ||||
| 		if s.deleteMode == DeleteModeOnly { | ||||
| @@ -878,7 +878,7 @@ func (s *syncCopyMove) _run(job listDirJob) (jobs []listDirJob) { | ||||
| 		if s.aborting() { | ||||
| 			return nil | ||||
| 		} | ||||
| 		var src, dst BasicInfo | ||||
| 		var src, dst DirEntry | ||||
| 		if iSrc < len(srcList) { | ||||
| 			src = srcList[iSrc] | ||||
| 		} | ||||
|   | ||||
| @@ -187,13 +187,13 @@ func parentDir(entryPath string) string { | ||||
| } | ||||
|  | ||||
| // add an entry to the tree | ||||
| func (dt DirTree) add(entry BasicInfo) { | ||||
| func (dt DirTree) add(entry DirEntry) { | ||||
| 	dirPath := parentDir(entry.Remote()) | ||||
| 	dt[dirPath] = append(dt[dirPath], entry) | ||||
| } | ||||
|  | ||||
| // add a directory entry to the tree | ||||
| func (dt DirTree) addDir(entry BasicInfo) { | ||||
| func (dt DirTree) addDir(entry DirEntry) { | ||||
| 	dt.add(entry) | ||||
| 	// create the directory itself if it doesn't exist already | ||||
| 	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 | ||||
| // than a certain amount | ||||
| func (lh *ListRHelper) Add(entry BasicInfo) error { | ||||
| func (lh *ListRHelper) Add(entry DirEntry) error { | ||||
| 	if entry == nil { | ||||
| 		return nil | ||||
| 	} | ||||
|   | ||||
| @@ -360,8 +360,8 @@ func (f *Fs) list(dir string, recurse bool, fn listFn) error { | ||||
| 	return nil | ||||
| } | ||||
|  | ||||
| // Convert a list item into a BasicInfo | ||||
| func (f *Fs) itemToDirEntry(remote string, object *storage.Object, isDirectory bool) (fs.BasicInfo, error) { | ||||
| // Convert a list item into a DirEntry | ||||
| func (f *Fs) itemToDirEntry(remote string, object *storage.Object, isDirectory bool) (fs.DirEntry, error) { | ||||
| 	if isDirectory { | ||||
| 		d := &fs.Dir{ | ||||
| 			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 | ||||
| } | ||||
|  | ||||
| // Convert a list item into a BasicInfo | ||||
| func (f *Fs) itemToDirEntry(remote string, object *s3.Object, isDirectory bool) (fs.BasicInfo, error) { | ||||
| // Convert a list item into a DirEntry | ||||
| func (f *Fs) itemToDirEntry(remote string, object *s3.Object, isDirectory bool) (fs.DirEntry, error) { | ||||
| 	if isDirectory { | ||||
| 		size := int64(0) | ||||
| 		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 | ||||
| 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 | ||||
| 	} | ||||
| 	// 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) | ||||
| 		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") | ||||
| 	} | ||||
| 	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) | ||||
| 	}) | ||||
| 	if err != nil { | ||||
| @@ -493,7 +493,7 @@ func (f *Fs) Purge() error { | ||||
| 	go func() { | ||||
| 		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 { | ||||
| 			toBeDeleted <- o | ||||
| 		} | ||||
|   | ||||
| @@ -166,8 +166,8 @@ func (f *Fs) setRoot(root string) { | ||||
| 	f.diskRoot = diskRoot | ||||
| } | ||||
|  | ||||
| // Convert a list item into a BasicInfo | ||||
| func (f *Fs) itemToDirEntry(remote string, object *yandex.ResourceInfoResponse) (fs.BasicInfo, error) { | ||||
| // Convert a list item into a DirEntry | ||||
| func (f *Fs) itemToDirEntry(remote string, object *yandex.ResourceInfoResponse) (fs.DirEntry, error) { | ||||
| 	switch object.ResourceType { | ||||
| 	case "dir": | ||||
| 		t, err := time.Parse(time.RFC3339Nano, object.Modified) | ||||
|   | ||||
		Reference in New Issue
	
	Block a user