diff --git a/app/src/main/java/com/fongmi/android/tv/utils/Download.java b/app/src/main/java/com/fongmi/android/tv/utils/Download.java index 65ded49c5..0febb995e 100644 --- a/app/src/main/java/com/fongmi/android/tv/utils/Download.java +++ b/app/src/main/java/com/fongmi/android/tv/utils/Download.java @@ -40,10 +40,10 @@ public class Download { private void doInBackground() { try { - Path.clear(file); + Path.create(file); Response response = OkHttp.newCall(url).execute(); download(response.body().byteStream(), Double.parseDouble(response.header(HttpHeaders.CONTENT_LENGTH, "1"))); - if (callback != null) App.post(() -> callback.success(Path.chmod(file))); + if (callback != null) App.post(() -> callback.success(file)); } catch (Exception e) { if (callback != null) App.post(() -> callback.error(e.getMessage())); } diff --git a/catvod/src/main/java/com/github/catvod/utils/Path.java b/catvod/src/main/java/com/github/catvod/utils/Path.java index 59f0dc2aa..eb98aa665 100644 --- a/catvod/src/main/java/com/github/catvod/utils/Path.java +++ b/catvod/src/main/java/com/github/catvod/utils/Path.java @@ -148,7 +148,6 @@ public class Path { fos.write(data); fos.flush(); fos.close(); - chmod(file); return file; } catch (Exception ignored) { ignored.printStackTrace(); @@ -176,7 +175,6 @@ public class Path { while ((read = in.read(buffer)) != -1) fos.write(buffer, 0, read); fos.close(); in.close(); - chmod(out); } catch (Exception ignored) { } } @@ -192,20 +190,20 @@ public class Path { if (dir.delete()) Log.d(TAG, "Deleted:" + dir.getAbsolutePath()); } - public static File chmod(File file) { + public static File create(File file) throws Exception { try { - Shell.exec("chmod 777 " + file); - return file; + if (!file.exists()) file.createNewFile(); + if (!file.canWrite()) file.setWritable(true); + return chmod(file); } catch (Exception e) { e.printStackTrace(); return file; } } - public static File create(File file) throws Exception { + public static File chmod(File file) { try { - if (!file.exists()) file.createNewFile(); - if (!file.canWrite()) file.setWritable(true); + Shell.exec("chmod 777 " + file); return file; } catch (Exception e) { e.printStackTrace();