Commit graph

106 commits

Author SHA1 Message Date
Félix Saparelli
adef01f3dd
Find best download source out of alternatives (format extension) (#236) 2022-07-24 14:32:23 +12:00
Jiahao XU
1768392413
Merge pull request #228 from NobodyXu/fix/skip-on-custom-install
Fix updating metafiles: Skip on custom install path
2022-07-23 19:57:58 +10:00
Jiahao XU
5367b366d1
Use home::cargo_home in helpers::cargo_home
Signed-off-by: Jiahao XU <Jiahao_XU@outlook.com>
2022-07-23 19:17:47 +10:00
Jiahao XU
b4d2e9b99c
Fix get_install_path where cargo_home succeeds
The returned path must join with `"bin"`.

Signed-off-by: Jiahao XU <Jiahao_XU@outlook.com>
2022-07-23 19:16:23 +10:00
Jiahao XU
49f665d680
Fix confusing comment in helpers::cargo_home
Signed-off-by: Jiahao XU <Jiahao_XU@outlook.com>
2022-07-23 19:10:15 +10:00
Jiahao XU
5bf2b4e45d
Fix helpers::cargo_home: home::cargo_home is buggy
Signed-off-by: Jiahao XU <Jiahao_XU@outlook.com>
2022-07-23 19:08:29 +10:00
Jiahao XU
5ea66574c3
Mod get_install_path to ret Arc<Path> instead of PathBuf
Signed-off-by: Jiahao XU <Jiahao_XU@outlook.com>
2022-07-23 18:37:59 +10:00
Jiahao XU
5620810c55
Simplify get_install_path using cargo_home
Signed-off-by: Jiahao XU <Jiahao_XU@outlook.com>
2022-07-23 18:36:01 +10:00
Jiahao XU
79476e490b
Fix custom_install_path detection
Installing to `CARGO_INSTALL_ROOT` or the local executable dir should be
considered a custom installation path.

Signed-off-by: Jiahao XU <Jiahao_XU@outlook.com>
2022-07-23 18:33:30 +10:00
Jiahao XU
d9fe7bfaf4
Fix bug in helpers::create_if_not_exist
Returned `File` must be both readable and writable.

Signed-off-by: Jiahao XU <Jiahao_XU@outlook.com>
2022-07-22 22:40:00 +10:00
Jiahao XU
09d210bf62
Simplify helpers::create_if_not_exist implementation
Signed-off-by: Jiahao XU <Jiahao_XU@outlook.com>
2022-07-22 22:32:45 +10:00
Jiahao XU
05115641ff
Add new fn helpers::create_if_not_exist
Signed-off-by: Jiahao XU <Jiahao_XU@outlook.com>
2022-07-22 22:12:16 +10:00
Jiahao XU
9e45ba1032
Impl new RAII type helpers::flock::FileLock
that locks a file exclusive or shared

Signed-off-by: Jiahao XU <Jiahao_XU@outlook.com>
2022-07-22 19:48:37 +10:00
Jiahao XU
6964eee5d1
Merge pull request #223 from NobodyXu/fix/join-err
Fix: join err handling, unify it using `BinstallError`
2022-07-22 11:29:21 +10:00
Jiahao XU
6e5ecc46cf
Construct BinstallError from JoinError in await_task
Signed-off-by: Jiahao XU <Jiahao_XU@outlook.com>
2022-07-21 20:41:16 +10:00
Jiahao XU
21eac33e1f
Optimize: Create new fn helpers::cargo_home
that caches return value of `home::cargo_home`

Signed-off-by: Jiahao XU <Jiahao_XU@outlook.com>
2022-07-21 13:13:07 +10:00
Jiahao XU
a1d7a7c117
Refactor: Extract new mod jobserver_client.rs
Signed-off-by: Jiahao XU <Jiahao_XU@outlook.com>
2022-07-20 17:37:23 +10:00
Jiahao XU
b223990bb1
Simplify helpers::await_task API
Signed-off-by: Jiahao XU <Jiahao_XU@outlook.com>
2022-07-19 00:35:48 +10:00
Jiahao XU
072253ebae
Improve comment in create_jobserver_client
Signed-off-by: Jiahao XU <Jiahao_XU@outlook.com>
2022-07-19 00:32:56 +10:00
Jiahao XU
c67c59b3ca
Impl new fn helpers::create_jobserver_client
Signed-off-by: Jiahao XU <Jiahao_XU@outlook.com>
2022-07-18 21:04:36 +10:00
Jiahao XU
5e7aab7373
Impl helpers::await_task: Handle JoinError
Signed-off-by: Jiahao XU <Jiahao_XU@outlook.com>
2022-07-18 16:46:21 +10:00
Jiahao XU
38c8bc8cf2
Impl new type helpes::CrateName
Signed-off-by: Jiahao XU <Jiahao_XU@outlook.com>
2022-07-12 16:47:44 +10:00
Jiahao XU
fa63dbe5cf
Refactor: Rm global var helpers::CLIENT
Signed-off-by: Jiahao XU <Jiahao_XU@outlook.com>
2022-07-10 18:07:07 +10:00
Jiahao XU
5ad572fa42
Rename new_reqwest_client > get_reqwest_client
Signed-off-by: Jiahao XU <Jiahao_XU@outlook.com>
2022-07-05 19:57:56 +10:00
Jiahao XU
6582eefd25
Refactor: Replace REQWESTCONFIG with initialize_reqwest_client
so that we don't need two `OnceCell`s.

Signed-off-by: Jiahao XU <Jiahao_XU@outlook.com>
2022-07-05 19:57:54 +10:00
Jiahao XU
50b436100e
Reuse Client everywhere instead of recreate one
which pools the connection to the same site (github.com).

This commit also sets `USER_AGENT` so that quickinstall
can reuse it.

Signed-off-by: Jiahao XU <Jiahao_XU@outlook.com>
2022-07-05 19:57:14 +10:00
Félix Saparelli
7518993212
Merge pull request #195 from NobodyXu/feature/atomic-install 2022-07-05 21:52:06 +12:00
Félix Saparelli
1c2d005fd4
Write to .crates.toml 2022-07-04 23:53:47 +12:00
Félix Saparelli
66a14d0c7c
Polish up new secure options 2022-06-28 03:19:04 +12:00
Jiahao XU
77ce57815c
Impl new fn helpers::symlink_file
Signed-off-by: Jiahao XU <Jiahao_XU@outlook.com>
2022-06-23 23:26:30 +10:00
Jiahao XU
d4105585db
Fix atomic_install: Copy permissions of src
Signed-off-by: Jiahao XU <Jiahao_XU@outlook.com>
2022-06-23 22:50:30 +10:00
Jiahao XU
7616546a61
Impl new fn atomic_install for atommically installing a file
Signed-off-by: Jiahao XU <Jiahao_XU@outlook.com>
2022-06-23 21:27:15 +10:00
Jiahao XU
e18ac6e117
Run Manifest parsing in block_in_place mode
Signed-off-by: Jiahao XU <Jiahao_XU@outlook.com>
2022-06-23 19:55:09 +10:00
Jiahao XU
60caa9ee17
Run load_manifest_path in block_in_place mode
Signed-off-by: Jiahao XU <Jiahao_XU@outlook.com>
2022-06-23 19:50:25 +10:00
Jiahao XU
691bc18dd0
Set min TLS ver to 1.2 for https only mode
Signed-off-by: Jiahao XU <Jiahao_XU@outlook.com>
2022-06-23 13:03:50 +10:00
Jiahao XU
9b62ebdae1
Fix https only mode: It should not be http2 only
Signed-off-by: Jiahao XU <Jiahao_XU@outlook.com>
2022-06-23 13:01:22 +10:00
Jiahao XU
a3ab3ec502
Add new static var REQWESTGLOBALCONFIG
Signed-off-by: Jiahao XU <Jiahao_XU@outlook.com>
2022-06-23 13:01:22 +10:00
Jiahao XU
eb7d460a9a
Add new enum TLSVersion which impl ArgEnum
and can be converted to `reqwest::tls::Version`

Signed-off-by: Jiahao XU <Jiahao_XU@outlook.com>
2022-06-23 13:00:52 +10:00
Jiahao XU
8e92db3dc6
Refactor: Extract new_reqwest_client(_builder)
Signed-off-by: Jiahao XU <Jiahao_XU@outlook.com>
2022-06-23 13:00:52 +10:00
Jiahao XU
74a6e137be
Refactor: Mv debug! into create_request
Signed-off-by: Jiahao XU <Jiahao_XU@outlook.com>
2022-06-21 13:47:00 +10:00
Jiahao XU
621a641529
Rm unused items in mod helpers
Signed-off-by: Jiahao XU <Jiahao_XU@outlook.com>
2022-06-18 18:10:22 +10:00
Jiahao XU
0480e99460
Impl newtype StreamReadable
It wraps a `Stream<Item = Result<Bytes, E>>` and implements `Read` and
`BufRead` on it so that it can be used on sync context.

Signed-off-by: Jiahao XU <Jiahao_XU@outlook.com>
2022-06-18 17:29:50 +10:00
Jiahao XU
2091345ce0
Refactor: Mv TarEntriesVisitor to mod async_extracter
Signed-off-by: Jiahao XU <Jiahao_XU@outlook.com>
2022-06-13 01:14:22 +10:00
Jiahao XU
225cf74cd9
Refactor: Ret impl Stream in create_request
Since both `download*` function takes a `impl Stream` and the
`Response::bytes_stream` takes `Response` by value, thus there is no
lifetime issue and we can return `impl Stream` instead of `Response`

Signed-off-by: Jiahao XU <Jiahao_XU@outlook.com>
2022-06-12 20:01:43 +10:00
Jiahao XU
e39549f470
Improve debug! logging in download_and_extract
Signed-off-by: Jiahao XU <Jiahao_XU@outlook.com>
2022-06-12 17:08:22 +10:00
Jiahao XU
f25306ff97
Simplify download_tar_based_and_visit: Rm unused param
`path`

Signed-off-by: Jiahao XU <Jiahao_XU@outlook.com>
2022-06-12 17:07:29 +10:00
Jiahao XU
e376b71cf4
Simplify extract_tar_based_stream_and_visit
Rm unused param `path` and the unnecessary
`fs::create_dir_all` since the tar will not be extracted to disk.

Signed-off-by: Jiahao XU <Jiahao_XU@outlook.com>
2022-06-12 17:05:35 +10:00
Jiahao XU
f82890cba3
Rm download_and_extract_with_filter
Signed-off-by: Jiahao XU <Jiahao_XU@outlook.com>
2022-06-12 16:42:32 +10:00
Jiahao XU
cb2be5a882
Add new trait PathExt & impl for Path
Signed-off-by: Jiahao XU <Jiahao_XU@outlook.com>
2022-06-12 01:46:10 +10:00
Jiahao XU
f8c8c66f57
Impl new fn helpers::download_tar_based_and_visit
Signed-off-by: Jiahao XU <Jiahao_XU@outlook.com>
2022-06-11 20:38:11 +10:00