Fix debuglogs.org integration

// FREEBIE
This commit is contained in:
Michael Kirk 2018-03-06 15:28:25 -05:00
parent 913cdad74a
commit 39b87b702b
5 changed files with 31 additions and 15 deletions

View File

@ -28,10 +28,13 @@ def execute_command(command):
print e.output
sys.exit(1)
def add_field(curl_command, form_key, form_value):
curl_command.append('-F')
curl_command.append("%s=%s" % (form_key, form_value))
if __name__ == '__main__':
parser = argparse.ArgumentParser(description='Precommit cleanup script.')
parser.add_argument('--file', help='used for starting a new version.')
parser.add_argument('--file', required=True, help='used for starting a new version.')
args = parser.parse_args()
@ -41,24 +44,30 @@ if __name__ == '__main__':
upload_url = params['url']
upload_fields = params['fields']
upload_key = upload_fields['key']
upload_key = upload_fields.pop('key')
upload_key = upload_key + os.path.splitext(args.file)[1]
upload_fields['key'] = upload_key
download_url = 'https://debuglogs.org/' + upload_key
print 'download_url:', download_url
curl_command = ['curl', '-v', '-i', '-X', 'POST']
# key must appear before other fields
add_field(curl_command, 'key', upload_key)
for field_name in upload_fields:
field_value = upload_fields[field_name]
curl_command.append('-F')
curl_command.append("'%s=%s'" % (field_name, field_value, ))
add_field(curl_command, field_name, upload_fields[field_name])
add_field(curl_command, "content-type", "application/octet-stream")
curl_command.append('-F')
curl_command.append("'file=@%s'" % (args.file,))
curl_command.append("file=@%s" % (args.file,))
curl_command.append(upload_url)
# execute_command(curl_command)
print ' '.join(curl_command)
print 'Running...'
execute_command(curl_command)
print 'download_url:', download_url

View File

@ -12,6 +12,7 @@
#import <SignalMessaging/DebugLogger.h>
#import <SignalMessaging/Environment.h>
#import <SignalServiceKit/AppContext.h>
#import <SignalServiceKit/MimeTypeUtil.h>
#import <SignalServiceKit/TSAccountManager.h>
#import <SignalServiceKit/TSContactThread.h>
#import <SignalServiceKit/TSStorageManager.h>
@ -150,6 +151,9 @@ typedef void (^DebugLogUploadFailure)(DebugLogUploader *uploader, NSError *error
NSString *fieldValue = fields[fieldName];
[formData appendPartWithFormData:[fieldValue dataUsingEncoding:NSUTF8StringEncoding] name:fieldName];
}
[formData appendPartWithFormData:[weakSelf.mimeType dataUsingEncoding:NSUTF8StringEncoding]
name:@"content-type"];
NSError *error;
BOOL success = [formData appendPartWithFileURL:weakSelf.fileUrl
name:@"file"
@ -168,7 +172,7 @@ typedef void (^DebugLogUploadFailure)(DebugLogUploader *uploader, NSError *error
[self succeedWithUrl:[NSURL URLWithString:urlString]];
}
failure:^(NSURLSessionDataTask *_Nullable task, NSError *error) {
DDLogError(@"%@ failed: %@", weakSelf.logTag, uploadUrl);
DDLogError(@"%@ upload: %@ failed with error: %@", weakSelf.logTag, uploadUrl, error);
[weakSelf failWithError:error];
}];
}
@ -427,7 +431,7 @@ typedef void (^DebugLogUploadFailure)(DebugLogUploader *uploader, NSError *error
__weak Pastelog *weakSelf = self;
self.currentUploader = [DebugLogUploader new];
[self.currentUploader uploadFileWithURL:[NSURL fileURLWithPath:zipFilePath]
mimeType:@"application/zip"
mimeType:OWSMimeTypeApplicationZip
success:^(DebugLogUploader *uploader, NSURL *url) {
if (uploader != weakSelf.currentUploader) {
// Ignore events from obsolete uploaders.

View File

@ -255,6 +255,7 @@ NSString *const OWSPreferencesKeySystemCallLogEnabled = @"OWSPreferencesKeySyste
}
}();
DDLogInfo(@"%@ Migrating setting - System Call Log Enabled: %d", self.logTag, shouldLogCallsInRecents);
[self setValueForKey:OWSPreferencesKeySystemCallLogEnabled
toValue:@(shouldLogCallsInRecents)
transaction:transaction];

View File

@ -1,10 +1,11 @@
//
// Copyright (c) 2017 Open Whisper Systems. All rights reserved.
// Copyright (c) 2018 Open Whisper Systems. All rights reserved.
//
NS_ASSUME_NONNULL_BEGIN
extern NSString *const OWSMimeTypeApplicationOctetStream;
extern NSString *const OWSMimeTypeApplicationZip;
extern NSString *const OWSMimeTypeImagePng;
extern NSString *const OWSMimeTypeOversizeTextMessage;
extern NSString *const OWSMimeTypeUnknownForTests;

View File

@ -19,6 +19,7 @@ NSString *const OWSMimeTypeApplicationOctetStream = @"application/octet-stream";
NSString *const OWSMimeTypeImagePng = @"image/png";
NSString *const OWSMimeTypeOversizeTextMessage = @"text/x-signal-plain";
NSString *const OWSMimeTypeUnknownForTests = @"unknown/mimetype";
NSString *const OWSMimeTypeApplicationZip = @"application/zip";
NSString *const kOversizeTextAttachmentUTI = @"org.whispersystems.oversize-text-attachment";
NSString *const kOversizeTextAttachmentFileExtension = @"txt";
@ -1250,7 +1251,7 @@ NSString *const kSyncMessageFileExtension = @"bin";
@"application/yang" : @"yang",
@"application/yin+xml" : @"yin",
@"application/ynd.ms-pkipko" : @"pko",
@"application/zip" : @"zip",
OWSMimeTypeApplicationZip : @"zip",
@"audio/aac" : @"aac",
@"audio/adpcm" : @"adp",
@"audio/aiff" : @"aiff",
@ -2557,7 +2558,7 @@ NSString *const kSyncMessageFileExtension = @"bin";
@"z7" : @"application/x-zmachine",
@"z8" : @"application/x-zmachine",
@"zaz" : @"application/vnd.zzazz.deck+xml",
@"zip" : @"application/zip",
@"zip" : OWSMimeTypeApplicationZip,
@"zir" : @"application/vnd.zul",
@"zirz" : @"application/vnd.zul",
@"zmm" : @"application/vnd.handheld-entertainment+xml",