Skip to content
This repository was archived by the owner on Jan 31, 2022. It is now read-only.

Commit 3782c77

Browse files
author
Clément Le Provost
committed
[offline] Use a better temporary directory
1 parent e663d33 commit 3782c77

File tree

2 files changed

+10
-7
lines changed

2 files changed

+10
-7
lines changed

algoliasearch/src/offline/java/com/algolia/search/saas/MirroredIndex.java

Lines changed: 1 addition & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -233,12 +233,6 @@ protected LocalIndex getLocalIndex() {
233233
return localIndex;
234234
}
235235

236-
private File getTempDir()
237-
{
238-
// TODO: Use better value
239-
return getClient().getRootDataDir();
240-
}
241-
242236
private File getDataDir()
243237
{
244238
return new File(new File(getClient().getRootDataDir(), getClient().getApplicationID()), getIndexName());
@@ -435,7 +429,7 @@ public void run()
435429

436430
try {
437431
// Create temporary directory.
438-
tmpDir = new File(getTempDir(), UUID.randomUUID().toString());
432+
tmpDir = new File(getClient().getTempDir(), UUID.randomUUID().toString());
439433
tmpDir.mkdirs();
440434

441435
// NOTE: We are doing everything sequentially, because this is a background job: we care more about

algoliasearch/src/offline/java/com/algolia/search/saas/OfflineClient.java

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -127,6 +127,15 @@ public MirroredIndex initIndex(@NonNull String indexName)
127127
return rootDataDir;
128128
}
129129

130+
/**
131+
* Get the path to the temporary directory used by this client.
132+
*
133+
* @return The path to the temporary directory.
134+
*/
135+
protected @NonNull File getTempDir() {
136+
return context.getCacheDir();
137+
}
138+
130139
/**
131140
* Enable the offline mode.
132141
* @param licenseData License for Algolia's SDK.

0 commit comments

Comments
 (0)