Fix infinitely invalid file download

Julien LepillerWed May 27 01:05:38+0200 2020

e84e4e2

Fix infinitely invalid file download

CHANGELOG.md

44
Changes Since 0.2.1
55
-------------------
66
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+
718
Changes In 0.2.1
819
-----------------
920

app/src/main/java/eu/lepiller/nani/DictionaryDownloadActivity.java

202202
                            }
203203
                            Log.d(TAG, "Can do range? " + acceptRanges);
204204
                        }
205-
                        output = new FileOutputStream(file, true);
206-
                    } else {
207-
                        output = new FileOutputStream(file);
208205
                    }
209206
210207
                    long total = 0;

212209
                    if(expectedLength > 0 && acceptRanges && file.length() < expectedLength) {
213210
                        connection.addRequestProperty("Range", "bytes=" + file.length() + "-" + (expectedLength-1));
214211
                        total = file.length();
212+
                        output = new FileOutputStream(file, true);
213+
                    } else {
214+
                        output = new FileOutputStream(file);
215215
                    }
216216
                    connection.connect();
217217