Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
C
Clash Verge
Manage
Activity
Members
Labels
Plan
Issues
0
Issue boards
Milestones
Wiki
Code
Merge requests
0
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package Registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Terms and privacy
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
many-archive
Clash Verge
Commits
4e806e21
There was an error fetching the commit references. Please try again later.
Unverified
Commit
4e806e21
authored
3 years ago
by
GyDi
Browse files
Options
Downloads
Patches
Plain Diff
chore: adjust error log
parent
ec0fdf83
No related branches found
No related tags found
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
src-tauri/src/cmds.rs
+25
-27
25 additions, 27 deletions
src-tauri/src/cmds.rs
with
25 additions
and
27 deletions
src-tauri/src/cmds.rs
+
25
−
27
View file @
4e806e21
...
...
@@ -6,7 +6,7 @@ use crate::{
use
crate
::{
ret_err
,
wrap_err
};
use
anyhow
::
Result
;
use
serde_yaml
::
Mapping
;
use
std
::{
path
::
PathBuf
,
process
::
Command
,
process
::
Stdio
};
use
std
::{
path
::
PathBuf
,
process
::
Command
};
use
tauri
::{
api
,
Manager
,
State
};
/// get all profiles from `profiles.yaml`
...
...
@@ -321,55 +321,53 @@ pub fn open_logs_dir() -> Result<(), String> {
open_path_cmd
(
log_dir
,
"failed to open logs dir"
)
}
///
get open/explorer command
fn
open_path_cmd
(
dir
:
PathBuf
,
err_str
:
&
str
)
->
Result
<
(),
String
>
{
///
use the os default open command to open file or dir
fn
open_path_cmd
(
path
:
PathBuf
,
err_str
:
&
str
)
->
Result
<
(),
String
>
{
let
result
;
#[cfg(target_os
=
"windows"
)]
{
use
std
::
os
::
windows
::
process
::
CommandExt
;
result
=
Command
::
new
(
"explorer"
)
.creation_flags
(
0x08000000
)
.arg
(
&
dir
)
.spawn
();
.creation_flags
(
0x08000000
)
.arg
(
&
path
)
.spawn
();
}
#[cfg(target_os
=
"macos"
)]
{
result
=
Command
::
new
(
"open"
)
.arg
(
&
dir
)
.spawn
();
result
=
Command
::
new
(
"open"
)
.arg
(
&
path
)
.spawn
();
}
#[cfg(target_os
=
"linux"
)]
{
result
=
Command
::
new
(
"xdg-open"
)
.arg
(
&
dir
)
.stdout
(
Stdio
::
piped
())
.stderr
(
Stdio
::
piped
()
)
.spawn
();
result
=
Command
::
new
(
"xdg-open"
)
.arg
(
&
path
)
.spawn
();
}
match
result
{
Ok
(
child
)
=>
{
match
child
.wait_with_output
()
{
Ok
(
out
)
=>
{
if
let
Some
(
code
)
=
out
.status
.code
()
{
if
code
!=
0
{
log
::
error!
(
"open dir {:?} failed, child exit code: {:?}, stderr: {:?} stdout: {:?}"
,
&
dir
,
code
,
String
::
from_utf8_lossy
(
&
out
.stderr
),
String
::
from_utf8_lossy
(
&
out
.stdout
));
return
Err
(
err_str
.into
());
}
Ok
(
child
)
=>
match
child
.wait_with_output
()
{
Ok
(
out
)
=>
{
if
let
Some
(
code
)
=
out
.status
.code
()
{
if
code
!=
0
{
log
::
error!
(
"failed to open path {:?} for {} (code {code})"
,
&
path
,
String
::
from_utf8_lossy
(
&
out
.stderr
),
);
return
Err
(
err_str
.into
());
}
},
Err
(
err
)
=>
{
log
::
error!
(
"open dir {:?} failed, child exec err: {}"
,
&
dir
,
err
);
return
Err
(
err_str
.into
());
}
}
Err
(
err
)
=>
{
log
::
error!
(
"failed to open path {:?} for {err}"
,
&
path
);
return
Err
(
err_str
.into
());
}
},
Err
(
err
)
=>
{
log
::
error!
(
"open
dir
{:?}
spawn process failed, err: {}"
,
&
dir
,
err
);
log
::
error!
(
"
failed to
open
path
{:?}
for {err}"
,
&
path
);
return
Err
(
err_str
.into
());
},
_
=>
{
log
::
error!
(
"open dir {:?} failed due to OS not supported"
,
&
dir
);
return
Err
(
err_str
.into
());
},
}
}
return
Ok
(());
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment