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
c8e6f3a6
There was an error fetching the commit references. Please try again later.
Unverified
Commit
c8e6f3a6
authored
2 years ago
by
GyDi
Browse files
Options
Downloads
Patches
Plain Diff
refactor: rm update item block_on
parent
dc941575
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/config/profiles.rs
+20
-26
20 additions, 26 deletions
src-tauri/src/config/profiles.rs
with
20 additions
and
26 deletions
src-tauri/src/config/profiles.rs
+
20
−
26
View file @
c8e6f3a6
...
...
@@ -27,41 +27,35 @@ impl ProfilesN {
/// 更新单个配置
pub
async
fn
update_item
(
&
self
,
uid
:
String
,
option
:
Option
<
PrfOption
>
)
->
Result
<
()
>
{
let
(
url
,
opt
)
=
{
let
url
_
opt
=
{
let
profiles
=
self
.config
.lock
();
let
item
=
profiles
.get_item
(
&
uid
)
?
;
let
is_remote
=
item
.itype
.as_ref
()
.map_or
(
false
,
|
s
|
s
==
"remote"
);
if
let
Some
(
typ
)
=
item
.itype
.as_ref
()
{
// maybe only valid for `local` profile
if
*
typ
!=
"remote"
{
// reactivate the config
if
Some
(
uid
)
==
profiles
.get_current
()
{
drop
(
profiles
);
tauri
::
async_runtime
::
block_on
(
async
{
CoreManager
::
global
()
.activate_config
()
.await
})
?
;
}
return
Ok
(());
}
}
if
item
.url
.is_none
()
{
if
!
is_remote
{
None
// 直接更新
}
else
if
item
.url
.is_none
()
{
bail!
(
"failed to get the profile item url"
);
}
else
{
Some
((
item
.url
.clone
()
.unwrap
(),
item
.option
.clone
()))
}
(
item
.url
.clone
()
.unwrap
(),
item
.option
.clone
())
};
let
merged_opt
=
PrfOption
::
merge
(
opt
,
option
);
let
item
=
PrfItem
::
from_url
(
&
url
,
None
,
None
,
merged_opt
)
.await
?
;
let
should_update
=
match
url_opt
{
Some
((
url
,
opt
))
=>
{
let
merged_opt
=
PrfOption
::
merge
(
opt
,
option
);
let
item
=
PrfItem
::
from_url
(
&
url
,
None
,
None
,
merged_opt
)
.await
?
;
let
mut
profiles
=
self
.config
.lock
();
profiles
.update_item
(
uid
.clone
(),
item
)
?
;
let
mut
profiles
=
self
.config
.lock
();
profiles
.update_item
(
uid
.clone
(),
item
)
?
;
Some
(
uid
)
==
profiles
.get_current
()
}
None
=>
true
,
};
// reactivate the profile
if
Some
(
uid
)
==
profiles
.get_current
()
{
drop
(
profiles
);
tauri
::
async_runtime
::
block_on
(
async
{
CoreManager
::
global
()
.activate_config
()
.await
})
?
;
if
should_update
{
CoreManager
::
global
()
.activate_config
()
.await
?
;
}
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