mirror of
https://github.com/yuzu-emu/breakpad.git
synced 2024-11-28 05:04:14 +01:00
[Mac]Exit with unique status in symupload when file already exists.
- This change should also be made for other platforms. - This allows users to tell the difference between upload succeeding, failing, and being skipped because the file already exists on server. Change-Id: I0b404da7aac29e0a16346bbd816ad1c815985bce Reviewed-on: https://chromium-review.googlesource.com/c/breakpad/breakpad/+/2341373 Reviewed-by: Mark Mentovai <mark@chromium.org>
This commit is contained in:
parent
3d8daa2c74
commit
e3a62dc550
@ -48,7 +48,13 @@
|
|||||||
#include "HTTPPutRequest.h"
|
#include "HTTPPutRequest.h"
|
||||||
#include "SymbolCollectorClient.h"
|
#include "SymbolCollectorClient.h"
|
||||||
|
|
||||||
typedef enum { SymUploadProtocolV1, SymUploadProtocolV2 } SymUploadProtocol;
|
typedef enum { kSymUploadProtocolV1, kSymUploadProtocolV2 } SymUploadProtocol;
|
||||||
|
|
||||||
|
typedef enum {
|
||||||
|
kResultSuccess = 0,
|
||||||
|
kResultFailure = 1,
|
||||||
|
kResultAlreadyExists = 2
|
||||||
|
} Result;
|
||||||
|
|
||||||
typedef struct {
|
typedef struct {
|
||||||
NSString* symbolsPath;
|
NSString* symbolsPath;
|
||||||
@ -56,7 +62,7 @@ typedef struct {
|
|||||||
SymUploadProtocol symUploadProtocol;
|
SymUploadProtocol symUploadProtocol;
|
||||||
NSString* apiKey;
|
NSString* apiKey;
|
||||||
BOOL force;
|
BOOL force;
|
||||||
BOOL success;
|
Result result;
|
||||||
} Options;
|
} Options;
|
||||||
|
|
||||||
//=============================================================================
|
//=============================================================================
|
||||||
@ -137,14 +143,14 @@ static void StartSymUploadProtocolV1(Options* options,
|
|||||||
|
|
||||||
[result release];
|
[result release];
|
||||||
[ul release];
|
[ul release];
|
||||||
options->success = !error && status == 200;
|
options->result = (!error && status == 200) ? kResultSuccess : kResultFailure;
|
||||||
}
|
}
|
||||||
|
|
||||||
//=============================================================================
|
//=============================================================================
|
||||||
static void StartSymUploadProtocolV2(Options* options,
|
static void StartSymUploadProtocolV2(Options* options,
|
||||||
NSArray* moduleParts,
|
NSArray* moduleParts,
|
||||||
NSString* debugID) {
|
NSString* debugID) {
|
||||||
options->success = NO;
|
options->result = kResultFailure;
|
||||||
|
|
||||||
NSString* debugFile = [moduleParts objectAtIndex:4];
|
NSString* debugFile = [moduleParts objectAtIndex:4];
|
||||||
if (!options->force) {
|
if (!options->force) {
|
||||||
@ -156,6 +162,7 @@ static void StartSymUploadProtocolV2(Options* options,
|
|||||||
if (symbolStatus == SymbolStatusFound) {
|
if (symbolStatus == SymbolStatusFound) {
|
||||||
fprintf(stdout, "Symbol file already exists, upload aborted."
|
fprintf(stdout, "Symbol file already exists, upload aborted."
|
||||||
" Use \"-f\" to overwrite.\n");
|
" Use \"-f\" to overwrite.\n");
|
||||||
|
options->result = kResultAlreadyExists;
|
||||||
return;
|
return;
|
||||||
} else if (symbolStatus == SymbolStatusUnknown) {
|
} else if (symbolStatus == SymbolStatusUnknown) {
|
||||||
fprintf(stdout, "Failed to get check for existing symbol.\n");
|
fprintf(stdout, "Failed to get check for existing symbol.\n");
|
||||||
@ -205,7 +212,7 @@ static void StartSymUploadProtocolV2(Options* options,
|
|||||||
} else {
|
} else {
|
||||||
fprintf(stdout, "Successfully sent the symbol file.\n");
|
fprintf(stdout, "Successfully sent the symbol file.\n");
|
||||||
}
|
}
|
||||||
options->success = YES;
|
options->result = kResultSuccess;
|
||||||
}
|
}
|
||||||
|
|
||||||
//=============================================================================
|
//=============================================================================
|
||||||
@ -218,9 +225,9 @@ static void Start(Options* options) {
|
|||||||
options:0
|
options:0
|
||||||
range:NSMakeRange(0, [compactedID length])];
|
range:NSMakeRange(0, [compactedID length])];
|
||||||
|
|
||||||
if (options->symUploadProtocol == SymUploadProtocolV1) {
|
if (options->symUploadProtocol == kSymUploadProtocolV1) {
|
||||||
StartSymUploadProtocolV1(options, moduleParts, compactedID);
|
StartSymUploadProtocolV1(options, moduleParts, compactedID);
|
||||||
} else if (options->symUploadProtocol == SymUploadProtocolV2) {
|
} else if (options->symUploadProtocol == kSymUploadProtocolV2) {
|
||||||
StartSymUploadProtocolV2(options, moduleParts, compactedID);
|
StartSymUploadProtocolV2(options, moduleParts, compactedID);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -242,12 +249,27 @@ static void Usage(int argc, const char* argv[]) {
|
|||||||
"[Only in sym-upload-v2 protocol mode]\n");
|
"[Only in sym-upload-v2 protocol mode]\n");
|
||||||
fprintf(stderr, "\t-h: Usage\n");
|
fprintf(stderr, "\t-h: Usage\n");
|
||||||
fprintf(stderr, "\t-?: Usage\n");
|
fprintf(stderr, "\t-?: Usage\n");
|
||||||
|
fprintf(stderr, "Exit codes:\n");
|
||||||
|
fprintf(stderr, "\t%d: Success\n", kResultSuccess);
|
||||||
|
fprintf(stderr, "\t%d: Failure\n", kResultFailure);
|
||||||
|
fprintf(stderr,
|
||||||
|
"\t%d: Symbol file already exists on server (and -f was not "
|
||||||
|
"specified).\n",
|
||||||
|
kResultAlreadyExists);
|
||||||
|
fprintf(stderr,
|
||||||
|
"\t [This exit code will only be returned by the sym-upload-v2 "
|
||||||
|
"protocol.\n");
|
||||||
|
fprintf(stderr,
|
||||||
|
"\t The sym-upload-v1 protocol can return either Success or "
|
||||||
|
"Failure\n");
|
||||||
|
fprintf(stderr, "\t in this case, and the action taken by the server is "
|
||||||
|
"unspecified.]\n");
|
||||||
}
|
}
|
||||||
|
|
||||||
//=============================================================================
|
//=============================================================================
|
||||||
static void SetupOptions(int argc, const char* argv[], Options* options) {
|
static void SetupOptions(int argc, const char* argv[], Options* options) {
|
||||||
// Set default value of symUploadProtocol.
|
// Set default value of symUploadProtocol.
|
||||||
options->symUploadProtocol = SymUploadProtocolV1;
|
options->symUploadProtocol = kSymUploadProtocolV1;
|
||||||
|
|
||||||
extern int optind;
|
extern int optind;
|
||||||
char ch;
|
char ch;
|
||||||
@ -256,11 +278,11 @@ static void SetupOptions(int argc, const char* argv[], Options* options) {
|
|||||||
switch (ch) {
|
switch (ch) {
|
||||||
case 'p':
|
case 'p':
|
||||||
if (strcmp(optarg, "sym-upload-v2") == 0) {
|
if (strcmp(optarg, "sym-upload-v2") == 0) {
|
||||||
options->symUploadProtocol = SymUploadProtocolV2;
|
options->symUploadProtocol = kSymUploadProtocolV2;
|
||||||
break;
|
break;
|
||||||
} else if (strcmp(optarg, "sym-upload-v1") == 0) {
|
} else if (strcmp(optarg, "sym-upload-v1") == 0) {
|
||||||
// This is already the default but leave in case that changes.
|
// This is already the default but leave in case that changes.
|
||||||
options->symUploadProtocol = SymUploadProtocolV1;
|
options->symUploadProtocol = kSymUploadProtocolV1;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
Usage(argc, argv);
|
Usage(argc, argv);
|
||||||
@ -319,5 +341,5 @@ int main(int argc, const char* argv[]) {
|
|||||||
Start(&options);
|
Start(&options);
|
||||||
|
|
||||||
[pool release];
|
[pool release];
|
||||||
return options.success ? 0 : 1;
|
return options.result;
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user