Fix infinitely invalid file download
CHANGELOG.md
| 4 | 4 | Changes Since 0.2.1 | |
| 5 | 5 | ------------------- | |
| 6 | 6 | ||
| 7 | + | ### Features | |
| 8 | + | ||
| 9 | + | * Dictionary list is now downloaded from the website, so new dictionaries will | |
| 10 | + | not always require an app update. | |
| 11 | + | * Show a message when a file is corrupted and delete it. | |
| 12 | + | ||
| 13 | + | ### Bug Fixes | |
| 14 | + | ||
| 15 | + | * When a file is already downloaded, updating it will append to it instead | |
| 16 | + | of overriding it. | |
| 17 | + | ||
| 7 | 18 | Changes In 0.2.1 | |
| 8 | 19 | ----------------- | |
| 9 | 20 |
app/src/main/java/eu/lepiller/nani/DictionaryDownloadActivity.java
| 202 | 202 | } | |
| 203 | 203 | Log.d(TAG, "Can do range? " + acceptRanges); | |
| 204 | 204 | } | |
| 205 | - | output = new FileOutputStream(file, true); | |
| 206 | - | } else { | |
| 207 | - | output = new FileOutputStream(file); | |
| 208 | 205 | } | |
| 209 | 206 | ||
| 210 | 207 | long total = 0; | |
… | |||
| 212 | 209 | if(expectedLength > 0 && acceptRanges && file.length() < expectedLength) { | |
| 213 | 210 | connection.addRequestProperty("Range", "bytes=" + file.length() + "-" + (expectedLength-1)); | |
| 214 | 211 | total = file.length(); | |
| 212 | + | output = new FileOutputStream(file, true); | |
| 213 | + | } else { | |
| 214 | + | output = new FileOutputStream(file); | |
| 215 | 215 | } | |
| 216 | 216 | connection.connect(); | |
| 217 | 217 | ||