Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit b61c8219 authored by Christopher Tate's avatar Christopher Tate Committed by Android Git Automerger
Browse files

am ef4f8222: Merge "Fix cross-process race in initial files/cache dir creation" into klp-dev

* commit 'ef4f8222':
  Fix cross-process race in initial files/cache dir creation
parents 6d90862f ef4f8222
Loading
Loading
Loading
Loading
+23 −12
Original line number Diff line number Diff line
@@ -817,6 +817,10 @@ class ContextImpl extends Context {
            }
            if (!mFilesDir.exists()) {
                if(!mFilesDir.mkdirs()) {
                    if (mFilesDir.exists()) {
                        // spurious failure; probably racing with another process for this app
                        return mFilesDir;
                    }
                    Log.w(TAG, "Unable to create files directory " + mFilesDir.getPath());
                    return null;
                }
@@ -879,6 +883,10 @@ class ContextImpl extends Context {
            }
            if (!mCacheDir.exists()) {
                if(!mCacheDir.mkdirs()) {
                    if (mCacheDir.exists()) {
                        // spurious failure; probably racing with another process for this app
                        return mCacheDir;
                    }
                    Log.w(TAG, "Unable to create cache directory " + mCacheDir.getAbsolutePath());
                    return null;
                }
@@ -2136,6 +2144,8 @@ class ContextImpl extends Context {
            File dir = dirs[i];
            if (!dir.exists()) {
                if (!dir.mkdirs()) {
                    // recheck existence in case of cross-process race
                    if (!dir.exists()) {
                        // Failing to mkdir() may be okay, since we might not have
                        // enough permissions; ask vold to create on our behalf.
                        final IMountService mount = IMountService.Stub.asInterface(
@@ -2151,6 +2161,7 @@ class ContextImpl extends Context {
                        }
                    }
                }
            }
            result[i] = dir;
        }
        return result;