apt transaction pharser
This commit is contained in:
parent
db57290b09
commit
2d2ea055cf
@ -9,11 +9,7 @@
|
||||
<component name="ChangeListManager">
|
||||
<list default="true" id="df2ca9e1-e07d-43f4-bc68-0a6113fc1fa2" name="Changes" comment="">
|
||||
<change beforePath="$PROJECT_DIR$/.idea/workspace.xml" beforeDir="false" afterPath="$PROJECT_DIR$/.idea/workspace.xml" afterDir="false" />
|
||||
<change beforePath="$PROJECT_DIR$/src/apt_package_row/imp.rs" beforeDir="false" afterPath="$PROJECT_DIR$/src/apt_package_row/imp.rs" afterDir="false" />
|
||||
<change beforePath="$PROJECT_DIR$/src/apt_update/main.rs" beforeDir="false" afterPath="$PROJECT_DIR$/src/apt_update/main.rs" afterDir="false" />
|
||||
<change beforePath="$PROJECT_DIR$/src/apt_update_page/mod.rs" beforeDir="false" afterPath="$PROJECT_DIR$/src/apt_update_page/mod.rs" afterDir="false" />
|
||||
<change beforePath="$PROJECT_DIR$/src/apt_update_page/process.rs" beforeDir="false" afterPath="$PROJECT_DIR$/src/apt_update_page/process.rs" afterDir="false" />
|
||||
<change beforePath="$PROJECT_DIR$/src/build_ui/mod.rs" beforeDir="false" afterPath="$PROJECT_DIR$/src/build_ui/mod.rs" afterDir="false" />
|
||||
</list>
|
||||
<option name="SHOW_DIALOG" value="false" />
|
||||
<option name="HIGHLIGHT_CONFLICTS" value="true" />
|
||||
@ -116,7 +112,7 @@
|
||||
<workItem from="1720423242486" duration="3396000" />
|
||||
<workItem from="1720476457389" duration="7123000" />
|
||||
<workItem from="1720502207843" duration="3142000" />
|
||||
<workItem from="1720556059466" duration="3551000" />
|
||||
<workItem from="1720556059466" duration="5702000" />
|
||||
</task>
|
||||
<servers />
|
||||
</component>
|
||||
|
@ -1,3 +1,47 @@
|
||||
pub fn apt_process_update(excluded_updates_vec: &Vec<String>) {
|
||||
dbg!(excluded_updates_vec);
|
||||
use rust_apt::new_cache;
|
||||
use rust_apt::cache::Upgrade;
|
||||
|
||||
#[derive(Debug)]
|
||||
struct AptChangesInfo {
|
||||
package_count: u64,
|
||||
total_download_size: u64,
|
||||
total_installed_size: u64
|
||||
}
|
||||
|
||||
impl AptChangesInfo {
|
||||
fn add_package(&mut self) {
|
||||
self.package_count += 1;
|
||||
}
|
||||
|
||||
fn increase_total_download_size_by(&mut self, value: u64) {
|
||||
self.total_download_size += value;
|
||||
}
|
||||
|
||||
fn increase_total_installed_size_by(&mut self, value: u64) {
|
||||
self.total_installed_size += value;
|
||||
}
|
||||
}
|
||||
|
||||
pub fn apt_process_update(excluded_updates_vec: &Vec<String>) {
|
||||
|
||||
// Emulate Apt Full Upgrade to get transaction info
|
||||
let mut apt_changes_struct = AptChangesInfo {
|
||||
package_count: 0,
|
||||
total_download_size: 0,
|
||||
total_installed_size: 0
|
||||
};
|
||||
|
||||
let apt_cache = new_cache!().unwrap();
|
||||
|
||||
apt_cache.upgrade(Upgrade::FullUpgrade).unwrap();
|
||||
|
||||
for change in apt_cache.get_changes(false) {
|
||||
if !excluded_updates_vec.iter().any(|e| change.name().contains(e)) {
|
||||
apt_changes_struct.add_package();
|
||||
apt_changes_struct.increase_total_download_size_by(change.candidate().unwrap().size());
|
||||
apt_changes_struct.increase_total_installed_size_by(change.candidate().unwrap().installed_size());
|
||||
}
|
||||
}
|
||||
|
||||
dbg!(apt_changes_struct);
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user