Jiahao XU
1766b92547
Add new fn Crates2Json::write_to_writer
...
Signed-off-by: Jiahao XU <Jiahao_XU@outlook.com>
2022-07-22 22:45:55 +10:00
Jiahao XU
15e2213225
Add new fn Crates2Json::load_from_reader
...
Signed-off-by: Jiahao XU <Jiahao_XU@outlook.com>
2022-07-22 22:44:28 +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
d7bd96660e
Fix CratesToml::append_to_path
: Lock file to avoid race condition
...
Signed-off-by: Jiahao XU <Jiahao_XU@outlook.com>
2022-07-22 22:22:31 +10:00
Jiahao XU
e1b6fb85aa
Add new fn CratesToml::write_to_file
...
Signed-off-by: Jiahao XU <Jiahao_XU@outlook.com>
2022-07-22 22:22:18 +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
1cfdd3b8bc
Merge pull request #225 from NobodyXu/fix/tempdir
...
Fix: Create `temp_dir` in `install_path`
2022-07-22 21:55:38 +10:00
Jiahao XU
7311f77f29
Impl new fn CratesToml::write_to_writer
...
Signed-off-by: Jiahao XU <Jiahao_XU@outlook.com>
2022-07-22 20:19:04 +10:00
Jiahao XU
565b404dce
Impl fn CratesToml::load_from_reader
...
Signed-off-by: Jiahao XU <Jiahao_XU@outlook.com>
2022-07-22 20:15:03 +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
751cf47716
Add new dep fs4 v0.6.2
...
Signed-off-by: Jiahao XU <Jiahao_XU@outlook.com>
2022-07-22 19:42:33 +10:00
Jiahao XU
95c30122e9
Rm unused import tempfile::TempDir
in main.rs
...
Signed-off-by: Jiahao XU <Jiahao_XU@outlook.com>
2022-07-22 19:17:23 +10:00
Jiahao XU
fb35863faa
Create temp_dir
in install_path
...
Signed-off-by: Jiahao XU <Jiahao_XU@outlook.com>
2022-07-22 19:17:09 +10:00
Jiahao XU
d21dde4889
Merge pull request #226 from NobodyXu/fix/metafile-update
...
Fix race condition when updating metafile
2022-07-22 19:15:36 +10:00
Jiahao XU
92f4d0af95
Fix metafile updating: Update them in entry
only
...
to avoid race condition.
Signed-off-by: Jiahao XU <Jiahao_XU@outlook.com>
2022-07-22 17:58:29 +10:00
Jiahao XU
488e7b8492
Update CratesToml::append
to accept iter
...
intead of one single pair of value.
Signed-off-by: Jiahao XU <Jiahao_XU@outlook.com>
2022-07-22 17:57:51 +10:00
Jiahao XU
739b3ee247
Update Crates2Json::append
to accept iter
...
instead of one single pair of value.
Signed-off-by: Jiahao XU <Jiahao_XU@outlook.com>
2022-07-22 17:57:25 +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
adbc587f3b
Merge pull request #222 from NobodyXu/refactor
...
Refactor: Make appending to metafiles easier and fix their err handling
2022-07-22 11:29:12 +10:00
Jiahao XU
4716389a52
Merge pull request #221 from NobodyXu/optimize
...
Minor Optimization
2022-07-22 11:27:13 +10:00
Jiahao XU
32b98f0c5a
Fix Deserialize
for CrateVersionSource
...
Use `Cow::<'_, str>::deserialize` to ensure that it would still work
even if it contains escaped characters.
Signed-off-by: Jiahao XU <Jiahao_XU@outlook.com>
2022-07-22 01:43:40 +10:00
Jiahao XU
a3fcc298ab
Avoid CrateVersionSource::clone
for insertion in metafiles
...
Signed-off-by: Jiahao XU <Jiahao_XU@outlook.com>
2022-07-22 01:38:44 +10:00
Jiahao XU
de9404feda
Optimize Crates2Json
: Use String
as key
...
to avoid cost of deserializing (`CrateVersionSource::from_str`).
Signed-off-by: Jiahao XU <Jiahao_XU@outlook.com>
2022-07-22 01:37:27 +10:00
Jiahao XU
96aaca1cc6
Optimize CratesToml
: Use String
as key
...
to avoid cost of deserializing (`CrateVersionSource::from_str`).
Signed-off-by: Jiahao XU <Jiahao_XU@outlook.com>
2022-07-22 01:36:22 +10:00
Jiahao XU
9d9a31bef3
Optimize Deserialize
impl for CrateVersionSource
...
Use `<&str>::deserialize` instead of `String::deserialize` to avoid
intermediate `String`.
Signed-off-by: Jiahao XU <Jiahao_XU@outlook.com>
2022-07-22 01:23:58 +10:00
Jiahao XU
c2ce265afa
Optimize Crates2Json::write_to_path
: Use to_writer
...
which avoids allocating a `Vec<u8>` just to hold serialized data.
Signed-off-by: Jiahao XU <Jiahao_XU@outlook.com>
2022-07-21 22:18:08 +10:00
Jiahao XU
d7ae1f242b
Optimize Crates2Json::load_from_path
: Use from_reader
...
which avoids reading the entire file into string at once.
Signed-off-by: Jiahao XU <Jiahao_XU@outlook.com>
2022-07-21 22:14:20 +10:00
Jiahao XU
adc0a22a50
Rm unused variant MainExit::JoinErr
...
Signed-off-by: Jiahao XU <Jiahao_XU@outlook.com>
2022-07-21 20:44:13 +10:00
Jiahao XU
d39bc0acab
Construct BinstallError
from JoinError
in main
...
Signed-off-by: Jiahao XU <Jiahao_XU@outlook.com>
2022-07-21 20:43:47 +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
46cf20a3f7
Add new variant BinstallError::TaskJoinError
...
Signed-off-by: Jiahao XU <Jiahao_XU@outlook.com>
2022-07-21 20:40:31 +10:00
Jiahao XU
fb3e35624b
Fix err handling in Crates2Json::append_to_path
...
Only uses `Self::default()` if the file is not found.
Signed-off-by: Jiahao XU <Jiahao_XU@outlook.com>
2022-07-21 19:59:36 +10:00
Jiahao XU
1e725a9ffe
Refactor: Extract Crates2Json::append{_to_path}
...
Signed-off-by: Jiahao XU <Jiahao_XU@outlook.com>
2022-07-21 19:58:23 +10:00
Jiahao XU
0157a594e6
Fix err handling in CratesToml::append_to_path
...
Make it more robust to `io::Error`: Only create a `Self::default()` if
fails to open the file.
Signed-off-by: Jiahao XU <Jiahao_XU@outlook.com>
2022-07-21 19:54:45 +10:00
Jiahao XU
31d9716d28
Refactor: Extract CratesToml::append{_to_path}
...
Signed-off-by: Jiahao XU <Jiahao_XU@outlook.com>
2022-07-21 19:50:23 +10:00
Jiahao XU
4f0f01b75c
Fix typo in impl Version for crates_io_api::Version
...
Signed-off-by: Jiahao XU <Jiahao_XU@outlook.com>
2022-07-21 19:20:21 +10:00
Jiahao XU
e308b275d5
Optimize and generalize find_version
...
- Rm the process of collecting into `BTreeMap` in `find_version`.
- Accept any type that implements trait `Version`
Signed-off-by: Jiahao XU <Jiahao_XU@outlook.com>
2022-07-21 19:19:50 +10:00
Jiahao XU
b2d09e2b13
Rm unused derive(Clone)
for DesiredTargets
...
Signed-off-by: Jiahao XU <Jiahao_XU@outlook.com>
2022-07-21 15:07:09 +10:00
Jiahao XU
eda7b9445a
Rm unnecessary Arc
inside DesiredTargetsInner
...
Since `DesiredTargets` is now stored in `binstall::Options`, which
itself is wrapped in an `Arc`, `DesiredTargetsInner::Initialized` no
longer needs an `Arc` for O(1) `clone`.
Signed-off-by: Jiahao XU <Jiahao_XU@outlook.com>
2022-07-21 15:06:00 +10:00
Jiahao XU
6a95bb07e0
Add field desired_targets
to binstall::Options
...
Signed-off-by: Jiahao XU <Jiahao_XU@outlook.com>
2022-07-21 15:05:12 +10:00
Jiahao XU
aa88dce215
Add field cli_overrides
to binstall::Options
...
Signed-off-by: Jiahao XU <Jiahao_XU@outlook.com>
2022-07-21 15:00:01 +10:00
Jiahao XU
f09004b5b7
Optimize: Share crates_io_api::AsyncClient
...
So that the connection pool and the rate limit will be shared.
Signed-off-by: Jiahao XU <Jiahao_XU@outlook.com>
2022-07-21 14:50:51 +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
305a4e4c30
Improve err msg in MultiFetcher::first_available
...
Signed-off-by: Jiahao XU <Jiahao_XU@outlook.com>
2022-07-21 13:07:20 +10:00
Jiahao XU
dc8d8ccd88
Optimize MultiFetcher
: Start check
ing ASAP
...
Signed-off-by: Jiahao XU <Jiahao_XU@outlook.com>
2022-07-21 13:06:34 +10:00
Jiahao XU
6180e9ec3e
Add comment in fn resolve
...
Signed-off-by: Jiahao XU <Jiahao_XU@outlook.com>
2022-07-21 13:00:58 +10:00
Jiahao XU
c418c2dbbe
Optimize arg parsing: Avoid O(n) Vec::remove
...
Signed-off-by: Jiahao XU <Jiahao_XU@outlook.com>
2022-07-21 12:44:54 +10:00
Jiahao XU
ef72f851f7
Merge pull request #220 from NobodyXu/fix
...
Forbid --manifest-path to used with batch installation
2022-07-20 19:39:38 +10:00
Jiahao XU
cfe7703af9
Forbid --manifest-path
to used with batch installation
...
Signed-off-by: Jiahao XU <Jiahao_XU@outlook.com>
2022-07-20 19:11:02 +10:00