diff options
| author | Petter Rasmussen | 2016-10-12 01:38:59 +0200 | 
|---|---|---|
| committer | GitHub | 2016-10-12 01:38:59 +0200 | 
| commit | 8f299578a2f0222e4b11e1a03692f7aba69c0977 (patch) | |
| tree | cb59f29f791d2886905382a31a9279866ad3a95d /drive | |
| parent | 9e8d2cd027c72b2364026dc32cd4ca5494d922d9 (diff) | |
| parent | 8f5194c7154b20965250f6333226a18e225647dd (diff) | |
| download | gdrive-8f299578a2f0222e4b11e1a03692f7aba69c0977.tar.bz2 | |
Merge pull request #201 from jblazquez/master
Added --description option
Diffstat (limited to 'drive')
| -rw-r--r-- | drive/mkdir.go | 13 | ||||
| -rw-r--r-- | drive/update.go | 23 | ||||
| -rw-r--r-- | drive/upload.go | 54 | 
3 files changed, 50 insertions, 40 deletions
| diff --git a/drive/mkdir.go b/drive/mkdir.go index 8eea210..05d5191 100644 --- a/drive/mkdir.go +++ b/drive/mkdir.go @@ -9,9 +9,10 @@ import (  const DirectoryMimeType = "application/vnd.google-apps.folder"  type MkdirArgs struct { -	Out     io.Writer -	Name    string -	Parents []string +	Out         io.Writer +	Name        string +	Description string +	Parents     []string  }  func (self *Drive) Mkdir(args MkdirArgs) error { @@ -24,7 +25,11 @@ func (self *Drive) Mkdir(args MkdirArgs) error {  }  func (self *Drive) mkdir(args MkdirArgs) (*drive.File, error) { -	dstFile := &drive.File{Name: args.Name, MimeType: DirectoryMimeType} +	dstFile := &drive.File{ +		Name:        args.Name, +		Description: args.Description, +		MimeType:    DirectoryMimeType, +	}  	// Set parent folders  	dstFile.Parents = args.Parents diff --git a/drive/update.go b/drive/update.go index 2ab684e..f496f52 100644 --- a/drive/update.go +++ b/drive/update.go @@ -11,16 +11,17 @@ import (  )  type UpdateArgs struct { -	Out       io.Writer -	Progress  io.Writer -	Id        string -	Path      string -	Name      string -	Parents   []string -	Mime      string -	Recursive bool -	ChunkSize int64 -	Timeout   time.Duration +	Out         io.Writer +	Progress    io.Writer +	Id          string +	Path        string +	Name        string +	Description string +	Parents     []string +	Mime        string +	Recursive   bool +	ChunkSize   int64 +	Timeout     time.Duration  }  func (self *Drive) Update(args UpdateArgs) error { @@ -32,7 +33,7 @@ func (self *Drive) Update(args UpdateArgs) error {  	defer srcFile.Close()  	// Instantiate empty drive file -	dstFile := &drive.File{} +	dstFile := &drive.File{Description: args.Description}  	// Use provided file name or use filename  	if args.Name == "" { diff --git a/drive/upload.go b/drive/upload.go index dbf068c..a4482e2 100644 --- a/drive/upload.go +++ b/drive/upload.go @@ -12,17 +12,18 @@ import (  )  type UploadArgs struct { -	Out       io.Writer -	Progress  io.Writer -	Path      string -	Name      string -	Parents   []string -	Mime      string -	Recursive bool -	Share     bool -	Delete    bool -	ChunkSize int64 -	Timeout   time.Duration +	Out         io.Writer +	Progress    io.Writer +	Path        string +	Name        string +	Description string +	Parents     []string +	Mime        string +	Recursive   bool +	Share       bool +	Delete      bool +	ChunkSize   int64 +	Timeout     time.Duration  }  func (self *Drive) Upload(args UploadArgs) error { @@ -110,9 +111,10 @@ func (self *Drive) uploadDirectory(args UploadArgs) error {  	fmt.Fprintf(args.Out, "Creating directory %s\n", srcFileInfo.Name())  	// Make directory on drive  	f, err := self.mkdir(MkdirArgs{ -		Out:     args.Out, -		Name:    srcFileInfo.Name(), -		Parents: args.Parents, +		Out:         args.Out, +		Name:        srcFileInfo.Name(), +		Parents:     args.Parents, +		Description: args.Description,  	})  	if err != nil {  		return err @@ -129,6 +131,7 @@ func (self *Drive) uploadDirectory(args UploadArgs) error {  		newArgs := args  		newArgs.Path = filepath.Join(args.Path, name)  		newArgs.Parents = []string{f.Id} +		newArgs.Description = ""  		// Upload  		err = self.uploadRecursive(newArgs) @@ -150,7 +153,7 @@ func (self *Drive) uploadFile(args UploadArgs) (*drive.File, int64, error) {  	defer srcFile.Close()  	// Instantiate empty drive file -	dstFile := &drive.File{} +	dstFile := &drive.File{Description: args.Description}  	// Use provided file name or use filename  	if args.Name == "" { @@ -196,15 +199,16 @@ func (self *Drive) uploadFile(args UploadArgs) (*drive.File, int64, error) {  }  type UploadStreamArgs struct { -	Out       io.Writer -	In        io.Reader -	Name      string -	Parents   []string -	Mime      string -	Share     bool -	ChunkSize int64 -	Progress  io.Writer -	Timeout   time.Duration +	Out         io.Writer +	In          io.Reader +	Name        string +	Description string +	Parents     []string +	Mime        string +	Share       bool +	ChunkSize   int64 +	Progress    io.Writer +	Timeout     time.Duration  }  func (self *Drive) UploadStream(args UploadStreamArgs) error { @@ -213,7 +217,7 @@ func (self *Drive) UploadStream(args UploadStreamArgs) error {  	}  	// Instantiate empty drive file -	dstFile := &drive.File{Name: args.Name} +	dstFile := &drive.File{Name: args.Name, Description: args.Description}  	// Set mime type if provided  	if args.Mime != "" { | 
