Permalink
Browse files

hopefully fix download issue for people who return 200.

  • Loading branch information...
1 parent 0db6b1c commit 211f02d9d816659945ba3702d65ac04ba18056e5 @ahmedre ahmedre committed Jul 22, 2012
Showing with 20 additions and 0 deletions.
  1. +20 −0 src/com/quran/labs/androidquran/service/QuranDownloadService.java
@@ -581,6 +581,26 @@ private int downloadFile(String urlString, String destination,
android.util.Log.d(TAG, "actualFile: " + actualFile.getPath() +
", " + actualFile.getAbsolutePath() + ", " +
actualFile.getName());
+
+ // check for 200 response code - happens on some devices
+ if (rc == HttpURLConnection.HTTP_OK){
+ rc = HttpURLConnection.HTTP_PARTIAL;
+ if (downloaded != 0){
+ // just in case, remove the actual file if exists
+ if (actualFile.exists()){
+ if (!actualFile.delete()){
+ return ERROR_PERMISSIONS;
+ }
+ }
+ // just in case, remove the partial file
+ if (partialFile.exists()){
+ if (!partialFile.delete()){
+ return ERROR_PERMISSIONS;
+ }
+ }
+ downloaded = 0;
+ }
+ }
long fileLength = downloaded +
(rc == HttpURLConnection.HTTP_PARTIAL? contentLength : 0);

0 comments on commit 211f02d

Please sign in to comment.