Skip to content
This repository was archived by the owner on Jul 11, 2021. It is now read-only.

Commit 0dfb720

Browse files
author
Simone Mosciatti
committed
merge with remove name
2 parents 09f511a + 339dea8 commit 0dfb720

2 files changed

Lines changed: 38 additions & 44 deletions

File tree

Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,4 +18,4 @@ engine_pro = {path = "./engine_pro", optional = true}
1818
[features]
1919
default = []
2020
pro = ["engine_pro"]
21-
# trial = ["engine_pro/trial"]
21+
trial = ["engine_pro/trial"]

src/lib.rs

Lines changed: 37 additions & 43 deletions
Original file line numberDiff line numberDiff line change
@@ -580,48 +580,41 @@ extern "C" fn CreateDB(
580580
_ => (":memory:", true),
581581
};
582582
match sql::get_arc_connection(path) {
583-
Ok(rc) => match r::create_metadata_table(
584-
rc.clone(),
585-
).and_then(|_| {
586-
r::insert_metadata(
587-
rc.clone(),
588-
"setup",
589-
"path",
590-
path,
591-
)
592-
})
593-
.and_then(|_| {
594-
r::enable_foreign_key(rc.clone())
595-
})
596-
.and_then(|_| vtab::register_modules(&rc))
597-
{
598-
Err(e) => e.reply(&context),
599-
Ok(mut vtab_context) => {
600-
let (tx, rx) = channel();
601-
let db = r::DBKey::new_from_arc(
602-
tx,
603-
rc,
604-
in_memory,
605-
vtab_context,
606-
);
607-
let mut loop_data =
608-
db.loop_data.clone();
609-
thread::spawn(move || {
610-
r::listen_and_execute(
611-
&mut loop_data,
612-
&rx,
583+
Ok(rc) => {
584+
match r::create_metadata_table(rc.clone())
585+
.and_then(|_| {
586+
r::enable_foreign_key(rc.clone())
587+
}).and_then(|_| {
588+
vtab::register_modules(&rc)
589+
}) {
590+
Err(e) => e.reply(&context),
591+
Ok(mut vtab_context) => {
592+
let (tx, rx) = channel();
593+
let db = r::DBKey::new_from_arc(
594+
tx,
595+
rc,
596+
in_memory,
597+
vtab_context,
613598
);
614-
});
615-
let ptr = Box::into_raw(Box::new(db));
616-
let type_set = unsafe {
617-
r::rm::ffi::RedisModule_ModuleTypeSetValue.unwrap()(
599+
let mut loop_data =
600+
db.loop_data.clone();
601+
thread::spawn(move || {
602+
r::listen_and_execute(
603+
&mut loop_data,
604+
&rx,
605+
);
606+
});
607+
let ptr =
608+
Box::into_raw(Box::new(db));
609+
let type_set = unsafe {
610+
r::rm::ffi::RedisModule_ModuleTypeSetValue.unwrap()(
618611
safe_key.key,
619612
r::rm::ffi::DBType,
620613
ptr as *mut std::os::raw::c_void,
621614
)
622-
};
615+
};
623616

624-
match type_set {
617+
match type_set {
625618
r::rm::ffi::REDISMODULE_OK => {
626619
let ok =
627620
r::QueryResult::OK {};
@@ -649,8 +642,9 @@ extern "C" fn CreateDB(
649642
}
650643
}
651644
}
645+
}
652646
}
653-
},
647+
}
654648
Err(_) => {
655649
let error = CString::new(
656650
"Err - Error \
@@ -830,9 +824,9 @@ extern "C" fn Backup(
830824
let source_db =
831825
get_dbkey_from_name(context.as_ptr(), argvector[1]);
832826
if source_db.is_err() {
833-
let error = CString::new(
834-
"Error in opening the SOURCE database",
835-
).unwrap();
827+
let error =
828+
CString::new("Error in opening the SOURCE database")
829+
.unwrap();
836830
return unsafe {
837831
r::rm::ffi::RedisModule_ReplyWithError.unwrap()(
838832
context.as_ptr(),
@@ -844,9 +838,9 @@ extern "C" fn Backup(
844838

845839
let dest_db = get_dbkey_from_name(context.as_ptr(), argvector[2]);
846840
if dest_db.is_err() {
847-
let error = CString::new(
848-
"Error in opening the DESTINATION database",
849-
).unwrap();
841+
let error =
842+
CString::new("Error in opening the DESTINATION database")
843+
.unwrap();
850844
return unsafe {
851845
r::rm::ffi::RedisModule_ReplyWithError.unwrap()(
852846
context.as_ptr(),

0 commit comments

Comments
 (0)