mkdirs returns false if the directory already exists. Although
it check exists prior to mkdirs, it's possible for the dir to be
created by another thread in between the calls so make it robust
by checking isDirectory (which also checks exists) if mkdirs returns
false.
Change-Id: If63a2d20400c3093f0aea4c22192fa0e01fde748
Signed-off-by: Tom Pantelis <tompantelis@gmail.com>
checkSupportedRepresentation(representation);
- if (!storageDirectory.exists()) {
- checkArgument(storageDirectory.mkdirs(), "Unable to create cache directory at %s", storageDirectory);
- }
- checkArgument(storageDirectory.exists());
- checkArgument(storageDirectory.isDirectory());
+ checkArgument(storageDirectory.mkdirs() || storageDirectory.isDirectory(),
+ "Unable to create cache directory at %s", storageDirectory);
checkArgument(storageDirectory.canWrite());
checkArgument(storageDirectory.canRead());