1
0
mirror of https://github.com/garraflavatra/rolens.git synced 2025-01-18 13:07:58 +00:00

Open dump in Explorer/Finder when finished (fixes #43)

This commit is contained in:
Romein van Buren 2023-06-24 15:50:46 +02:00
parent 8f81e66d17
commit 3e293910ea
Signed by: romein
GPG Key ID: 0EFF8478ADDF6C49
2 changed files with 13 additions and 2 deletions

View File

@ -1,3 +1,7 @@
## [Unreleased]
* Open dump in Explorer/Finder when finished (#43).
## [v0.2.1] ## [v0.2.1]
* Display host and database statistics generated by the corresponding diagnostic MongoDB commands in addition to collection stats (#15). * Display host and database statistics generated by the corresponding diagnostic MongoDB commands in addition to collection stats (#15).
@ -17,6 +21,7 @@
Initial release. Initial release.
[Unreleased]: https://github.com/garraflavatra/rolens/tree/main
[v0.1.0]: https://github.com/garraflavatra/rolens/releases/tag/v0.1.0 [v0.1.0]: https://github.com/garraflavatra/rolens/releases/tag/v0.1.0
[v0.2.0]: https://github.com/garraflavatra/rolens/releases/tag/v0.2.0 [v0.2.0]: https://github.com/garraflavatra/rolens/releases/tag/v0.2.0
[v0.2.1]: https://github.com/garraflavatra/rolens/releases/tag/v0.2.1 [v0.2.1]: https://github.com/garraflavatra/rolens/releases/tag/v0.2.1

View File

@ -43,6 +43,7 @@ func (a *App) PerformDump(jsonData string) bool {
args := make([]string, 0) args := make([]string, 0)
args = append(args, fmt.Sprintf(`--uri="%v"`, host.URI)) args = append(args, fmt.Sprintf(`--uri="%v"`, host.URI))
fname := path.Join(info.OutDir, info.Filename)
if info.DbKey != "" { if info.DbKey != "" {
args = append(args, fmt.Sprintf(`--db="%v"`, info.DbKey)) args = append(args, fmt.Sprintf(`--db="%v"`, info.DbKey))
@ -52,7 +53,7 @@ func (a *App) PerformDump(jsonData string) bool {
} }
} }
args = append(args, fmt.Sprintf(`--out="%v"`, path.Join(info.OutDir, info.Filename))) args = append(args, fmt.Sprintf(`--out="%v"`, fname))
cmd := exec.Command("mongodump", args...) cmd := exec.Command("mongodump", args...)
var stdout strings.Builder var stdout strings.Builder
var stderr strings.Builder var stderr strings.Builder
@ -63,9 +64,14 @@ func (a *App) PerformDump(jsonData string) bool {
runtime.LogInfo(a.ctx, "Performing dump, executing command: mongodump "+strings.Join(args, " ")) runtime.LogInfo(a.ctx, "Performing dump, executing command: mongodump "+strings.Join(args, " "))
runtime.LogInfo(a.ctx, "mongodump stdout: "+stdout.String()) runtime.LogInfo(a.ctx, "mongodump stdout: "+stdout.String())
runtime.LogInfo(a.ctx, "mongodump sterr: "+stderr.String()) runtime.LogInfo(a.ctx, "mongodump sterr: "+stderr.String())
if err != nil { if err != nil {
runtime.LogWarning(a.ctx, "Error while executing mongodump: "+err.Error()) runtime.LogWarning(a.ctx, "Error while executing mongodump: "+err.Error())
return false
} }
return err == nil println(fname)
a.ui.Reveal(fname)
return true
} }