Skip to content

Commit

Permalink
[develop] drive/path.go: modified to use self for identifier for reci…
Browse files Browse the repository at this point in the history
…ever.
  • Loading branch information
SGH623QVQT committed Oct 2, 2017
1 parent 64f45b2 commit ca724d8
Showing 1 changed file with 6 additions and 6 deletions.
12 changes: 6 additions & 6 deletions drive/path.go
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,7 @@ func (drive *Drive) newPathResolver() *drivePathResolver {
}
}

func (resolver *drivePathResolver) getFileID(abspath string) (string, error) {
func (self *drivePathResolver) getFileID(abspath string) (string, error) {
if !strings.HasPrefix(abspath, "/") {
return "", fmt.Errorf("'%s' is not absolute path", abspath)
}
Expand All @@ -90,7 +90,7 @@ func (resolver *drivePathResolver) getFileID(abspath string) (string, error) {
pathes := strings.Split(abspath, "/")
var parent = "root"
for _, path := range pathes {
entries, err := resolver.queryEntryByName(path, parent)
entries, err := self.queryEntryByName(path, parent)
if err != nil {
return "", err
}
Expand All @@ -99,17 +99,17 @@ func (resolver *drivePathResolver) getFileID(abspath string) (string, error) {
return parent, nil
}

func (resolver *drivePathResolver) secureFileId(expr string) string {
func (self *drivePathResolver) secureFileId(expr string) string {
if strings.Contains(expr, "/") {
id, err := resolver.getFileID(expr)
id, err := self.getFileID(expr)
if err == nil {
return id
}
}
return expr
}

func (resolver *drivePathResolver) queryEntryByName(name string, parent string) ([]*drive.File, error) {
func (self *drivePathResolver) queryEntryByName(name string, parent string) ([]*drive.File, error) {
conditions := []string{
"trashed = false",
fmt.Sprintf("name = '%v'", name),
Expand All @@ -119,7 +119,7 @@ func (resolver *drivePathResolver) queryEntryByName(name string, parent string)
fields := []googleapi.Field{"nextPageToken", "files(id,name,parents)"}

var files []*drive.File
resolver.service.List().Q(query).Fields(fields...).Pages(context.TODO(), func(fl *drive.FileList) error {
self.service.List().Q(query).Fields(fields...).Pages(context.TODO(), func(fl *drive.FileList) error {
files = append(files, fl.Files...)
return nil
})
Expand Down

0 comments on commit ca724d8

Please sign in to comment.