mirror of
https://github.com/bitsocialnet/5chan.git
synced 2026-08-03 07:41:04 +02:00
fix(upload-automation): harden android and electron failure handling
Updated Android/Electron upload paths to fail deterministically and report consistent stage details, while removing unsafe stage casting and path/package mismatches. This keeps postimages automation behavior intact and makes failures easier to diagnose.
This commit is contained in:
+2
-1
@@ -111,8 +111,9 @@ public class FileUploaderPlugin extends Plugin {
|
||||
tryProvidersSequentially(uri, providerOrder, call);
|
||||
} catch (Exception e) {
|
||||
Log.e(TAG, "Upload failed", e);
|
||||
if (!call.getData().has("_resolved")) {
|
||||
try {
|
||||
call.reject("Upload failed: " + e.getMessage());
|
||||
} catch (Exception ignored) {
|
||||
}
|
||||
}
|
||||
})
|
||||
+6
-3
@@ -73,6 +73,9 @@ public class MediaUploadAutomationRunner {
|
||||
static final String STAGE_SUBMIT_CLICKED = "submit_clicked";
|
||||
static final String STAGE_SUCCESS_SELECTOR_MATCHED = "success_selector_matched";
|
||||
static final String STAGE_BLOCKED_DETECTED = "blocked_detected";
|
||||
static final String STAGE_INPUT_NOT_FOUND = "input_not_found";
|
||||
static final String STAGE_CHOOSER_NOT_TRIGGERED = "chooser_not_triggered";
|
||||
static final String STAGE_UPLOAD_TIMED_OUT = "upload_timed_out";
|
||||
|
||||
private final Context context;
|
||||
private final Uri fileUri;
|
||||
@@ -202,7 +205,7 @@ public class MediaUploadAutomationRunner {
|
||||
if (finished || fileChooserHandled) return;
|
||||
long elapsed = elapsedMs();
|
||||
if (elapsed >= MediaUploadRecipes.FILE_INPUT_TIMEOUT_MS) {
|
||||
String stage = lastMatchedSelector != null ? "chooser_not_triggered" : "input_not_found";
|
||||
String stage = lastMatchedSelector != null ? STAGE_CHOOSER_NOT_TRIGGERED : STAGE_INPUT_NOT_FOUND;
|
||||
String error =
|
||||
lastMatchedSelector != null
|
||||
? "File chooser not triggered"
|
||||
@@ -289,7 +292,7 @@ public class MediaUploadAutomationRunner {
|
||||
false,
|
||||
null,
|
||||
"Upload timeout",
|
||||
"upload_timed_out",
|
||||
STAGE_UPLOAD_TIMED_OUT,
|
||||
elapsed,
|
||||
lastMatchedSelector));
|
||||
return;
|
||||
@@ -302,7 +305,7 @@ public class MediaUploadAutomationRunner {
|
||||
false,
|
||||
null,
|
||||
"File chooser not triggered",
|
||||
"chooser_not_triggered",
|
||||
STAGE_CHOOSER_NOT_TRIGGERED,
|
||||
elapsed,
|
||||
lastMatchedSelector,
|
||||
triggerAttemptCount));
|
||||
@@ -113,12 +113,12 @@ public class MediaUploadRecipesTest {
|
||||
|
||||
@Test
|
||||
public void failureClassification_inputNotFound_stageConstant() {
|
||||
assertEquals("input_not_found", "input_not_found");
|
||||
assertEquals(MediaUploadAutomationRunner.STAGE_INPUT_NOT_FOUND, "input_not_found");
|
||||
}
|
||||
|
||||
@Test
|
||||
public void failureClassification_chooserNotTriggered_stageConstant() {
|
||||
assertEquals("chooser_not_triggered", "chooser_not_triggered");
|
||||
assertEquals(MediaUploadAutomationRunner.STAGE_CHOOSER_NOT_TRIGGERED, "chooser_not_triggered");
|
||||
}
|
||||
|
||||
@Test
|
||||
@@ -128,7 +128,7 @@ public class MediaUploadRecipesTest {
|
||||
|
||||
@Test
|
||||
public void failureClassification_uploadTimedOut_stageConstant() {
|
||||
assertEquals("upload_timed_out", "upload_timed_out");
|
||||
assertEquals(MediaUploadAutomationRunner.STAGE_UPLOAD_TIMED_OUT, "upload_timed_out");
|
||||
}
|
||||
|
||||
@Test
|
||||
|
||||
Reference in New Issue
Block a user