Show internal reason for why import fails.
This commit is contained in:
		@@ -563,21 +563,20 @@ PearlAssociatedObjectProperty( NSNumber*, StoreCorrupted, storeCorrupted );
 | 
			
		||||
 | 
			
		||||
    // Read metadata for the import file.
 | 
			
		||||
    MPMarshalledFile *file = mpw_marshal_read( NULL, importData.UTF8String );
 | 
			
		||||
    MPMarshalledUser *importUser = nil;
 | 
			
		||||
    @try {
 | 
			
		||||
        if (!file)
 | 
			
		||||
            return MPError( ([NSError errorWithDomain:MPErrorDomain code:MPErrorMarshalCode userInfo:@{
 | 
			
		||||
                    @"type"                  : @(MPMarshalErrorInternal),
 | 
			
		||||
                    NSLocalizedDescriptionKey: @"Could not process Master Password import data.",
 | 
			
		||||
            }]), @"While importing sites." );
 | 
			
		||||
        if (file->error.type != MPMarshalSuccess) {
 | 
			
		||||
        MPMarshalErrorType type = file->error.type;
 | 
			
		||||
        mpw_marshal_file_free( &file );
 | 
			
		||||
            return MPError( ([NSError errorWithDomain:MPErrorDomain code:MPErrorMarshalCode userInfo:@{
 | 
			
		||||
                @"type"                  : @(type),
 | 
			
		||||
                NSLocalizedDescriptionKey: @"Could not parse Master Password import data.",
 | 
			
		||||
                    @"type"                  : @(file->error.type),
 | 
			
		||||
                    NSLocalizedDescriptionKey: strf( @"Could not parse Master Password import data:\n%@", @(file->error.message) ),
 | 
			
		||||
            }]), @"While importing sites." );
 | 
			
		||||
        }
 | 
			
		||||
        if (file->info->format == MPMarshalFormatNone) {
 | 
			
		||||
        mpw_marshal_file_free( &file );
 | 
			
		||||
            return MPError( ([NSError errorWithDomain:MPErrorDomain code:MPErrorMarshalCode userInfo:@{
 | 
			
		||||
                    @"type"                  : @(MPMarshalErrorFormat),
 | 
			
		||||
                    NSLocalizedDescriptionKey: @"This is not a Master Password import file.",
 | 
			
		||||
@@ -591,7 +590,6 @@ PearlAssociatedObjectProperty( NSNumber*, StoreCorrupted, storeCorrupted );
 | 
			
		||||
            importMasterPassword = askImportPassword( @(file->info->fullName) );
 | 
			
		||||
            if (!importMasterPassword) {
 | 
			
		||||
                inf( @"Import cancelled." );
 | 
			
		||||
            mpw_marshal_file_free( &file );
 | 
			
		||||
                return MPError( ([NSError errorWithDomain:NSCocoaErrorDomain code:NSUserCancelledError userInfo:nil]), @"" );
 | 
			
		||||
            }
 | 
			
		||||
 | 
			
		||||
@@ -600,13 +598,11 @@ PearlAssociatedObjectProperty( NSNumber*, StoreCorrupted, storeCorrupted );
 | 
			
		||||
                         caseInsensitiveCompare:@(file->info->keyID)] != NSOrderedSame);
 | 
			
		||||
 | 
			
		||||
        // Parse import data.
 | 
			
		||||
    MPMarshalledUser *importUser = mpw_marshal_auth( file, mpw_masterKeyProvider_str( importMasterPassword.UTF8String ) );
 | 
			
		||||
 | 
			
		||||
    @try {
 | 
			
		||||
        importUser = mpw_marshal_auth( file, mpw_masterKeyProvider_str( importMasterPassword.UTF8String ) );
 | 
			
		||||
        if (!importUser || file->error.type != MPMarshalSuccess)
 | 
			
		||||
            return MPError( ([NSError errorWithDomain:MPErrorDomain code:MPErrorMarshalCode userInfo:@{
 | 
			
		||||
                    @"type"                  : @(file->error.type),
 | 
			
		||||
                    NSLocalizedDescriptionKey: @(file->error.message),
 | 
			
		||||
                    NSLocalizedDescriptionKey: strf( @"Could not authenticate Master Password import:\n%@", @(file->error.message) ),
 | 
			
		||||
            }]), @"While importing sites." );
 | 
			
		||||
 | 
			
		||||
        // Find an existing user to update.
 | 
			
		||||
 
 | 
			
		||||
		Reference in New Issue
	
	Block a user