Skip to content

Commit

Permalink
fix: cache path
Browse files Browse the repository at this point in the history
  • Loading branch information
dic1911 committed Dec 4, 2024
1 parent 4d2dd23 commit b387602
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,8 @@ public boolean onTouch(View view, MotionEvent motionEvent) {
// Move to /sdcard/Android/...... automatically
if (Build.VERSION.SDK_INT >= 30) {
ContextCompat.getMainExecutor(getContext()).execute(() -> {
if (!NekoConfig.cachePath.String().contains("/data/")) {
var directories = EnvUtil.getAvailableDirectories();
if (!NekoConfig.cachePath.String().contains("/data/") && directories.length > 3) {
NekoConfig.cachePath.setConfigString(EnvUtil.getAvailableDirectories()[2]);
ImageLoader.getInstance().checkMediaPaths();
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -51,16 +51,17 @@ object EnvUtil {
// This is the only media path of NekoX, don't use other!
@JvmStatic
fun getTelegramPath(): File {
var defaultIndex = if (availableDirectories.size > 3) 2 else 0

if (NekoConfig.cachePath.String() == "") {
// https://github.com/NekoX-Dev/NekoX/issues/284
NekoConfig.cachePath.setConfigString(availableDirectories[2]);
NekoConfig.cachePath.setConfigString(availableDirectories[defaultIndex]);
}
var telegramPath = File(NekoConfig.cachePath.String())
if (telegramPath.isDirectory || telegramPath.mkdirs()) {
return telegramPath
} else {
NekoConfig.cachePath.setConfigString(availableDirectories[2])
NekoConfig.cachePath.setConfigString(availableDirectories[defaultIndex])
}

// fallback
Expand Down

0 comments on commit b387602

Please sign in to comment.