Skip to content

Commit 050eb1a

Browse files
committed
fix(update): Create an update marker regardless of the update mode
1 parent 6388329 commit 050eb1a

File tree

3 files changed

+34
-60
lines changed

3 files changed

+34
-60
lines changed

src/debugger.rs

Lines changed: 14 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ use zed_extension_api::{
1010
};
1111

1212
use crate::{
13-
config::{CheckUpdates, get_check_updates, get_java_debug_jar},
13+
config::get_java_debug_jar,
1414
lsp::LspWrapper,
1515
util::{
1616
create_path_if_not_exists, get_curr_dir, mark_checked_once, path_to_quoted_string,
@@ -124,21 +124,18 @@ impl Debugger {
124124
}
125125

126126
// Use local installation if update mode requires it
127-
if let Some(path) =
128-
should_use_local_or_download(configuration, find_latest_local_debugger(), "debugger")?
129-
{
127+
if let Some(path) = should_use_local_or_download(
128+
configuration,
129+
find_latest_local_debugger(),
130+
DEBUGGER_INSTALL_PATH,
131+
)? {
130132
self.plugin_path = Some(path.clone());
131133
return Ok(path);
132134
}
133135

134-
let result = self.get_or_download_fork(language_server_id);
135-
136-
// Mark as checked once if in Once mode and download was successful
137-
if result.is_ok() && get_check_updates(configuration) == CheckUpdates::Once {
138-
let _ = mark_checked_once(DEBUGGER_INSTALL_PATH, "0.53.2");
139-
}
136+
140137

141-
result
138+
self.get_or_download_fork(language_server_id)
142139
}
143140

144141
fn get_or_download_fork(
@@ -169,6 +166,9 @@ impl Debugger {
169166
format!("Failed to download java-debug fork from {JAVA_DEBUG_PLUGIN_FORK_URL}: {err}")
170167
})?;
171168

169+
// Mark the downloaded version for "Once" mode tracking
170+
let _ = mark_checked_once(DEBUGGER_INSTALL_PATH, latest_version);
171+
172172
self.plugin_path = Some(jar_path.clone());
173173
Ok(jar_path)
174174
}
@@ -270,6 +270,9 @@ impl Debugger {
270270
DownloadedFileType::Uncompressed,
271271
)
272272
.map_err(|err| format!("Failed to download {url} {err}"))?;
273+
274+
// Mark the downloaded version for "Once" mode tracking
275+
let _ = mark_checked_once(DEBUGGER_INSTALL_PATH, latest_version);
273276
}
274277

275278
self.plugin_path = Some(jar_path.clone());

src/jdk.rs

Lines changed: 9 additions & 36 deletions
Original file line numberDiff line numberDiff line change
@@ -6,12 +6,9 @@ use zed_extension_api::{
66
set_language_server_installation_status,
77
};
88

9-
use crate::{
10-
config::{CheckUpdates, get_check_updates},
11-
util::{
12-
get_curr_dir, has_checked_once, mark_checked_once, path_to_quoted_string,
13-
remove_all_files_except,
14-
},
9+
use crate::util::{
10+
get_curr_dir, mark_checked_once, path_to_quoted_string, remove_all_files_except,
11+
should_use_local_or_download,
1512
};
1613

1714
// Errors
@@ -77,32 +74,10 @@ pub fn try_to_fetch_and_install_latest_jdk(
7774
let jdk_path = get_curr_dir()?.join(JDK_INSTALL_PATH);
7875

7976
// Check if we should use local installation based on update mode
80-
match get_check_updates(configuration) {
81-
CheckUpdates::Never => {
82-
if let Some(local_path) = find_latest_local_jdk() {
83-
return get_jdk_bin_path(&local_path);
84-
}
85-
return Err(
86-
"Update checks disabled (never) and no local JDK installation found".to_string(),
87-
);
88-
}
89-
CheckUpdates::Once => {
90-
// If we have a local installation, use it
91-
if let Some(local_path) = find_latest_local_jdk() {
92-
return get_jdk_bin_path(&local_path);
93-
}
94-
95-
// If we've already checked once, don't check again
96-
if has_checked_once(JDK_INSTALL_PATH) {
97-
return Err(
98-
"Update check already performed once for JDK. No local installation found."
99-
.to_string(),
100-
);
101-
}
102-
}
103-
CheckUpdates::Always => {
104-
// Continue to check for updates
105-
}
77+
if let Some(path) =
78+
should_use_local_or_download(configuration, find_latest_local_jdk(), JDK_INSTALL_PATH)?
79+
{
80+
return get_jdk_bin_path(&path);
10681
}
10782

10883
let version = zed::latest_github_release(
@@ -145,10 +120,8 @@ pub fn try_to_fetch_and_install_latest_jdk(
145120
let _ = remove_all_files_except(&jdk_path, version.as_str());
146121
}
147122

148-
// Mark as checked once if in Once mode
149-
if get_check_updates(configuration) == CheckUpdates::Once {
150-
let _ = mark_checked_once(JDK_INSTALL_PATH, &version);
151-
}
123+
// Always mark the downloaded version for "Once" mode tracking
124+
let _ = mark_checked_once(JDK_INSTALL_PATH, &version);
152125

153126
get_jdk_bin_path(&install_path)
154127
}

src/jdtls.rs

Lines changed: 11 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ use zed_extension_api::{
1515
};
1616

1717
use crate::{
18-
config::{CheckUpdates, get_check_updates, is_java_autodownload},
18+
config::is_java_autodownload,
1919
jdk::try_to_fetch_and_install_latest_jdk,
2020
util::{
2121
create_path_if_not_exists, get_curr_dir, get_java_exec_name, get_java_executable,
@@ -158,7 +158,7 @@ pub fn try_to_fetch_and_install_latest_jdtls(
158158
) -> zed::Result<PathBuf> {
159159
// Use local installation if update mode requires it
160160
if let Some(path) =
161-
should_use_local_or_download(configuration, find_latest_local_jdtls(), "jdtls")?
161+
should_use_local_or_download(configuration, find_latest_local_jdtls(), JDTLS_INSTALL_PATH)?
162162
{
163163
return Ok(path);
164164
}
@@ -205,10 +205,8 @@ pub fn try_to_fetch_and_install_latest_jdtls(
205205
let _ = remove_all_files_except(prefix, build_directory.as_str());
206206
}
207207

208-
// Mark as checked once if in Once mode
209-
if get_check_updates(configuration) == CheckUpdates::Once {
210-
let _ = mark_checked_once(JDTLS_INSTALL_PATH, &latest_version);
211-
}
208+
// Always mark the downloaded version for "Once" mode tracking
209+
let _ = mark_checked_once(JDTLS_INSTALL_PATH, &latest_version);
212210

213211
// return jdtls base path
214212
Ok(build_path)
@@ -219,9 +217,11 @@ pub fn try_to_fetch_and_install_latest_lombok(
219217
configuration: &Option<Value>,
220218
) -> zed::Result<PathBuf> {
221219
// Use local installation if update mode requires it
222-
if let Some(path) =
223-
should_use_local_or_download(configuration, find_latest_local_lombok(), "lombok")?
224-
{
220+
if let Some(path) = should_use_local_or_download(
221+
configuration,
222+
find_latest_local_lombok(),
223+
LOMBOK_INSTALL_PATH,
224+
)? {
225225
return Ok(path);
226226
}
227227

@@ -256,10 +256,8 @@ pub fn try_to_fetch_and_install_latest_lombok(
256256
let _ = remove_all_files_except(prefix, jar_name.as_str());
257257
}
258258

259-
// Mark as checked once if in Once mode
260-
if get_check_updates(configuration) == CheckUpdates::Once {
261-
let _ = mark_checked_once(LOMBOK_INSTALL_PATH, &latest_version);
262-
}
259+
// Always mark the downloaded version for "Once" mode tracking
260+
let _ = mark_checked_once(LOMBOK_INSTALL_PATH, &latest_version);
263261

264262
// else use it
265263
Ok(jar_path)

0 commit comments

Comments
 (0)