Skip to content

Commit fc59418

Browse files
committed
solve git conflict
Signed-off-by: alperozturk <[email protected]>
1 parent 52b170e commit fc59418

File tree

2 files changed

+17
-11
lines changed

2 files changed

+17
-11
lines changed

app/src/main/java/it/niedermann/owncloud/notes/persistence/CapabilitiesClient.java

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -13,16 +13,10 @@
1313
import androidx.annotation.Nullable;
1414
import androidx.annotation.WorkerThread;
1515

16-
import com.nextcloud.android.sso.api.ParsedResponse;
1716
import com.nextcloud.android.sso.model.SingleSignOnAccount;
1817

19-
import java.util.Map;
20-
21-
import it.niedermann.owncloud.notes.persistence.sync.OcsAPI;
2218
import it.niedermann.owncloud.notes.shared.model.Capabilities;
23-
import it.niedermann.owncloud.notes.shared.model.OcsResponse;
24-
import it.niedermann.owncloud.notes.shared.model.OcsUser;
25-
import retrofit2.Response;
19+
import it.niedermann.owncloud.notes.util.ThrowableExtensionsKt;
2620

2721
@WorkerThread
2822
public class CapabilitiesClient {
@@ -34,6 +28,8 @@ public class CapabilitiesClient {
3428
@WorkerThread
3529
public static Capabilities getCapabilities(@NonNull Context context, @NonNull SingleSignOnAccount ssoAccount, @Nullable String lastETag, @NonNull ApiProvider apiProvider) throws Throwable {
3630
final var ocsAPI = apiProvider.getOcsAPI(context, ssoAccount);
31+
final var repository = NotesRepository.getInstance(context);
32+
3733
try {
3834
final var response = ocsAPI.getCapabilities(lastETag).blockingSingle();
3935
final var capabilities = response.getResponse().ocs.data;
@@ -44,16 +40,20 @@ public static Capabilities getCapabilities(@NonNull Context context, @NonNull Si
4440
Log.w(TAG, "Response headers of capabilities are null");
4541
}
4642

47-
final var repository = NotesRepository.getInstance(context);
4843
repository.insertCapabilities(capabilities);
4944

5045
return capabilities;
51-
} catch (RuntimeException e) {
52-
final var cause = e.getCause();
46+
} catch (Throwable t) {
47+
if (ThrowableExtensionsKt.isEmptyResponseCast(t)) {
48+
Log.d(TAG, "Server returned empty response - Notes not modified.");
49+
return repository.getCapabilities();
50+
}
51+
52+
final var cause = t.getCause();
5353
if (cause != null) {
5454
throw cause;
5555
} else {
56-
throw e;
56+
throw t;
5757
}
5858
}
5959
}

app/src/main/java/it/niedermann/owncloud/notes/persistence/NotesServerSyncTask.java

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,7 @@
4242
import it.niedermann.owncloud.notes.shared.model.ISyncCallback;
4343
import it.niedermann.owncloud.notes.shared.model.SyncResultStatus;
4444
import it.niedermann.owncloud.notes.shared.util.ApiVersionUtil;
45+
import it.niedermann.owncloud.notes.util.ThrowableExtensionsKt;
4546

4647

4748
/**
@@ -280,6 +281,11 @@ private boolean pullRemoteChanges() {
280281
return true;
281282
} catch (Throwable t) {
282283
final Throwable cause = t.getCause();
284+
if (ThrowableExtensionsKt.isEmptyResponseCast(t)) {
285+
Log.d(TAG, "Server returned empty response - Notes not modified.");
286+
return true;
287+
}
288+
283289
if (t.getClass() == RuntimeException.class && cause != null) {
284290
if (cause.getClass() == NextcloudHttpRequestFailedException.class || cause instanceof NextcloudHttpRequestFailedException) {
285291
final NextcloudHttpRequestFailedException httpException = (NextcloudHttpRequestFailedException) cause;

0 commit comments

Comments
 (0)