Skip to content

Commit

Permalink
0.0.10
Browse files Browse the repository at this point in the history
  • Loading branch information
victorteokw committed Dec 10, 2024
1 parent 706a4a4 commit 48af63a
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 9 deletions.
2 changes: 1 addition & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
[package]
edition = "2021"
name = "teodevgroup_teo_docs_search_engine"
version = "0.0.9"
version = "0.0.10"

[lib]
crate-type = ["cdylib"]
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@teodevgroup/teo-docs-search-engine",
"version": "0.0.9",
"version": "0.0.10",
"main": "index.js",
"types": "index.d.ts",
"napi": {
Expand Down
14 changes: 7 additions & 7 deletions src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ extern crate napi_derive;

use std::env::current_dir;
use std::fs;
use std::path::Path;
use once_cell::sync::Lazy;
use tantivy::collector::TopDocs;
use tantivy::query::QueryParser;
Expand Down Expand Up @@ -33,12 +34,11 @@ pub struct SearchIndex {

impl SearchIndex {

fn _index() -> Index {
let path = current_dir().unwrap();
let tmp_dir = path.join(".fulltextcache");
if !tmp_dir.exists() {
fs::create_dir(&tmp_dir).unwrap();
fn _index(tmp_dir: &Path) -> Index {
if tmp_dir.exists() {
fs::remove_dir_all(&tmp_dir).unwrap();
}
fs::create_dir(&tmp_dir).unwrap();
Index::create_in_dir(&tmp_dir, SCHEMA.clone()).unwrap()
}

Expand Down Expand Up @@ -94,8 +94,8 @@ impl SearchIndex {
impl SearchIndex {

#[napi(constructor)]
pub fn new() -> Self {
Self { index: Self::_index() }
pub fn new(dir: String) -> Self {
Self { index: Self::_index(Path::new(&dir)) }
}

#[napi]
Expand Down

0 comments on commit 48af63a

Please sign in to comment.