Skip to content

Commit

Permalink
Revert "Support sqlite bundle system in windows (#879)"
Browse files Browse the repository at this point in the history
This reverts commit 474dfce.
  • Loading branch information
bigfoodK authored Jun 29, 2024
1 parent 474dfce commit ca4de18
Show file tree
Hide file tree
Showing 4 changed files with 22 additions and 17 deletions.
8 changes: 5 additions & 3 deletions namui/namui-cli/src/services/bundle/bundle_to_sqlite.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,15 +2,17 @@ use super::*;
use anyhow::Result;
use rayon::prelude::*;
use rusqlite::{Connection, DatabaseName, OptionalExtension};
use std::{collections::HashSet, fs::create_dir_all, io, time::UNIX_EPOCH};
use std::{
collections::HashSet,
io::{self},
time::UNIX_EPOCH,
};

pub fn bundle_to_sqlite(
sqlite_path: impl AsRef<std::path::Path>,
collect_operations: Vec<CollectOperation>,
) -> Result<()> {
let sqlite_path = sqlite_path.as_ref().to_path_buf();
create_dir_all(sqlite_path.parent().unwrap())?;
println!("{sqlite_path:#?}");
let create_conn = || Connection::open(&sqlite_path).unwrap();
let conn = create_conn();

Expand Down
2 changes: 1 addition & 1 deletion namui/namui-cli/src/services/resource_collect_service.rs
Original file line number Diff line number Diff line change
Expand Up @@ -17,10 +17,10 @@ pub fn collect_all(
let mut ops: Vec<CollectOperation> = vec![];
collect_runtime(&mut ops, additional_runtime_path, target)?;
collect_rust_build(&mut ops, &project_path, target, release)?;
collect_bundle(&bundle_manifest, &dest_path)?;
collect_deep_link_manifest(&mut ops, &project_path, target)?;

collect_resources(&project_path, &dest_path, ops)?;
collect_bundle(&bundle_manifest, &dest_path)?;

bundle_manifest.create_bundle_metadata_file(&dest_path)?;
Ok(())
Expand Down
2 changes: 1 addition & 1 deletion namui/namui/src/namui/system/file/bundle/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ fn bundle_sqlite_path() -> io::Result<PathBuf> {
Ok(std::env::current_exe()?
.parent()
.ok_or_else(|| io::Error::new(ErrorKind::Other, anyhow!("No parent")))?
.join("bundle.sqlite"))
.join("bundle.sqlite?immutable=1"))
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,40 +5,43 @@ pub async fn load_all_typefaces() -> Result<()> {
let default_typefaces = [
(
"NotoSansKR-Bold",
"__system__/font/Ko/NotoSansKR-Bold.woff2",
crate::Url::parse("__system__/font/Ko/NotoSansKR-Bold.woff2").unwrap(),
),
(
"NotoSansKR-Light",
"__system__/font/Ko/NotoSansKR-Light.woff2",
crate::Url::parse("__system__/font/Ko/NotoSansKR-Light.woff2").unwrap(),
),
(
"NotoSansKR-Medium",
"__system__/font/Ko/NotoSansKR-Medium.woff2",
crate::Url::parse("__system__/font/Ko/NotoSansKR-Medium.woff2").unwrap(),
),
(
"NotoSansKR-Regular",
"__system__/font/Ko/NotoSansKR-Regular.woff2",
crate::Url::parse("__system__/font/Ko/NotoSansKR-Regular.woff2").unwrap(),
),
(
"NotoSansKR-Thin",
"__system__/font/Ko/NotoSansKR-Thin.woff2",
crate::Url::parse("__system__/font/Ko/NotoSansKR-Thin.woff2").unwrap(),
),
(
"NotoColorEmoji",
crate::Url::parse("__system__/font/NotoColorEmoji.woff2").unwrap(),
),
("NotoColorEmoji", "__system__/font/NotoColorEmoji.woff2"),
(
"NotoSansKR-Black",
"__system__/font/Ko/NotoSansKR-Black.woff2",
crate::Url::parse("__system__/font/Ko/NotoSansKR-Black.woff2").unwrap(),
),
];

try_join_all(
default_typefaces
.into_iter()
.map(|(typeface_name, path)| async move {
let bytes = get_file_from_bundle_with_cached(&path)
.map(|(typeface_name, url)| async move {
let bytes = get_file_from_bundle_with_cached(&url)
.await
.map_err(|error| {
eprintln!("error: {:?}", error);
anyhow!("Could not fetch {}: {}", path, error)
anyhow!("Could not fetch {}: {}", url, error)
})?;

crate::system::typeface::register_typeface(typeface_name.to_string(), bytes)
Expand All @@ -52,7 +55,7 @@ pub async fn load_all_typefaces() -> Result<()> {
Ok(())
}

async fn get_file_from_bundle_with_cached(url: &str) -> Result<Vec<u8>> {
let file = crate::file::bundle::read(url).await?;
async fn get_file_from_bundle_with_cached(url: &crate::Url) -> Result<Vec<u8>> {
let file = crate::file::bundle::read(url.clone()).await?;
Ok(file)
}

0 comments on commit ca4de18

Please sign in to comment.