Force unix path separators for engine values #47

Merged
lucas merged 1 commit from issue/46 into master 2023-03-03 17:37:28 +01:00
9 changed files with 29 additions and 9 deletions

View file

@ -7,6 +7,10 @@
- dtmt: split `build` into `build` and `package` - dtmt: split `build` into `build` and `package`
- dtmt: implement deploying built bundles - dtmt: implement deploying built bundles
=== Fixed
- all: force unix path separators for engine values
== 2023-03-01 == 2023-03-01
=== Added === Added

9
Cargo.lock generated
View file

@ -676,6 +676,7 @@ dependencies = [
"dtmt-shared", "dtmt-shared",
"futures", "futures",
"oodle-sys", "oodle-sys",
"path-slash",
"sdk", "sdk",
"serde", "serde",
"serde_sjson", "serde_sjson",
@ -704,6 +705,7 @@ dependencies = [
"nanorand", "nanorand",
"oodle-sys", "oodle-sys",
"path-clean", "path-clean",
"path-slash",
"pin-project-lite", "pin-project-lite",
"promptly", "promptly",
"sdk", "sdk",
@ -1699,6 +1701,12 @@ version = "1.0.1"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "17359afc20d7ab31fdb42bb844c8b3bb1dabd7dcf7e68428492da7f16966fcef" checksum = "17359afc20d7ab31fdb42bb844c8b3bb1dabd7dcf7e68428492da7f16966fcef"
[[package]]
name = "path-slash"
version = "0.2.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "1e91099d4268b0e11973f036e885d652fb0b21fedcf69738c627f94db6a44f42"
[[package]] [[package]]
name = "pbkdf2" name = "pbkdf2"
version = "0.11.0" version = "0.11.0"
@ -2045,6 +2053,7 @@ dependencies = [
"luajit2-sys", "luajit2-sys",
"nanorand", "nanorand",
"oodle-sys", "oodle-sys",
"path-slash",
"pin-project-lite", "pin-project-lite",
"serde", "serde",
"serde_sjson", "serde_sjson",

View file

@ -23,3 +23,4 @@ tracing-error = "0.2.0"
tracing-subscriber = { version = "0.3.16", features = ["env-filter"] } tracing-subscriber = { version = "0.3.16", features = ["env-filter"] }
zip = "0.6.4" zip = "0.6.4"
tokio-stream = { version = "0.1.12", features = ["fs"] } tokio-stream = { version = "0.1.12", features = ["fs"] }
path-slash = "0.2.1"

View file

@ -8,6 +8,7 @@ use color_eyre::eyre::Context;
use color_eyre::{eyre, Help, Result}; use color_eyre::{eyre, Help, Result};
use futures::stream; use futures::stream;
use futures::StreamExt; use futures::StreamExt;
use path_slash::PathBufExt;
use sdk::filetype::lua; use sdk::filetype::lua;
use sdk::filetype::package::Package; use sdk::filetype::package::Package;
use sdk::murmur::Murmur64; use sdk::murmur::Murmur64;
@ -153,22 +154,22 @@ fn build_mod_data_lua(state: Arc<State>) -> String {
lua.push_str(" new_mod(\""); lua.push_str(" new_mod(\"");
lua.push_str(&mod_info.id); lua.push_str(&mod_info.id);
lua.push_str("\", {\n mod_script = \""); lua.push_str("\", {\n mod_script = \"");
lua.push_str(&resources.init.to_string_lossy()); lua.push_str(&resources.init.to_slash_lossy());
if let Some(data) = resources.data.as_ref() { if let Some(data) = resources.data.as_ref() {
lua.push_str("\",\n mod_data = \""); lua.push_str("\",\n mod_data = \"");
lua.push_str(&data.to_string_lossy()); lua.push_str(&data.to_slash_lossy());
} }
if let Some(localization) = &resources.localization { if let Some(localization) = &resources.localization {
lua.push_str("\",\n mod_localization = \""); lua.push_str("\",\n mod_localization = \"");
lua.push_str(&localization.to_string_lossy()); lua.push_str(&localization.to_slash_lossy());
} }
lua.push_str("\",\n })\n"); lua.push_str("\",\n })\n");
} else { } else {
lua.push_str(" return dofile(\""); lua.push_str(" return dofile(\"");
lua.push_str(&resources.init.to_string_lossy()); lua.push_str(&resources.init.to_slash_lossy());
lua.push_str("\")\n"); lua.push_str("\")\n");
} }

View file

@ -29,6 +29,7 @@ tracing-subscriber = { version = "0.3.16", features = ["env-filter"] }
tracing = { version = "0.1.37", features = ["async-await"] } tracing = { version = "0.1.37", features = ["async-await"] }
zip = "0.6.3" zip = "0.6.3"
path-clean = "1.0.1" path-clean = "1.0.1"
path-slash = "0.2.1"
[dev-dependencies] [dev-dependencies]
tempfile = "3.3.0" tempfile = "3.3.0"

View file

@ -9,6 +9,7 @@ use color_eyre::{Help, Report};
use dtmt_shared::ModConfig; use dtmt_shared::ModConfig;
use futures::future::try_join_all; use futures::future::try_join_all;
use futures::StreamExt; use futures::StreamExt;
use path_slash::PathExt;
use sdk::filetype::package::Package; use sdk::filetype::package::Package;
use sdk::murmur::IdString64; use sdk::murmur::IdString64;
use sdk::{Bundle, BundleFile}; use sdk::{Bundle, BundleFile};
@ -134,7 +135,7 @@ where
path.set_extension(""); path.set_extension("");
BundleFile::from_sjson( BundleFile::from_sjson(
path.to_string_lossy().to_string(), path.to_slash_lossy().to_string(),
file_type, file_type,
sjson, sjson,
root.as_ref(), root.as_ref(),
@ -176,7 +177,7 @@ where
.await .await
.wrap_err_with(|| format!("failed to read file {}", path.display()))?; .wrap_err_with(|| format!("failed to read file {}", path.display()))?;
let pkg_name = package.to_string_lossy().to_string(); let pkg_name = package.to_slash_lossy().to_string();
let pkg = Package::from_sjson(sjson, pkg_name.clone(), root) let pkg = Package::from_sjson(sjson, pkg_name.clone(), root)
.await .await
.wrap_err_with(|| format!("invalid package file {}", &pkg_name))?; .wrap_err_with(|| format!("invalid package file {}", &pkg_name))?;

View file

@ -5,6 +5,7 @@ use std::path::PathBuf;
use clap::{value_parser, Arg, ArgMatches, Command}; use clap::{value_parser, Arg, ArgMatches, Command};
use color_eyre::eyre::{Context, Result}; use color_eyre::eyre::{Context, Result};
use color_eyre::Help; use color_eyre::Help;
use path_slash::PathBufExt;
use tokio::fs::{self, DirEntry}; use tokio::fs::{self, DirEntry};
use tokio_stream::wrappers::ReadDirStream; use tokio_stream::wrappers::ReadDirStream;
use tokio_stream::StreamExt; use tokio_stream::StreamExt;
@ -88,7 +89,7 @@ pub(crate) async fn run(_ctx: sdk::Context, matches: &ArgMatches) -> Result<()>
.await .await
.wrap_err_with(|| format!("failed to read mod config at {}", path.display()))?; .wrap_err_with(|| format!("failed to read mod config at {}", path.display()))?;
zip.start_file(name.to_string_lossy(), Default::default())?; zip.start_file(name.to_slash_lossy(), Default::default())?;
zip.write_all(&data)?; zip.write_all(&data)?;
} }
@ -111,7 +112,7 @@ pub(crate) async fn run(_ctx: sdk::Context, matches: &ArgMatches) -> Result<()>
let (name, data) = res?; let (name, data) = res?;
let name = base_path.join(name); let name = base_path.join(name);
zip.start_file(name.to_string_lossy(), Default::default())?; zip.start_file(name.to_slash_lossy(), Default::default())?;
zip.write_all(&data)?; zip.write_all(&data)?;
} }
}; };

View file

@ -24,3 +24,4 @@ tracing = { version = "0.1.37", features = ["async-await"] }
tracing-error = "0.2.0" tracing-error = "0.2.0"
luajit2-sys = "0.0.2" luajit2-sys = "0.0.2"
async-recursion = "1.0.2" async-recursion = "1.0.2"
path-slash = "0.2.1"

View file

@ -7,6 +7,7 @@ use std::str::FromStr;
use async_recursion::async_recursion; use async_recursion::async_recursion;
use color_eyre::eyre::{self, Context}; use color_eyre::eyre::{self, Context};
use color_eyre::Result; use color_eyre::Result;
use path_slash::PathBufExt;
use tokio::fs; use tokio::fs;
use crate::binary::sync::{ReadExt, WriteExt}; use crate::binary::sync::{ReadExt, WriteExt};
@ -258,7 +259,7 @@ impl Package {
for path in paths.iter() { for path in paths.iter() {
w.write_u64(t.hash().into())?; w.write_u64(t.hash().into())?;
let hash = Murmur64::hash(path.to_string_lossy().as_bytes()); let hash = Murmur64::hash(path.to_slash_lossy().as_bytes());
w.write_u64(hash.into())?; w.write_u64(hash.into())?;
} }
} }