diff options
author | Yohann Roussel <yroussel@google.com> | 2014-12-02 10:12:00 +0000 |
---|---|---|
committer | Android Git Automerger <android-git-automerger@android.com> | 2014-12-02 10:12:00 +0000 |
commit | 077aaf0a32c1478b2bfd02f5041d4271bcb9d429 (patch) | |
tree | 5194208c619551697dcb624bd62cf66d7f4113a8 /library | |
parent | 52d67322080759653bd4eb35e061d7a7ccec697d (diff) | |
parent | 8c2abf7f471b061b737e700af711e9d5d6883b40 (diff) | |
download | multidex-077aaf0a32c1478b2bfd02f5041d4271bcb9d429.tar.gz |
am 8c2abf7f: Workaround mkdirs concurency problems
* commit '8c2abf7f471b061b737e700af711e9d5d6883b40':
Workaround mkdirs concurency problems
Diffstat (limited to 'library')
-rw-r--r-- | library/src/android/support/multidex/MultiDexExtractor.java | 28 |
1 files changed, 24 insertions, 4 deletions
diff --git a/library/src/android/support/multidex/MultiDexExtractor.java b/library/src/android/support/multidex/MultiDexExtractor.java index b5973c5..27da6b3 100644 --- a/library/src/android/support/multidex/MultiDexExtractor.java +++ b/library/src/android/support/multidex/MultiDexExtractor.java @@ -253,10 +253,12 @@ final class MultiDexExtractor { */ private static void prepareDexDir(File dexDir, final String extractedFilePrefix) throws IOException { - dexDir.mkdirs(); - if (!dexDir.isDirectory()) { - throw new IOException("Failed to create dex directory " + dexDir.getPath()); - } + /* mkdirs() has some bugs, especially before jb-mr1 and we have only a maximum of one parent + * to create, lets stick to mkdir(). + */ + File cache = dexDir.getParentFile(); + mkdirChecked(cache); + mkdirChecked(dexDir); // Clean possible old files FileFilter filter = new FileFilter() { @@ -282,6 +284,24 @@ final class MultiDexExtractor { } } + private static void mkdirChecked(File dir) throws IOException { + dir.mkdir(); + if (!dir.isDirectory()) { + File parent = dir.getParentFile(); + if (parent == null) { + Log.e(TAG, "Failed to create dir " + dir.getPath() + ". Parent file is null."); + } else { + Log.e(TAG, "Failed to create dir " + dir.getPath() + + ". parent file is a dir " + parent.isDirectory() + + ", a file " + parent.isFile() + + ", exists " + parent.exists() + + ", readable " + parent.canRead() + + ", writable " + parent.canWrite()); + } + throw new IOException("Failed to create cache directory " + dir.getPath()); + } + } + private static void extract(ZipFile apk, ZipEntry dexFile, File extractTo, String extractedFilePrefix) throws IOException, FileNotFoundException { |