Skip to content

Commit

Permalink
Add path to file info
Browse files Browse the repository at this point in the history
  • Loading branch information
prasmussen committed Feb 21, 2016
1 parent a02adf6 commit 9ee98bc
Showing 1 changed file with 11 additions and 2 deletions.
13 changes: 11 additions & 2 deletions drive/info.go
Original file line number Diff line number Diff line change
Expand Up @@ -12,24 +12,32 @@ type FileInfoArgs struct {
SizeInBytes bool
}

func (self *Drive) Info(args FileInfoArgs) (err error) {
func (self *Drive) Info(args FileInfoArgs) error {
f, err := self.service.Files.Get(args.Id).Fields("id", "name", "size", "createdTime", "modifiedTime", "md5Checksum", "mimeType", "parents", "shared", "description", "webContentLink", "webViewLink").Do()
if err != nil {
return fmt.Errorf("Failed to get file: %s", err)
}

pathfinder := self.newPathfinder()
absPath, err := pathfinder.absPath(f)
if err != nil {
return err
}

PrintFileInfo(PrintFileInfoArgs{
Out: args.Out,
File: f,
Path: absPath,
SizeInBytes: args.SizeInBytes,
})

return
return nil
}

type PrintFileInfoArgs struct {
Out io.Writer
File *drive.File
Path string
SizeInBytes bool
}

Expand All @@ -39,6 +47,7 @@ func PrintFileInfo(args PrintFileInfoArgs) {
items := []kv{
kv{"Id", f.Id},
kv{"Name", f.Name},
kv{"Path", args.Path},
kv{"Description", f.Description},
kv{"Mime", f.MimeType},
kv{"Size", formatSize(f.Size, args.SizeInBytes)},
Expand Down

0 comments on commit 9ee98bc

Please sign in to comment.