Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: update tika_native dir in build folder #28

Merged
merged 1 commit into from
Nov 24, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 18 additions & 0 deletions extractous-core/build.rs
Original file line number Diff line number Diff line change
Expand Up @@ -92,6 +92,20 @@ fn find_already_built_libs(out_dir: &Path) -> Option<PathBuf> {
None
}

fn is_dir_updated(src: &Path, dest: &Path) -> bool {
let src_modified = fs::metadata(src)
.and_then(|meta| meta.modified())
.ok();
let dest_modified = fs::metadata(dest)
.and_then(|meta| meta.modified())
.ok();

match (src_modified, dest_modified) {
(Some(src_time), Some(dest_time)) => src_time > dest_time,
_ => true, // If either timestamp is unavailable, consider the source as updated
}
}

// Run the gradle build command to build tika-native
fn gradle_build(
tika_native_source_dir: &PathBuf,
Expand All @@ -108,6 +122,10 @@ fn gradle_build(
println!("Using GraalVM JDK found at {}", graalvm_home.display());
println!("Building tika_native libs this might take a while ... Please be patient!!");

if is_dir_updated(&tika_native_dir, &out_dir) {
println!("Lib tika_native files were updated");
fs_extra::dir::remove(&tika_native_dir).ok();
}
// Because build script are not allowed to change files outside of OUT_DIR
// we need to copy the tika-native source directory to OUT_DIR and call gradle build there
if !tika_native_dir.is_dir() {
Expand Down
Loading