1313import androidx .annotation .Nullable ;
1414import androidx .annotation .WorkerThread ;
1515
16- import com .nextcloud .android .sso .api .ParsedResponse ;
1716import com .nextcloud .android .sso .model .SingleSignOnAccount ;
1817
19- import java .util .Map ;
20-
21- import it .niedermann .owncloud .notes .persistence .sync .OcsAPI ;
2218import 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
2822public 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 }
0 commit comments