Skip to content

Commit

Permalink
Updated to v1.2.5
Browse files Browse the repository at this point in the history
  • Loading branch information
tanaikech committed Jan 29, 2020
1 parent 65d88d7 commit b5c2edb
Show file tree
Hide file tree
Showing 4 changed files with 48 additions and 30 deletions.
9 changes: 9 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -319,4 +319,13 @@ If you have any questions and commissions for me, feel free to tell me.

1. It seems that the specification of `github.com/urfave/cli` was changed by the update of [https://github.com/urfave/cli](https://github.com/urfave/cli). By this, when `go get -u github.com/tanaikech/goodls` is run, an error occurred. So this error was removed.

<a name="v125"></a>

- v1.2.5 (January 29, 2020)

1. An option for selecting whether the top directory is created was added.
- `$ goodls -u [URL] --notcreatetopdirectory` or `$ goodls -u [URL] -ntd`
- When this option is NOT used (default situation), when a folder including sub-folders is downloaded, the top folder which is downloaded is created as the top directory under the working directory. When this option is used, the top directory is not created and all files and sub-folders under the top folder are downloaded under the working directory.
- [This feature request](https://github.com/tanaikech/goodls/issues/8) was implemented.

[TOP](#top)
3 changes: 1 addition & 2 deletions doc.go
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,5 @@ If you use API key, you can download all files in a shared folder.
$ goodls -u [URL of shared folder on Google Drive] -key [API key]
---------------------------------------------------------------
*/
---------------------------------------------------------------*/
package main
11 changes: 8 additions & 3 deletions getfilesfromfolder.go
Original file line number Diff line number Diff line change
Expand Up @@ -167,12 +167,17 @@ func (p *para) initDownload(fileList *getfilelist.FileListDl) error {
}
for _, e := range fileList.FileList {
path := p.WorkDir
if p.Notcreatetopdirectory {
e.FolderTree = append(e.FolderTree[:0], e.FolderTree[1:]...)
}
for _, dir := range e.FolderTree {
path = filepath.Join(path, idToName[dir].(string))
}
err = p.makeDirByCondition(path)
if err != nil {
return err
if path != p.WorkDir {
err = p.makeDirByCondition(path)
if err != nil {
return err
}
}
for _, file := range e.Files {
if file.MimeType != "application/vnd.google-apps.script" {
Expand Down
55 changes: 30 additions & 25 deletions goodls.go
Original file line number Diff line number Diff line change
Expand Up @@ -37,26 +37,27 @@ type chunks struct {

// para : Structure for each parameter
type para struct {
APIKey string
Client *http.Client
Code string
ContentType string
Disp bool
DlFolder bool
DownloadBytes int64
Ext string
Filename string
ID string
InputtedMimeType []string
Kind string
OverWrite bool
Resumabledownload string
SearchID string
ShowFileInf bool
Size int64
Skip bool
URL string
WorkDir string
APIKey string
Client *http.Client
Code string
ContentType string
Disp bool
DlFolder bool
DownloadBytes int64
Ext string
Filename string
ID string
InputtedMimeType []string
Kind string
Notcreatetopdirectory bool
OverWrite bool
Resumabledownload string
SearchID string
ShowFileInf bool
Size int64
Skip bool
URL string
WorkDir string
}

// Read : For io.Reader
Expand Down Expand Up @@ -281,10 +282,8 @@ func (p *para) download(url string) error {
}
return p.downloadLargeFile()
}
} else {
return fmt.Errorf("file ID [ %s ] cannot be downloaded as [ %s ]", p.ID, p.Ext)
}
return nil
return fmt.Errorf("file ID [ %s ] cannot be downloaded as [ %s ]", p.ID, p.Ext)
}

// handler : Initialize of "para".
Expand Down Expand Up @@ -314,6 +313,7 @@ func handler(c *cli.Context) error {
}
return nil
}(c.String("mimetype")),
Notcreatetopdirectory: c.Bool("notcreatetopdirectory"),
}
if envv := os.Getenv(envval); c.String("apikey") == "" && envv != "" {
p.APIKey = strings.TrimSpace(envv)
Expand Down Expand Up @@ -362,7 +362,7 @@ func createHelp() *cli.App {
{Name: "tanaike [ https://github.com/tanaikech/" + appname + " ] ", Email: "[email protected]"},
}
a.UsageText = "Download shared files on Google Drive."
a.Version = "1.2.4"
a.Version = "1.2.5"
a.Flags = []cli.Flag{
&cli.StringFlag{
Name: "url, u",
Expand Down Expand Up @@ -413,13 +413,18 @@ func createHelp() *cli.App {
&cli.StringFlag{
Name: "apikey, key",
Aliases: []string{"key"},
Usage: "API key is uded to retrieve file list from shared folder and file information.",
Usage: "API key is used to retrieve file list from shared folder and file information.",
},
&cli.StringFlag{
Name: "directory, d",
Aliases: []string{"d"},
Usage: "Directory for saving downloaded files. When this is not used, the files are saved to the current working directory.",
},
&cli.BoolFlag{
Name: "notcreatetopdirectory, ntd",
Aliases: []string{"ntd"},
Usage: "When this option is NOT used (default situation), when a folder including subfolders is downloaded, the top folder which is downloaded is created as the top directory under the working directory. When this option is used, the top directory is not created and all files and subfolders under the top folder are downloaded under the working directory.",
},
}
return a
}
Expand Down

0 comments on commit b5c2edb

Please sign in to comment.