Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

v2 [#3133] SingleInstanceData: Fill missing WD as is #3154

Merged
merged 5 commits into from
Jan 3, 2024
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 7 additions & 0 deletions v2/internal/frontend/desktop/linux/single_instance.go
Original file line number Diff line number Diff line change
Expand Up @@ -55,8 +55,15 @@ func SetupSingleInstance(uniqueID string) {
data := options.SecondInstanceData{
Args: os.Args[1:],
}
data.WorkingDirectory, err = os.Getwd()
if err != nil {
log.Printf("Failed to get working directory: %v", err)
return
Comment on lines +60 to +62
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Proper error handling is implemented for the os.Getwd() call. However, consider if returning early is the best approach, as it may prevent further necessary cleanup or logic that should execute regardless of this error.

}

serialized, err := json.Marshal(data)
if err != nil {
log.Printf("Failed to marshal data: %v", err)
return
}

Expand Down
11 changes: 10 additions & 1 deletion v2/internal/frontend/desktop/windows/single_instance.go
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,16 @@ func SetupSingleInstance(uniqueId string) {
data := options.SecondInstanceData{
Args: os.Args[1:],
}
serialized, _ := json.Marshal(data)
data.WorkingDirectory, err = os.Getwd()
if err != nil {
log.Printf("Failed to get working directory: %v", err)
return
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Proper error handling is implemented for the os.Getwd() call. However, consider if returning early is the best approach, as it may prevent further necessary cleanup or logic that should execute regardless of this error.

}
serialized, err := json.Marshal(data)
if err != nil {
log.Printf("Failed to marshal data: %v", err)
return
}

SendMessage(hwnd, string(serialized))
// exit second instance of app after sending message
Expand Down