aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorZheng Fu <zhengfu@google.com>2014-09-29 21:54:38 +0000
committerAndroid (Google) Code Review <android-gerrit@google.com>2014-09-29 21:54:38 +0000
commit0af7ae496b016635724a3fa3243eb12e569bf592 (patch)
treeb581000aacea6d08cad73f9139c9eb687e0597f0
parentfa8c000ab8bb67523f192b8e3bf395b669ece694 (diff)
parent5799f2bcbabe927ed91e3df4f71e54f8cb1f770c (diff)
downloadContactsProvider-0af7ae496b016635724a3fa3243eb12e569bf592.tar.gz
Merge "DO NOT MERGE synchronize photo storage creation for race conditions." into lmp-dev
-rw-r--r--src/com/android/providers/contacts/PhotoStore.java12
1 files changed, 8 insertions, 4 deletions
diff --git a/src/com/android/providers/contacts/PhotoStore.java b/src/com/android/providers/contacts/PhotoStore.java
index e7be48c4..79042c40 100644
--- a/src/com/android/providers/contacts/PhotoStore.java
+++ b/src/com/android/providers/contacts/PhotoStore.java
@@ -39,6 +39,8 @@ import java.util.Set;
*/
public class PhotoStore {
+ private static final Object MKDIRS_LOCK = new Object();
+
private final String TAG = PhotoStore.class.getSimpleName();
// Directory name under the root directory for photo storage.
@@ -66,10 +68,12 @@ public class PhotoStore {
*/
public PhotoStore(File rootDirectory, ContactsDatabaseHelper databaseHelper) {
mStorePath = new File(rootDirectory, DIRECTORY);
- if (!mStorePath.exists()) {
- if(!mStorePath.mkdirs()) {
- throw new RuntimeException("Unable to create photo storage directory "
- + mStorePath.getPath());
+ synchronized (MKDIRS_LOCK) {
+ if (!mStorePath.exists()) {
+ if (!mStorePath.mkdirs()) {
+ throw new RuntimeException("Unable to create photo storage directory "
+ + mStorePath.getPath());
+ }
}
}
mDatabaseHelper = databaseHelper;