Skip to content

Commit

Permalink
[Refactor] Throw FileNotFoundException instead of IOException while f…
Browse files Browse the repository at this point in the history
…etching external storage

Signed-off-by: Muntashir Al-Islam <muntashirakon@riseup.net>
  • Loading branch information
MuntashirAkon committed Apr 24, 2024
1 parent 4f97928 commit c5d811f
Showing 1 changed file with 4 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -161,26 +161,26 @@ public static File getCachePath() {
Context context = ContextUtils.getContext();
try {
return getExternalCachePath(context);
} catch (IOException e) {
} catch (FileNotFoundException e) {
return context.getCacheDir();
}
}

@AnyThread
@NonNull
public static File getExternalCachePath(@NonNull Context context) throws IOException {
public static File getExternalCachePath(@NonNull Context context) throws FileNotFoundException {
return getBestExternalPath(context.getExternalCacheDirs());
}

@AnyThread
@NonNull
public static File getExternalMediaPath(@NonNull Context context) throws IOException {
public static File getExternalMediaPath(@NonNull Context context) throws FileNotFoundException {
return getBestExternalPath(context.getExternalMediaDirs());
}

@AnyThread
@NonNull
public static File getBestExternalPath(@Nullable File[] extDirs) throws IOException {
public static File getBestExternalPath(@Nullable File[] extDirs) throws FileNotFoundException {
if (extDirs == null) {
throw new FileNotFoundException("Shared storage unavailable.");
}
Expand Down

0 comments on commit c5d811f

Please sign in to comment.