Skip to content

Commit 8b0278b

Browse files
committed
Delete when user avatar directory path is already a file
1 parent 33dd82d commit 8b0278b

File tree

1 file changed

+4
-3
lines changed

1 file changed

+4
-3
lines changed

app/src/main/java/com/github/mobile/util/AvatarLoader.java

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -165,10 +165,11 @@ private String getAvatarFilenameForUrl(String avatarUrl) {
165165
protected BitmapDrawable fetchAvatar(final String url,
166166
final String userId, final String cachedAvatarFilename) {
167167
File userAvatarDir = new File(avatarDir, userId);
168-
if (!userAvatarDir.isDirectory())
169-
userAvatarDir.mkdirs();
170-
else
168+
if (userAvatarDir.isDirectory())
171169
deleteCachedUserAvatars(userAvatarDir);
170+
else
171+
userAvatarDir.delete();
172+
userAvatarDir.mkdirs();
172173

173174
File rawAvatar = new File(userAvatarDir, cachedAvatarFilename + "-raw");
174175
HttpRequest request = HttpRequest.get(url);

0 commit comments

Comments
 (0)