From 4f3a20960ecf535935ea158a4037d5a2aedd9c83 Mon Sep 17 00:00:00 2001 From: Isira Seneviratne Date: Mon, 18 Sep 2023 05:14:15 +0530 Subject: [PATCH] Switch to Files.createDirectories() --- .../schabi/newpipe/streams/io/StoredDirectoryHelper.java | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/app/src/main/java/org/schabi/newpipe/streams/io/StoredDirectoryHelper.java b/app/src/main/java/org/schabi/newpipe/streams/io/StoredDirectoryHelper.java index 1b74c90a504..53dc5cf2a8d 100644 --- a/app/src/main/java/org/schabi/newpipe/streams/io/StoredDirectoryHelper.java +++ b/app/src/main/java/org/schabi/newpipe/streams/io/StoredDirectoryHelper.java @@ -180,9 +180,12 @@ public boolean isDirect() { */ public boolean mkdirs() { if (docTree == null) { - // TODO: Use Files.createDirectories() when AGP 8.1 is available: - // https://issuetracker.google.com/issues/282544786 - return Files.exists(ioTree) || ioTree.toFile().mkdirs(); + try { + Files.createDirectories(ioTree); + } catch (final IOException e) { + Log.e(TAG, "Error while creating directories at " + ioTree, e); + } + return Files.exists(ioTree); } if (docTree.exists()) {