44import eu .pretix .libpretixsync .db .ReusableMedium ;
55import eu .pretix .libpretixsync .utils .JSONUtils ;
66import io .requery .sql .StatementExecutionException ;
7+
78import org .json .JSONArray ;
89import org .json .JSONException ;
910import org .json .JSONObject ;
@@ -74,6 +75,7 @@ public interface ProgressFeedback {
7475
7576 public interface CheckConnectivityFeedback {
7677 void recordError ();
78+
7779 void recordSuccess (Long durationInMillis );
7880 }
7981
@@ -82,6 +84,7 @@ public static class EventSwitchRequested extends Exception {
8284 public String eventName ;
8385 public Long subeventId ;
8486 public Long checkinlistId ;
87+
8588 public EventSwitchRequested (String eventSlug , String eventName , Long subeventId , Long checkinlistId ) {
8689 this .eventSlug = eventSlug ;
8790 this .eventName = eventName ;
@@ -134,7 +137,7 @@ public SyncManager(
134137 }
135138
136139 public SyncResult sync (boolean force ) throws EventSwitchRequested {
137- return sync (force ,null );
140+ return sync (force , null );
138141 }
139142
140143 /**
@@ -514,9 +517,9 @@ protected void uploadQueuedCalls(ProgressFeedback feedback) throws SyncException
514517 List <QueuedCall > calls = dataStore .select (QueuedCall .class )
515518 .get ().toList ();
516519 String url = "" ;
517- try {
518- int i = 0 ;
519- for ( QueuedCall call : calls ) {
520+ int i = 0 ;
521+ for ( QueuedCall call : calls ) {
522+ try {
520523 if (feedback != null && i % 10 == 0 ) {
521524 feedback .postFeedback ("Uploading queued calls (" + i + "/" + calls .size () + ") …" );
522525 }
@@ -536,21 +539,24 @@ protected void uploadQueuedCalls(ProgressFeedback feedback) throws SyncException
536539 } else {
537540 throw new SyncException (response .getData ().toString ());
538541 }
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 ) {
545554 sentry .addBreadcrumb ("sync.queue" , "API Error: " + e .getMessage ());
546555 throw new SyncException (e .getMessage ());
547556 }
548- } catch (ApiException e ) {
549- sentry .addBreadcrumb ("sync.queue" , "API Error: " + e .getMessage ());
550- throw new SyncException (e .getMessage ());
551557 }
552558
553- sentry .addBreadcrumb ("sync.queue" , "Receipt upload complete" );
559+ sentry .addBreadcrumb ("sync.queue" , "Queued call upload complete" );
554560 }
555561
556562 protected void uploadReceipts (ProgressFeedback feedback ) throws SyncException {
@@ -563,7 +569,7 @@ protected void uploadReceipts(ProgressFeedback feedback) throws SyncException {
563569
564570 try {
565571 int i = 0 ;
566- for (Receipt receipt : receipts ) {
572+ for (Receipt receipt : receipts ) {
567573 if (feedback != null && (i % 10 ) == 0 ) {
568574 feedback .postFeedback ("Uploading receipts (" + i + "/" + receipts .size () + ") …" );
569575 }
0 commit comments