Skip to content

Commit

Permalink
Simplify rollback of dynamic patches (flutter#7432)
Browse files Browse the repository at this point in the history
  • Loading branch information
sbaranov authored Jan 10, 2019
1 parent 6071286 commit 37d886e
Showing 1 changed file with 15 additions and 18 deletions.
33 changes: 15 additions & 18 deletions shell/platform/android/io/flutter/view/ResourceUpdater.java
Original file line number Diff line number Diff line change
Expand Up @@ -104,26 +104,23 @@ protected Void doInBackground(String... unused) {
connection.setIfModifiedSince(lastDownloadTime);
}

try (InputStream input = connection.getInputStream()) {
URL resolvedURL = connection.getURL();
Log.i(TAG, "Resolved update URL " + resolvedURL);

if (connection.getResponseCode() == HttpURLConnection.HTTP_NOT_FOUND) {
if (resolvedURL.equals(unresolvedURL)) {
Log.i(TAG, "Rolled back all updates");
localFile.delete();
return null;
} else {
Log.i(TAG, "Latest update not found");
return null;
}
}
URL resolvedURL = connection.getURL();
Log.i(TAG, "Resolved update URL " + resolvedURL);

if (connection.getResponseCode() == HttpURLConnection.HTTP_NOT_MODIFIED) {
Log.i(TAG, "Already have latest update");
return null;
}
int responseCode = connection.getResponseCode();
Log.i(TAG, "HTTP response code " + responseCode);

if (responseCode == HttpURLConnection.HTTP_NOT_FOUND) {
Log.i(TAG, "Latest update not found");
return null;
}

if (responseCode == HttpURLConnection.HTTP_NOT_MODIFIED) {
Log.i(TAG, "Already have latest update");
return null;
}

try (InputStream input = connection.getInputStream()) {
Log.i(TAG, "Downloading update " + unresolvedURL);
try (OutputStream output = new FileOutputStream(localFile)) {
int count;
Expand Down

0 comments on commit 37d886e

Please sign in to comment.