mirror of
				https://github.com/rclone/rclone.git
				synced 2025-10-30 23:17:59 +02:00 
			
		
		
		
	fs: add optional ID to fs.Directory and set it in the remotes which care
This commit is contained in:
		| @@ -427,7 +427,7 @@ func (f *Fs) List(dir string) (entries fs.DirEntries, err error) { | ||||
| 				// cache the directory ID for later lookups | ||||
| 				f.dirCache.Put(remote, *node.Id) | ||||
| 				when, _ := time.Parse(timeFormat, *node.ModifiedDate) // FIXME | ||||
| 				d := fs.NewDir(remote, when) | ||||
| 				d := fs.NewDir(remote, when).SetID(*node.Id) | ||||
| 				entries = append(entries, d) | ||||
| 			case fileKind: | ||||
| 				o, err := f.newObjectWithInfo(remote, node) | ||||
|   | ||||
| @@ -454,7 +454,7 @@ func (f *Fs) List(dir string) (entries fs.DirEntries, err error) { | ||||
| 		if info.Type == api.ItemTypeFolder { | ||||
| 			// cache the directory ID for later lookups | ||||
| 			f.dirCache.Put(remote, info.ID) | ||||
| 			d := fs.NewDir(remote, info.ModTime()) | ||||
| 			d := fs.NewDir(remote, info.ModTime()).SetID(info.ID) | ||||
| 			// FIXME more info from dir? | ||||
| 			entries = append(entries, d) | ||||
| 		} else if info.Type == api.ItemTypeFile { | ||||
|   | ||||
| @@ -591,7 +591,7 @@ func (f *Fs) List(dir string) (entries fs.DirEntries, err error) { | ||||
| 			// cache the directory ID for later lookups | ||||
| 			f.dirCache.Put(remote, item.Id) | ||||
| 			when, _ := time.Parse(timeFormatIn, item.ModifiedDate) | ||||
| 			d := fs.NewDir(remote, when) | ||||
| 			d := fs.NewDir(remote, when).SetID(item.Id) | ||||
| 			entries = append(entries, d) | ||||
| 		case item.Md5Checksum != "" || item.FileSize > 0: | ||||
| 			// If item has MD5 sum or a length it is a file stored on drive | ||||
|   | ||||
							
								
								
									
										12
									
								
								fs/dir.go
									
									
									
									
									
								
							
							
						
						
									
										12
									
								
								fs/dir.go
									
									
									
									
									
								
							| @@ -8,6 +8,7 @@ type Dir struct { | ||||
| 	modTime time.Time // modification or creation time - IsZero for unknown | ||||
| 	size    int64     // size of directory and contents or -1 if unknown | ||||
| 	items   int64     // number of objects or -1 for unknown | ||||
| 	id      string    // optional ID | ||||
| } | ||||
|  | ||||
| // NewDir creates an unspecialized Directory object | ||||
| @@ -46,6 +47,17 @@ func (d *Dir) SetRemote(remote string) *Dir { | ||||
| 	return d | ||||
| } | ||||
|  | ||||
| // ID gets the optional ID | ||||
| func (d *Dir) ID() string { | ||||
| 	return d.id | ||||
| } | ||||
|  | ||||
| // SetID sets the optional ID | ||||
| func (d *Dir) SetID(id string) *Dir { | ||||
| 	d.id = id | ||||
| 	return d | ||||
| } | ||||
|  | ||||
| // ModTime returns the modification date of the file | ||||
| // It should return a best guess if one isn't available | ||||
| func (d *Dir) ModTime() time.Time { | ||||
|   | ||||
							
								
								
									
										4
									
								
								fs/fs.go
									
									
									
									
									
								
							
							
						
						
									
										4
									
								
								fs/fs.go
									
									
									
									
									
								
							| @@ -219,6 +219,10 @@ type Directory interface { | ||||
| 	// Items returns the count of items in this directory or this | ||||
| 	// directory and subdirectories if known, -1 for unknown | ||||
| 	Items() int64 | ||||
|  | ||||
| 	// ID returns the internal ID of this directory if known, or | ||||
| 	// "" otherwise | ||||
| 	ID() string | ||||
| } | ||||
|  | ||||
| // MimeTyper is an optional interface for Object | ||||
|   | ||||
| @@ -423,7 +423,7 @@ func (f *Fs) List(dir string) (entries fs.DirEntries, err error) { | ||||
| 		if info.Folder != nil { | ||||
| 			// cache the directory ID for later lookups | ||||
| 			f.dirCache.Put(remote, info.ID) | ||||
| 			d := fs.NewDir(remote, time.Time(info.LastModifiedDateTime)) | ||||
| 			d := fs.NewDir(remote, time.Time(info.LastModifiedDateTime)).SetID(info.ID) | ||||
| 			if info.Folder != nil { | ||||
| 				d.SetItems(info.Folder.ChildCount) | ||||
| 			} | ||||
|   | ||||
		Reference in New Issue
	
	Block a user