From b6d597f2fd63f3448658f2d0729d772d7869a815 Mon Sep 17 00:00:00 2001 From: guoling Date: Tue, 18 Aug 2020 20:42:11 +0800 Subject: [PATCH] dont check process mode on open() failure --- Core/MMKV_Android.cpp | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/Core/MMKV_Android.cpp b/Core/MMKV_Android.cpp index 0f0700c7..57400e12 100644 --- a/Core/MMKV_Android.cpp +++ b/Core/MMKV_Android.cpp @@ -208,6 +208,11 @@ void MMKV::checkReSetCryptKey(int fd, int metaFD, string *cryptKey) { # endif // MMKV_DISABLE_CRYPT bool MMKV::checkProcessMode() { + // avoid exception on open() error + if (!m_file->isFileValid()) { + return true; + } + if (!m_fileModeLock) { // force use fcntl(), otherwise will conflict with MemoryFile::reloadFromFile() m_fileModeLock = new FileLock(m_file->getFd(), true);