|
17 | 17 |
|
18 | 18 | import androidx.annotation.NonNull; |
19 | 19 |
|
20 | | -import com.google.gson.JsonSyntaxException; |
21 | 20 | import com.nextcloud.android.sso.AccountImporter; |
| 21 | +import com.nextcloud.android.sso.api.EmptyResponse; |
22 | 22 | import com.nextcloud.android.sso.exceptions.NextcloudApiNotRespondingException; |
23 | 23 | import com.nextcloud.android.sso.exceptions.NextcloudFilesAppAccountNotFoundException; |
24 | 24 | import com.nextcloud.android.sso.exceptions.NextcloudHttpRequestFailedException; |
|
34 | 34 | import java.util.HashSet; |
35 | 35 | import java.util.List; |
36 | 36 | import java.util.Map; |
| 37 | +import java.util.Objects; |
37 | 38 |
|
38 | | -import io.reactivex.Observable; |
39 | 39 | import it.niedermann.owncloud.notes.BuildConfig; |
40 | 40 | import it.niedermann.owncloud.notes.persistence.entity.Account; |
41 | 41 | import it.niedermann.owncloud.notes.persistence.entity.Note; |
@@ -228,21 +228,7 @@ private boolean pullRemoteChanges() { |
228 | 228 | return false; |
229 | 229 | } |
230 | 230 |
|
231 | | - final var fetchResponse = notesAPI.getNotes(modified, localAccount.getETag()) |
232 | | - .onErrorResumeNext(error -> { |
233 | | - if (error instanceof JsonSyntaxException || |
234 | | - (error.getCause() != null && error.getCause() instanceof JsonSyntaxException)) { |
235 | | - Log.w(TAG, "JSON parse error, likely 304 Not Modified"); |
236 | | - return Observable.empty(); |
237 | | - } |
238 | | - return Observable.error(error); |
239 | | - }) |
240 | | - .blockingFirst(null); |
241 | | - |
242 | | - if (fetchResponse == null) { |
243 | | - Log.d(TAG, "No changes from server"); |
244 | | - return true; |
245 | | - } |
| 231 | + final var fetchResponse = notesAPI.getNotes(modified, localAccount.getETag()).blockingSingle(); |
246 | 232 | final var remoteNotes = fetchResponse.getResponse(); |
247 | 233 | final var remoteIDs = new HashSet<Long>(); |
248 | 234 | // pull remote changes: update or create each remote note |
@@ -296,6 +282,11 @@ private boolean pullRemoteChanges() { |
296 | 282 | return true; |
297 | 283 | } catch (Throwable t) { |
298 | 284 | final Throwable cause = t.getCause(); |
| 285 | + if (t instanceof ClassCastException castException && Objects.requireNonNull(castException.getMessage()).contains(EmptyResponse.class.getSimpleName())) { |
| 286 | + Log.d(TAG, "Server returned empty response - Notes not modified."); |
| 287 | + return true; |
| 288 | + } |
| 289 | + |
299 | 290 | if (t.getClass() == RuntimeException.class && cause != null) { |
300 | 291 | if (cause.getClass() == NextcloudHttpRequestFailedException.class || cause instanceof NextcloudHttpRequestFailedException) { |
301 | 292 | final NextcloudHttpRequestFailedException httpException = (NextcloudHttpRequestFailedException) cause; |
|
0 commit comments