@@ -104,26 +104,23 @@ protected Void doInBackground(String... unused) {
104104 connection .setIfModifiedSince (lastDownloadTime );
105105 }
106106
107- try (InputStream input = connection .getInputStream ()) {
108- URL resolvedURL = connection .getURL ();
109- Log .i (TAG , "Resolved update URL " + resolvedURL );
110-
111- if (connection .getResponseCode () == HttpURLConnection .HTTP_NOT_FOUND ) {
112- if (resolvedURL .equals (unresolvedURL )) {
113- Log .i (TAG , "Rolled back all updates" );
114- localFile .delete ();
115- return null ;
116- } else {
117- Log .i (TAG , "Latest update not found" );
118- return null ;
119- }
120- }
107+ URL resolvedURL = connection .getURL ();
108+ Log .i (TAG , "Resolved update URL " + resolvedURL );
121109
122- if (connection .getResponseCode () == HttpURLConnection .HTTP_NOT_MODIFIED ) {
123- Log .i (TAG , "Already have latest update" );
124- return null ;
125- }
110+ int responseCode = connection .getResponseCode ();
111+ Log .i (TAG , "HTTP response code " + responseCode );
112+
113+ if (responseCode == HttpURLConnection .HTTP_NOT_FOUND ) {
114+ Log .i (TAG , "Latest update not found" );
115+ return null ;
116+ }
117+
118+ if (responseCode == HttpURLConnection .HTTP_NOT_MODIFIED ) {
119+ Log .i (TAG , "Already have latest update" );
120+ return null ;
121+ }
126122
123+ try (InputStream input = connection .getInputStream ()) {
127124 Log .i (TAG , "Downloading update " + unresolvedURL );
128125 try (OutputStream output = new FileOutputStream (localFile )) {
129126 int count ;
0 commit comments