Skip to content

Commit

Permalink
feat(engine): update path handling to use platform-independent speara…
Browse files Browse the repository at this point in the history
…tor (#551)

* feat(engine): update path handling to use platform-independent separators

* fix

* bump up
  • Loading branch information
miseyu authored Oct 4, 2024
1 parent 66f1c54 commit 7aff8cd
Show file tree
Hide file tree
Showing 6 changed files with 44 additions and 31 deletions.
38 changes: 19 additions & 19 deletions engine/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 engine/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ homepage = "https://github.com/reearth/reearth-flow"
license = "MIT OR Apache-2.0"
repository = "https://github.com/reearth/reearth-flow"
rust-version = "1.81" # Remember to update clippy.toml as well
version = "0.0.1"
version = "0.0.2"

[profile.dev]
opt-level = 0
Expand Down
2 changes: 1 addition & 1 deletion engine/plateau-gis-quality-checker/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "plateau-gis-quality-checker",
"version": "0.0.1",
"version": "0.0.2",
"repository": "https://github.com/reearth/reearth-flow.git",
"license": "APACHE-2.0",
"type": "module",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
},
"package": {
"productName": "PLATEAU GIS Quality Checker",
"version": "0.0.1"
"version": "0.0.2"
},
"tauri": {
"allowlist": {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,9 @@
use std::{collections::HashMap, path::PathBuf, str::FromStr, sync::Arc};
use std::{
collections::HashMap,
path::{PathBuf, MAIN_SEPARATOR, MAIN_SEPARATOR_STR},
str::FromStr,
sync::Arc,
};

use reearth_flow_common::uri::Uri;
use reearth_flow_runtime::{
Expand Down Expand Up @@ -194,7 +199,7 @@ fn mapper(
.map_err(|e| PlateauProcessorError::UdxFolderExtractor(format!("{:?}", e)))?
};
let folders = city_gml_path
.split('/')
.split(MAIN_SEPARATOR)
.map(String::from)
.collect::<Vec<String>>();
let city_gml_path = Uri::from_str(city_gml_path.to_string().as_str())
Expand All @@ -214,16 +219,16 @@ fn mapper(
root = fourth_last.to_string();
pkg = second_last.to_string();
dirs = second_last.to_string();
rtdir = PathBuf::from(folders[..folders.len() - 3].join("/"));
rtdir = PathBuf::from(folders[..folders.len() - 3].join(MAIN_SEPARATOR_STR));
}
[.., fifth_last, _fourth_last, third_last, second_last, _last]
if PKG_FOLDERS.contains(&third_last.as_str()) =>
{
root = fifth_last.to_string();
pkg = third_last.to_string();
area = second_last.to_string();
dirs = format!("{}/{}", pkg, area);
rtdir = PathBuf::from(folders[..folders.len() - 4].join("/"));
dirs = format!("{}{}{}", pkg, MAIN_SEPARATOR_STR, area);
rtdir = PathBuf::from(folders[..folders.len() - 4].join(MAIN_SEPARATOR_STR));
}
[.., sixth_last, _fifth_last, fourth_last, third_last, second_last, _last]
if PKG_FOLDERS.contains(&fourth_last.as_str()) =>
Expand All @@ -232,8 +237,11 @@ fn mapper(
pkg = fourth_last.to_string();
admin = third_last.to_string();
area = second_last.to_string();
dirs = format!("{}/{}/{}", pkg, admin, area);
rtdir = PathBuf::from(folders[..folders.len() - 5].join("/"));
dirs = format!(
"{}{}{}{}{}",
pkg, MAIN_SEPARATOR_STR, admin, MAIN_SEPARATOR_STR, area
);
rtdir = PathBuf::from(folders[..folders.len() - 5].join(MAIN_SEPARATOR_STR));
}
_ => (),
};
Expand Down
9 changes: 7 additions & 2 deletions engine/runtime/action-source/src/file/path_extractor.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,9 @@
use std::{collections::HashMap, path::Path, str::FromStr, sync::Arc};
use std::{
collections::HashMap,
path::{Path, MAIN_SEPARATOR},
str::FromStr,
sync::Arc,
};

use async_zip::base::read::mem::ZipFileReader;
use futures::AsyncReadExt;
Expand Down Expand Up @@ -120,7 +125,7 @@ pub async fn extract(
{
continue;
}
let entry_is_dir = filename.ends_with('/');
let entry_is_dir = filename.ends_with(MAIN_SEPARATOR);
if entry_is_dir {
if storage
.exists(outpath.path().as_path())
Expand Down

0 comments on commit 7aff8cd

Please sign in to comment.