Skip to content

Commit

Permalink
cache: Separate caches by platform
Browse files Browse the repository at this point in the history
  • Loading branch information
cohaereo committed Jul 22, 2024
1 parent 9fbfefe commit e56dbcb
Show file tree
Hide file tree
Showing 7 changed files with 43 additions and 15 deletions.
34 changes: 30 additions & 4 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ rayon = "1.8.0"
base64 = "0.22.0"
bincode = "2.0.0-rc.3"
binrw = "0.13.3"
destiny-pkg = { version = "0.11", features = ["bincode"] }
destiny-pkg = { version = "0.12", features = ["bincode"] }
serde = { version = "1.0.188", features = ["derive"] }
serde_json = "1.0.108"
vgmstream = { git = "https://github.com/cohaereo/vgmstream-rs/", version = "0.1.3" }
Expand Down
4 changes: 2 additions & 2 deletions src/gui/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -93,7 +93,7 @@ pub struct QuickTagApp {

impl QuickTagApp {
/// Called once before the first frame.
pub fn new(cc: &eframe::CreationContext<'_>, version: GameVersion) -> Self {
pub fn new(cc: &eframe::CreationContext<'_>) -> Self {
let mut fonts = egui::FontDefinitions::default();
fonts.font_data.insert(
"Destiny_Keys".into(),
Expand All @@ -115,7 +115,7 @@ impl QuickTagApp {
scanner_context: scanner::create_scanner_context(&package_manager())
.expect("Failed to create scanner context"),
cache_load: Some(Promise::spawn_thread("load_cache", move || {
load_tag_cache(version)
load_tag_cache()
})),
tag_history: Rc::new(RefCell::new(TagHistory::default())),
cache: Default::default(),
Expand Down
2 changes: 1 addition & 1 deletion src/gui/tag.rs
Original file line number Diff line number Diff line change
Expand Up @@ -652,7 +652,7 @@ impl TagView {
.package_paths
.get(&tag.pkg_id())
.map(|p| {
p.name
p.filename
.to_lowercase()
.contains(&self.search_package_name_filter.to_lowercase())
})
Expand Down
8 changes: 4 additions & 4 deletions src/gui/texture.rs
Original file line number Diff line number Diff line change
Expand Up @@ -294,7 +294,7 @@ impl Texture {
if package_manager().version.is_d1()
&& !matches!(
package_manager().platform,
PackagePlatform::PS4 | PackagePlatform::XOne
PackagePlatform::PS4 | PackagePlatform::XboxOne
)
{
anyhow::bail!("Textures are not supported for D1");
Expand All @@ -313,7 +313,7 @@ impl Texture {
premultiply_alpha: false,
})
}
PackagePlatform::XOne => {
PackagePlatform::XboxOne => {
let texture: TextureHeaderRoiXbox = package_manager().read_tag_binrw(hash)?;
Ok(TextureDesc {
format: texture.format.to_wgpu()?,
Expand Down Expand Up @@ -364,7 +364,7 @@ impl Texture {
if package_manager().version.is_d1()
&& !matches!(
package_manager().platform,
PackagePlatform::PS4 | PackagePlatform::XOne
PackagePlatform::PS4 | PackagePlatform::XboxOne
)
{
anyhow::bail!("Textures are not supported for D1");
Expand All @@ -389,7 +389,7 @@ impl Texture {
Some(comment),
)
}
PackagePlatform::XOne => {
PackagePlatform::XboxOne => {
anyhow::bail!("Xbox One textures are not supported yet");
let (texture, texture_data, comment) = Self::load_data_roi_xone(hash, true)?;
Self::create_texture(
Expand Down
3 changes: 2 additions & 1 deletion src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,7 @@ fn main() -> eframe::Result<()> {
let pm = PackageManager::new(
packages_path,
args.version.unwrap_or(GameVersion::Destiny2TheFinalShape),
None
)
.unwrap();

Expand Down Expand Up @@ -98,7 +99,7 @@ fn main() -> eframe::Result<()> {
eframe::run_native(
"Quicktag",
native_options,
Box::new(|cc| Ok(Box::new(QuickTagApp::new(cc, package_manager().version)))),
Box::new(|cc| Ok(Box::new(QuickTagApp::new(cc)))),
)
}

Expand Down
5 changes: 3 additions & 2 deletions src/scanner.rs
Original file line number Diff line number Diff line change
Expand Up @@ -292,8 +292,8 @@ pub fn scanner_progress() -> ScanStatus {
*SCANNER_PROGRESS.read()
}

pub fn load_tag_cache(version: GameVersion) -> TagCache {
let cache_name = format!("tags_{}.cache", version.id());
pub fn load_tag_cache() -> TagCache {
let cache_name = format!("tags_{}.cache", package_manager().cache_key());
let cache_file_path = exe_relative_path(&cache_name);

if let Ok(cache_file) = File::open(&cache_file_path) {
Expand Down Expand Up @@ -388,6 +388,7 @@ pub fn load_tag_cache(version: GameVersion) -> TagCache {
.cloned()
.collect_vec();

let version = package_manager().version;
let package_count = all_pkgs.len();
let cache: FxHashMap<TagHash, ScanResult> = all_pkgs
.par_iter()
Expand Down

0 comments on commit e56dbcb

Please sign in to comment.