Skip to content

Commit e0a8d1e

Browse files
committed
clear core cache
1 parent ff5b831 commit e0a8d1e

3 files changed

Lines changed: 16 additions & 8 deletions

File tree

app/src/main/cpp/CoreWrapper.cpp

Lines changed: 9 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -121,6 +121,7 @@ Java_at_tomtasche_reader_background_CoreWrapper_parseNative(JNIEnv *env, jclass
121121
jboolean editable = env->GetBooleanField(options, editableField);
122122

123123
std::string outputPathCpp = getStringField(env, optionsClass, options, "outputPath");
124+
std::string cachePathCpp = getStringField(env, optionsClass, options, "cachePath");
124125

125126
jclass listClass = env->FindClass("java/util/List");
126127
jmethodID addMethod = env->GetMethodID(listClass, "add", "(Ljava/lang/Object;)Z");
@@ -195,11 +196,11 @@ Java_at_tomtasche_reader_background_CoreWrapper_parseNative(JNIEnv *env, jclass
195196

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

198-
std::string output_tmp = outputPathCpp + "/tmp";
199-
std::filesystem::create_directories(output_tmp);
200-
odr::HtmlService service = odr::html::translate(file, output_tmp, htmlConfig, logger);
199+
std::filesystem::remove_all(cachePathCpp);
200+
std::filesystem::create_directories(cachePathCpp);
201+
odr::HtmlService service = odr::html::translate(file, cachePathCpp, htmlConfig, logger);
201202
odr::Html html = service.bring_offline(outputPathCpp);
202-
std::filesystem::remove_all(output_tmp);
203+
std::filesystem::remove_all(cachePathCpp);
203204

204205
for (const odr::HtmlPage &page: html.pages()) {
205206
jstring pageName = env->NewStringUTF(page.name.c_str());
@@ -350,6 +351,7 @@ Java_at_tomtasche_reader_background_CoreWrapper_hostFileNative(JNIEnv *env, jcla
350351
jboolean editable = env->GetBooleanField(options, editableField);
351352

352353
std::string outputPathCpp = getStringField(env, optionsClass, options, "outputPath");
354+
std::string cachePathCpp = getStringField(env, optionsClass, options, "cachePath");
353355

354356
jclass listClass = env->FindClass("java/util/List");
355357
jmethodID addMethod = env->GetMethodID(listClass, "add", "(Ljava/lang/Object;)Z");
@@ -395,9 +397,9 @@ Java_at_tomtasche_reader_background_CoreWrapper_hostFileNative(JNIEnv *env, jcla
395397
htmlConfig.text_document_margin = paging;
396398
htmlConfig.editable = editable;
397399

398-
std::string output_tmp = outputPathCpp + "/tmp";
399-
std::filesystem::create_directories(output_tmp);
400-
odr::HtmlService service = odr::html::translate(file, output_tmp, htmlConfig, logger);
400+
std::filesystem::remove_all(cachePathCpp);
401+
std::filesystem::create_directories(cachePathCpp);
402+
odr::HtmlService service = odr::html::translate(file, cachePathCpp, htmlConfig, logger);
401403
s_server->connect_service(service, prefixCpp);
402404
odr::HtmlViews htmlViews = service.list_views();
403405

app/src/main/java/at/tomtasche/reader/background/CoreLoader.java

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@
77
import android.webkit.MimeTypeMap;
88

99
import java.io.File;
10+
import java.util.Objects;
1011

1112
import at.tomtasche.reader.nonfree.AnalyticsManager;
1213
import at.tomtasche.reader.nonfree.ConfigManager;
@@ -92,9 +93,13 @@ private void translate(Options options, Result result) throws Exception {
9293

9394
File cacheDirectory = AndroidFileCache.getCacheDirectory(cachedFile);
9495

96+
File coreOutputDirectory = new File(cacheDirectory, "core_output");
97+
File coreCacheDirectory = new File(cacheDirectory, "core_cache");
98+
9599
CoreWrapper.CoreOptions coreOptions = new CoreWrapper.CoreOptions();
96100
coreOptions.inputPath = cachedFile.getPath();
97-
coreOptions.outputPath = cacheDirectory.getPath();
101+
coreOptions.outputPath = coreOutputDirectory.getPath();
102+
coreOptions.cachePath = coreCacheDirectory.getPath();
98103
coreOptions.password = options.password;
99104
coreOptions.editable = options.translatable;
100105
coreOptions.ooxml = doOoxml;

app/src/main/java/at/tomtasche/reader/background/CoreWrapper.java

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -57,6 +57,7 @@ public static class CoreOptions {
5757

5858
public String inputPath;
5959
public String outputPath;
60+
public String cachePath;
6061
}
6162

6263
public static CoreResult parse(CoreOptions options) {

0 commit comments

Comments
 (0)