4
4
import eu .pretix .libpretixsync .db .ReusableMedium ;
5
5
import eu .pretix .libpretixsync .utils .JSONUtils ;
6
6
import io .requery .sql .StatementExecutionException ;
7
+
7
8
import org .json .JSONArray ;
8
9
import org .json .JSONException ;
9
10
import org .json .JSONObject ;
@@ -74,6 +75,7 @@ public interface ProgressFeedback {
74
75
75
76
public interface CheckConnectivityFeedback {
76
77
void recordError ();
78
+
77
79
void recordSuccess (Long durationInMillis );
78
80
}
79
81
@@ -82,6 +84,7 @@ public static class EventSwitchRequested extends Exception {
82
84
public String eventName ;
83
85
public Long subeventId ;
84
86
public Long checkinlistId ;
87
+
85
88
public EventSwitchRequested (String eventSlug , String eventName , Long subeventId , Long checkinlistId ) {
86
89
this .eventSlug = eventSlug ;
87
90
this .eventName = eventName ;
@@ -134,7 +137,7 @@ public SyncManager(
134
137
}
135
138
136
139
public SyncResult sync (boolean force ) throws EventSwitchRequested {
137
- return sync (force ,null );
140
+ return sync (force , null );
138
141
}
139
142
140
143
/**
@@ -514,9 +517,9 @@ protected void uploadQueuedCalls(ProgressFeedback feedback) throws SyncException
514
517
List <QueuedCall > calls = dataStore .select (QueuedCall .class )
515
518
.get ().toList ();
516
519
String url = "" ;
517
- try {
518
- int i = 0 ;
519
- for ( QueuedCall call : calls ) {
520
+ int i = 0 ;
521
+ for ( QueuedCall call : calls ) {
522
+ try {
520
523
if (feedback != null && i % 10 == 0 ) {
521
524
feedback .postFeedback ("Uploading queued calls (" + i + "/" + calls .size () + ") …" );
522
525
}
@@ -536,21 +539,24 @@ protected void uploadQueuedCalls(ProgressFeedback feedback) throws SyncException
536
539
} else {
537
540
throw new SyncException (response .getData ().toString ());
538
541
}
539
- }
540
- } catch (JSONException e ) {
541
- sentry .captureException (e );
542
- throw new SyncException ("Unknown server response: " + e .getMessage ());
543
- } catch (NotFoundApiException e ) {
544
- if (!url .contains ("/failed_checkins/" )) { // ignore this one: old pretix systems don't have it
542
+ } catch (JSONException e ) {
543
+ sentry .captureException (e );
544
+ throw new SyncException ("Unknown server response: " + e .getMessage ());
545
+ } catch (NotFoundApiException e ) {
546
+ if (url .contains ("/failed_checkins/" ) || url .contains ("/printlog/" )) {
547
+ // ignore this one: old pretix systems don't have it
548
+ dataStore .delete (call );
549
+ } else {
550
+ sentry .addBreadcrumb ("sync.queue" , "API Error: " + e .getMessage ());
551
+ throw new SyncException (e .getMessage ());
552
+ }
553
+ } catch (ApiException e ) {
545
554
sentry .addBreadcrumb ("sync.queue" , "API Error: " + e .getMessage ());
546
555
throw new SyncException (e .getMessage ());
547
556
}
548
- } catch (ApiException e ) {
549
- sentry .addBreadcrumb ("sync.queue" , "API Error: " + e .getMessage ());
550
- throw new SyncException (e .getMessage ());
551
557
}
552
558
553
- sentry .addBreadcrumb ("sync.queue" , "Receipt upload complete" );
559
+ sentry .addBreadcrumb ("sync.queue" , "Queued call upload complete" );
554
560
}
555
561
556
562
protected void uploadReceipts (ProgressFeedback feedback ) throws SyncException {
@@ -563,7 +569,7 @@ protected void uploadReceipts(ProgressFeedback feedback) throws SyncException {
563
569
564
570
try {
565
571
int i = 0 ;
566
- for (Receipt receipt : receipts ) {
572
+ for (Receipt receipt : receipts ) {
567
573
if (feedback != null && (i % 10 ) == 0 ) {
568
574
feedback .postFeedback ("Uploading receipts (" + i + "/" + receipts .size () + ") …" );
569
575
}
0 commit comments