Skip to content

Commit

Permalink
#1657 sync issues: fix npe
Browse files Browse the repository at this point in the history
  • Loading branch information
desperateCoder committed Nov 29, 2024
1 parent 13a422f commit 1e08215
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,6 @@
import it.niedermann.nextcloud.deck.remote.api.ResponseCallback;
import it.niedermann.nextcloud.deck.remote.helpers.providers.AbstractSyncDataProvider;
import it.niedermann.nextcloud.deck.remote.helpers.providers.IRelationshipProvider;
import it.niedermann.nextcloud.deck.util.ExecutorServiceProvider;
import okhttp3.Headers;

public class SyncHelper {
Expand Down Expand Up @@ -77,7 +76,7 @@ public void onResponse(List<T> response, Headers headers) {

if (existingEntity == null) {
try {
ExecutorServiceProvider.awaitExecution(() -> provider.createInDB(dataBaseAdapter, accountId, entityFromServer));
provider.createInDB(dataBaseAdapter, accountId, entityFromServer);
} catch (SQLiteConstraintException e) {
provider.onInsertFailed(dataBaseAdapter, e, account, accountId, response, entityFromServer);
throw new RuntimeException("ConstraintViolation! Entity: " + provider.getClass().getSimpleName()+"\n"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ public void insertAllNecessary(DataBaseAdapter dataBaseAdapter, long accountId)
if (labels== null){
return;
}
Card card = dataBaseAdapter.getCardByRemoteIdDirectly(accountId, this.card.getId());
// Card card = dataBaseAdapter.getCardByRemoteIdDirectly(accountId, this.card.getId());
for (Label label : labels) {
Label existingLabel = dataBaseAdapter.getLabelByRemoteIdDirectly(accountId, label.getId());
if (existingLabel != null) { // maybe not synced yet, skipping this time. next sync will be able to push it up
Expand All @@ -37,7 +37,7 @@ public void insertAllNecessary(DataBaseAdapter dataBaseAdapter, long accountId)

@Override
public void deleteAllExisting(DataBaseAdapter dataBaseAdapter, long accountId) {
Card card = dataBaseAdapter.getCardByRemoteIdDirectly(accountId, this.card.getId());
// Card card = dataBaseAdapter.getCardByRemoteIdDirectly(accountId, this.card.getId());
dataBaseAdapter.deleteJoinedLabelsForCard(card.getLocalId());
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ public void insertAllNecessary(DataBaseAdapter dataBaseAdapter, long accountId)
if (users == null){
return;
}
Card card = dataBaseAdapter.getCardByRemoteIdDirectly(accountId, this.card.getId());
// Card card = dataBaseAdapter.getCardByRemoteIdDirectly(accountId, this.card.getId());
for (User user : users){
User existingUser = dataBaseAdapter.getUserByUidDirectly(accountId, user.getUid());
JoinCardWithUser existingJoin = dataBaseAdapter.getJoinCardWithUser(existingUser.getLocalId(), card.getLocalId());
Expand All @@ -34,7 +34,7 @@ public void insertAllNecessary(DataBaseAdapter dataBaseAdapter, long accountId)

@Override
public void deleteAllExisting(DataBaseAdapter dataBaseAdapter, long accountId) {
Card card = dataBaseAdapter.getCardByRemoteIdDirectly(accountId, this.card.getId());
// Card card = dataBaseAdapter.getCardByRemoteIdDirectly(accountId, this.card.getId());
dataBaseAdapter.deleteJoinedUsersForCard(card.getLocalId());
}
}

0 comments on commit 1e08215

Please sign in to comment.