#59 #72
authoradam <adamansky@gmail.com>
Wed, 17 Jul 2013 18:04:26 +0000 (01:04 +0700)
committeradam <adamansky@gmail.com>
Wed, 17 Jul 2013 18:04:26 +0000 (01:04 +0700)
tcejdb/ejdb.c
tcejdb/testejdb/t4.c

index a453279..a2ec5b1 100644 (file)
@@ -1176,9 +1176,9 @@ static bool _importcoll(EJDB *jb, const char *bspath, TCLIST *cnames, int flags,
     }
     char *lastsep = pp;
     int i = 0;
-    char *cname, *mjson;
+    char *cname, *mjson = NULL;
     bson_type bt;
-    bson *mbson; //meta bson
+    bson *mbson = NULL; //meta bson
     bson_iterator mbsonit;
     int sp;
     EJCOLL *coll;
@@ -1369,10 +1369,10 @@ finish:
         TCFREE(mjson);
     }
     tcxstrdel(xmetapath);
-    TCFREE(cname);
     if (err && log) {
         tcxstrprintf(log, "\nERROR: Importing data into: '%s' failed with error: '%s'", cname, (ejdbecode(jb) != 0) ? ejdberrmsg(ejdbecode(jb)) : "Unknown");
     }
+    TCFREE(cname);
     return !err;
 }
 
@@ -1393,7 +1393,7 @@ static bool _exportcoll(EJCOLL *coll, const char *dpath, int flags, TCXSTR *log)
             FILE_SHARE_READ | FILE_SHARE_WRITE,
             NULL, CREATE_ALWAYS, FILE_ATTRIBUTE_NORMAL, NULL);
 
-    HANDLE fdm = CreateFile(fpath, GENERIC_READ | GENERIC_WRITE,
+    HANDLE fdm = CreateFile(fpathm, GENERIC_READ | GENERIC_WRITE,
             FILE_SHARE_READ | FILE_SHARE_WRITE,
             NULL, CREATE_ALWAYS, FILE_ATTRIBUTE_NORMAL, NULL);
 #endif
index 64c9a4d..949d97d 100644 (file)
@@ -105,8 +105,8 @@ void testBSONExportImport() {
 
     rv = ejdbimport(jb, "testBSONExportImport", cnames, JBIMPORTREPLACE, log);
     CU_ASSERT_TRUE(rv);
+    //fprintf(stderr, "\n\n%s", TCXSTRPTR(log));
 
-    CU_ASSERT_PTR_NOT_NULL(strstr(TCXSTRPTR(log), "Reading 'testBSONExportImport/col1.bson'"));
     CU_ASSERT_PTR_NOT_NULL(strstr(TCXSTRPTR(log), "Replacing all data in 'col1'"));
     CU_ASSERT_PTR_NOT_NULL(strstr(TCXSTRPTR(log), "1 objects imported into 'col1'"));
     CU_ASSERT_PTR_NOT_NULL(strstr(TCXSTRPTR(log), "2 objects imported into 'col2'"));
@@ -265,7 +265,6 @@ void testBSONExportImport2() {
     CU_ASSERT_TRUE_FATAL(bson_find_fieldpath_value("log", &it) == BSON_STRING);
     log = bson_iterator_string(&it);
 
-    CU_ASSERT_PTR_NOT_NULL(strstr(log, "Reading 'testBSONExportImport2/col1.bson'"));
     CU_ASSERT_PTR_NOT_NULL(strstr(log, "Replacing all data in 'col1'"));
     CU_ASSERT_PTR_NOT_NULL(strstr(log, "1 objects imported into 'col1'"));
     CU_ASSERT_PTR_NOT_NULL(strstr(log, "2 objects imported into 'col2'"));