mirror of
https://github.com/microsoft/vscode.git
synced 2026-04-24 02:28:34 +01:00
cli: add acquire_cli (#179837)
* cli: add acquire_cli
As given in my draft document, pipes a CLI of the given platform to the
specified process, for example:
```js
const cmd = await rpc.call('acquire_cli', {
command: 'node',
args: [
'-e',
'process.stdin.pipe(fs.createWriteStream("c:/users/conno/downloads/hello-cli"))',
],
platform: Platform.LinuxX64,
quality: 'insider',
});
```
It genericizes caching so that the CLI is also cached on the host, just
like servers.
* fix bug
This commit is contained in:
@@ -15,6 +15,7 @@ use serde::{de::DeserializeOwned, Serialize};
|
||||
|
||||
use crate::{
|
||||
constants::VSCODE_CLI_QUALITY,
|
||||
download_cache::DownloadCache,
|
||||
util::errors::{wrap, AnyError, NoHomeForLauncherError, WrappedError},
|
||||
};
|
||||
|
||||
@@ -22,6 +23,8 @@ const HOME_DIR_ALTS: [&str; 2] = ["$HOME", "~"];
|
||||
|
||||
#[derive(Clone)]
|
||||
pub struct LauncherPaths {
|
||||
pub server_cache: DownloadCache,
|
||||
pub cli_cache: DownloadCache,
|
||||
root: PathBuf,
|
||||
}
|
||||
|
||||
@@ -95,14 +98,10 @@ where
|
||||
}
|
||||
|
||||
/// Mutates persisted state.
|
||||
pub fn update_with<V, R>(
|
||||
&self,
|
||||
v: V,
|
||||
mutator: fn(v: V, state: &mut T) -> R,
|
||||
) -> Result<R, WrappedError> {
|
||||
pub fn update<R>(&self, mutator: impl FnOnce(&mut T) -> R) -> Result<R, WrappedError> {
|
||||
let mut container = self.container.lock().unwrap();
|
||||
let mut state = container.load_or_get();
|
||||
let r = mutator(v, &mut state);
|
||||
let r = mutator(&mut state);
|
||||
container.save(state).map(|_| r)
|
||||
}
|
||||
}
|
||||
@@ -132,7 +131,15 @@ impl LauncherPaths {
|
||||
}
|
||||
|
||||
pub fn new_without_replacements(root: PathBuf) -> LauncherPaths {
|
||||
LauncherPaths { root }
|
||||
// cleanup folders that existed before the new LRU strategy:
|
||||
let _ = std::fs::remove_dir_all(root.join("server-insiders"));
|
||||
let _ = std::fs::remove_dir_all(root.join("server-stable"));
|
||||
|
||||
LauncherPaths {
|
||||
server_cache: DownloadCache::new(root.join("servers")),
|
||||
cli_cache: DownloadCache::new(root.join("cli")),
|
||||
root,
|
||||
}
|
||||
}
|
||||
|
||||
/// Root directory for the server launcher
|
||||
|
||||
Reference in New Issue
Block a user