Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
import eu.pretix.libpretixsync.db.ReusableMedium;
import eu.pretix.libpretixsync.utils.JSONUtils;
import io.requery.sql.StatementExecutionException;

import org.json.JSONArray;
import org.json.JSONException;
import org.json.JSONObject;
Expand Down Expand Up @@ -74,6 +75,7 @@ public interface ProgressFeedback {

public interface CheckConnectivityFeedback {
void recordError();

void recordSuccess(Long durationInMillis);
}

Expand All @@ -82,6 +84,7 @@ public static class EventSwitchRequested extends Exception {
public String eventName;
public Long subeventId;
public Long checkinlistId;

public EventSwitchRequested(String eventSlug, String eventName, Long subeventId, Long checkinlistId) {
this.eventSlug = eventSlug;
this.eventName = eventName;
Expand Down Expand Up @@ -134,7 +137,7 @@ public SyncManager(
}

public SyncResult sync(boolean force) throws EventSwitchRequested {
return sync(force,null);
return sync(force, null);
}

/**
Expand Down Expand Up @@ -514,9 +517,9 @@ protected void uploadQueuedCalls(ProgressFeedback feedback) throws SyncException
List<QueuedCall> calls = dataStore.select(QueuedCall.class)
.get().toList();
String url = "";
try {
int i = 0;
for (QueuedCall call : calls) {
int i = 0;
for (QueuedCall call : calls) {
try {
if (feedback != null && i % 10 == 0) {
feedback.postFeedback("Uploading queued calls (" + i + "/" + calls.size() + ") …");
}
Expand All @@ -536,21 +539,24 @@ protected void uploadQueuedCalls(ProgressFeedback feedback) throws SyncException
} else {
throw new SyncException(response.getData().toString());
}
}
} catch (JSONException e) {
sentry.captureException(e);
throw new SyncException("Unknown server response: " + e.getMessage());
} catch (NotFoundApiException e) {
if (!url.contains("/failed_checkins/")) { // ignore this one: old pretix systems don't have it
} catch (JSONException e) {
sentry.captureException(e);
throw new SyncException("Unknown server response: " + e.getMessage());
} catch (NotFoundApiException e) {
if (url.contains("/failed_checkins/") || url.contains("/printlog/")) {
// ignore this one: old pretix systems don't have it
dataStore.delete(call);
} else {
sentry.addBreadcrumb("sync.queue", "API Error: " + e.getMessage());
throw new SyncException(e.getMessage());
}
} catch (ApiException e) {
sentry.addBreadcrumb("sync.queue", "API Error: " + e.getMessage());
throw new SyncException(e.getMessage());
}
} catch (ApiException e) {
sentry.addBreadcrumb("sync.queue", "API Error: " + e.getMessage());
throw new SyncException(e.getMessage());
}

sentry.addBreadcrumb("sync.queue", "Receipt upload complete");
sentry.addBreadcrumb("sync.queue", "Queued call upload complete");
}

protected void uploadReceipts(ProgressFeedback feedback) throws SyncException {
Expand All @@ -563,7 +569,7 @@ protected void uploadReceipts(ProgressFeedback feedback) throws SyncException {

try {
int i = 0;
for (Receipt receipt: receipts) {
for (Receipt receipt : receipts) {
if (feedback != null && (i % 10) == 0) {
feedback.postFeedback("Uploading receipts (" + i + "/" + receipts.size() + ") …");
}
Expand Down
Loading