Polycentric disk caching

This commit is contained in:
Kelvin 2024-12-04 18:20:40 +01:00
parent 49d0dead7d
commit a2fafdbdb9
4 changed files with 16 additions and 1 deletions

View file

@ -866,6 +866,9 @@ class Settings : FragmentedStorageFileJson() {
@FormField(R.string.enable_polycentric, FieldForm.TOGGLE, R.string.can_be_disabled_when_you_are_experiencing_issues, 3)
var polycentricEnabled: Boolean = true;
@FormField(R.string.polycentric_local_cache, FieldForm.TOGGLE, R.string.polycentric_local_cache_description, 4)
var polycentricLocalCache: Boolean = true;
}
@FormField(R.string.gesture_controls, FieldForm.GROUP, -1, 19)

View file

@ -47,6 +47,7 @@ import com.futo.platformplayer.services.DownloadService
import com.futo.platformplayer.stores.FragmentedStorage
import com.futo.platformplayer.stores.v2.ManagedStore
import com.futo.platformplayer.views.ToastView
import com.futo.polycentric.core.ApiMethods
import kotlinx.coroutines.*
import java.io.File
import java.util.*
@ -156,6 +157,7 @@ class StateApp {
//Files
private var _tempDirectory: File? = null;
private var _cacheDirectory: File? = null;
private var _persistentDirectory: File? = null;
@ -324,6 +326,9 @@ class StateApp {
_tempDirectory?.deleteRecursively();
}
_tempDirectory?.mkdirs();
_cacheDirectory = File(context.filesDir, "cache");
if(_cacheDirectory?.exists() == false)
_cacheDirectory?.mkdirs();
_persistentDirectory = File(context.filesDir, "persist");
if(_persistentDirectory?.exists() == false) {
_persistentDirectory?.mkdirs();
@ -383,6 +388,11 @@ class StateApp {
Logger.i(TAG, "MainApp Starting");
initializeFiles(true);
if(Settings.instance.other.polycentricLocalCache) {
Logger.i(TAG, "Initialize Polycentric Disk Cache")
_cacheDirectory?.let { ApiMethods.initCache(it) };
}
val logFile = File(context.filesDir, "log.txt");
if (Settings.instance.logging.logLevel > LogLevel.NONE.value) {
val fileLogConsumer = FileLogConsumer(logFile, LogLevel.fromInt(Settings.instance.logging.logLevel), false);

View file

@ -424,6 +424,8 @@
<string name="playlist_delete_confirmation">Playlist Delete Confirmation</string>
<string name="playlist_delete_confirmation_description">Show confirmation dialog when deleting media from a playlist</string>
<string name="enable_polycentric">Enable Polycentric</string>
<string name="polycentric_local_cache">Enable Polycentric Local Caching</string>
<string name="polycentric_local_cache_description">Caches polycentric results on-device to reduce load times, changing requires app reboot</string>
<string name="can_be_disabled_when_you_are_experiencing_issues">Can be disabled when you are experiencing issues</string>
<string name="bypass_rotation_prevention_description">Allows for rotation on non-video views.\nWARNING: Not designed for it</string>
<string name="bypass_rotation_prevention_warning">This may cause unexpected behavior, and is mostly untested.</string>

@ -1 +1 @@
Subproject commit f7d58c6ca6de151c11bd4ecc48a7de81bdc36d8a
Subproject commit 44edd69ece9cac4a6dd95a84ca91299e44f3650a