diff --git a/DEV_LOG.md b/DEV_LOG.md index 8e5eb6c4..3066f5fc 100644 --- a/DEV_LOG.md +++ b/DEV_LOG.md @@ -9,6 +9,7 @@ - 增加组任务groupHash冲突检查 https://github.com/AriaLyy/Aria/issues/635 - 修复task.cancel(false)还是把本地文件删除的问题 https://github.com/AriaLyy/Aria/issues/646 - fix bug https://github.com/AriaLyy/Aria/issues/670 + - fix bug https://github.com/AriaLyy/Aria/issues/664 + v_3.8.6 (2020/2/17) - fix bug https://github.com/AriaLyy/Aria/issues/608 - fix bug https://github.com/AriaLyy/Aria/issues/579#issuecomment-586665035 diff --git a/PublicComponent/src/main/java/com/arialyy/aria/orm/SqlHelper.java b/PublicComponent/src/main/java/com/arialyy/aria/orm/SqlHelper.java index 7f5d2c62..a9452140 100644 --- a/PublicComponent/src/main/java/com/arialyy/aria/orm/SqlHelper.java +++ b/PublicComponent/src/main/java/com/arialyy/aria/orm/SqlHelper.java @@ -44,6 +44,7 @@ import java.util.Set; final class SqlHelper extends SQLiteOpenHelper { private static final String TAG = "SqlHelper"; private static volatile SqlHelper INSTANCE = null; + private static boolean mainTmpDirSet = false; private Context mContext; synchronized static SqlHelper init(Context context) { @@ -147,6 +148,24 @@ final class SqlHelper extends SQLiteOpenHelper { return db; } + /** + * 用于修复 Too many open files 的问题 + * https://github.com/AriaLyy/Aria/issues/664 + */ + @Override + public SQLiteDatabase getReadableDatabase() { + if (!mainTmpDirSet) { + String cacheDir = mContext.getCacheDir().getPath() + "/AriaDbCacheDir"; + boolean rs = new File(cacheDir).mkdir(); + ALog.d(TAG, rs + ""); + super.getReadableDatabase() + .execSQL("PRAGMA temp_store_directory = '" + cacheDir + "'"); + mainTmpDirSet = true; + return super.getReadableDatabase(); + } + return super.getReadableDatabase(); + } + /** * 处理数据库升级 *