Skip to content

Commit 4c27962

Browse files
committed
handle non existing cache dir
1 parent e0a8d1e commit 4c27962

1 file changed

Lines changed: 4 additions & 2 deletions

File tree

app/src/main/cpp/CoreWrapper.cpp

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -98,6 +98,7 @@ Java_at_tomtasche_reader_background_CoreWrapper_setGlobalParams(JNIEnv *env, jcl
9898
JNIEXPORT jobject JNICALL
9999
Java_at_tomtasche_reader_background_CoreWrapper_parseNative(JNIEnv *env, jclass clazz,
100100
jobject options) {
101+
std::error_code ec;
101102
auto logger = std::make_shared<AndroidLogger>();
102103

103104
jclass resultClass = env->FindClass("at/tomtasche/reader/background/CoreWrapper$CoreResult");
@@ -196,7 +197,7 @@ Java_at_tomtasche_reader_background_CoreWrapper_parseNative(JNIEnv *env, jclass
196197

197198
__android_log_print(ANDROID_LOG_VERBOSE, "smn", "Translate to HTML");
198199

199-
std::filesystem::remove_all(cachePathCpp);
200+
std::filesystem::remove_all(cachePathCpp, ec);
200201
std::filesystem::create_directories(cachePathCpp);
201202
odr::HtmlService service = odr::html::translate(file, cachePathCpp, htmlConfig, logger);
202203
odr::Html html = service.bring_offline(outputPathCpp);
@@ -319,6 +320,7 @@ Java_at_tomtasche_reader_background_CoreWrapper_hostFileNative(JNIEnv *env, jcla
319320
jobject options) {
320321
__android_log_print(ANDROID_LOG_INFO, "smn", "host file");
321322

323+
std::error_code ec;
322324
auto logger = std::make_shared<AndroidLogger>();
323325

324326
jclass resultClass = env->FindClass("at/tomtasche/reader/background/CoreWrapper$CoreResult");
@@ -397,7 +399,7 @@ Java_at_tomtasche_reader_background_CoreWrapper_hostFileNative(JNIEnv *env, jcla
397399
htmlConfig.text_document_margin = paging;
398400
htmlConfig.editable = editable;
399401

400-
std::filesystem::remove_all(cachePathCpp);
402+
std::filesystem::remove_all(cachePathCpp, ec);
401403
std::filesystem::create_directories(cachePathCpp);
402404
odr::HtmlService service = odr::html::translate(file, cachePathCpp, htmlConfig, logger);
403405
s_server->connect_service(service, prefixCpp);

0 commit comments

Comments
 (0)