@ -26,6 +26,29 @@ static NSString *keychainDBPassAccount    = @"TSDatabasePass";
 
		
	
		
			
				
 
		
	
		
			
				@ end  
		
	
		
			
				
 
		
	
		
			
				/ /  Some  lingering  TSRecipient  records  in  the  wild  causing  crashes .  
		
	
		
			
				/ /  This  is  a  stop  gap  until  a  proper  cleanup  happens .  
		
	
		
			
				@ interface  TSRecipient  :  NSObject  < NSCoding >  
		
	
		
			
				
 
		
	
		
			
				@ end  
		
	
		
			
				
 
		
	
		
			
				@ implementation  TSRecipient  
		
	
		
			
				
 
		
	
		
			
				-  ( instancetype ) initWithCoder : ( NSCoder  * ) aDecoder  
		
	
		
			
				{  
		
	
		
			
				    DDLogWarn ( @ "Ignoring  decoding  signal  recipient  with  coder . ") ; 
 
		
	
		
			
				
 
		
	
		
			
				    self  =  [ super  init ] ; 
 
		
	
		
			
				    return  nil ; 
 
		
	
		
			
				}  
		
	
		
			
				
 
		
	
		
			
				-  ( void ) encodeWithCoder : ( NSCoder  * ) aCoder  
		
	
		
			
				{  
		
	
		
			
				    DDLogWarn ( @ "Ignoring  encoding  signal  recipient  with  coder . ") ; 
 
		
	
		
			
				}  
		
	
		
			
				
 
		
	
		
			
				@ end  
		
	
		
			
				
 
		
	
		
			
				@ implementation  TSStorageManager  
		
	
		
			
				
 
		
	
		
			
				+  ( instancetype ) sharedManager  {  
		
	
	
		
			
				
					
						
							
								 
						
						
							
								 
						
						
					 
				
			
			@ -67,19 +90,21 @@ static NSString *keychainDBPassAccount    = @"TSDatabasePass";
 
		
	
		
			
				        if  ( !data  ||  data . length  < =  0 )  { 
 
		
	
		
			
				            return  nil ; 
 
		
	
		
			
				        } 
 
		
	
		
			
				
 
		
	
		
			
				        @ try  { 
 
		
	
		
			
				            return  [ NSKeyedUnarchiver  unarchiveObjectWithData : data ] ; 
 
		
	
		
			
				        }  @ catch  ( NSException  * exception )  { 
 
		
	
		
			
				            / /  Sync  log  in  case  we  bail . 
 
		
	
		
			
				            NSLog ( @ "%@ Unarchiving key:%@ from collection:%@ and data %@ failed with error: %@", 
 
		
	
		
			
				                [ self  tag ] , 
 
		
	
		
			
				            DDLogError ( @ "%@ Unarchiving key:%@ from collection:%@ and data %@ failed with error: %@", 
 
		
	
		
			
				                self . tag , 
 
		
	
		
			
				                key , 
 
		
	
		
			
				                collection , 
 
		
	
		
			
				                data , 
 
		
	
		
			
				                exception . reason ) ; 
 
		
	
		
			
				            / /  Sync  log  in  case  we  bail . 
 
		
	
		
			
				            NSLog ( @ "%@ Raising exception since deserialization failed", [self tag]); 
 
		
	
		
			
				            [ exception  raise ] ; 
 
		
	
		
			
				            DDLogError ( @ "%@ Raising exception.", self.tag); 
 
		
	
		
			
				            @ throw  exception ; 
 
		
	
		
			
				            / /             DDLogWarn ( @ "%@ Ignoring exception.", self.tag); 
 
		
	
		
			
				            / /             return  nil ; 
 
		
	
		
			
				        } 
 
		
	
		
			
				    } ; 
 
		
	
		
			
				}  
		
	
	
		
			
				
					
						
						
						
							
								 
						
					 
				
			
			@ -100,13 +125,11 @@ static NSString *keychainDBPassAccount    = @"TSDatabasePass";
 
		
	
		
			
				    / /  Seeing  this  raise  an  exception - on - boot  for  some  users ,  making  it  impossible  to  get  any  good  data . 
 
		
	
		
			
				    @ try  { 
 
		
	
		
			
				        [ OWSReadReceipt  registerIndexOnSenderIdAndTimestampWithDatabase : self . database ] ; 
 
		
	
		
			
				    } 
 
		
	
		
			
				    @ catch  ( NSException  * exception )  { 
 
		
	
		
			
				    }  @ catch  ( NSException  * exception )  { 
 
		
	
		
			
				        DDLogError ( @ "%@ Failed to register read receipt index with exception: %@ with reason: %@", self.tag, exception, exception.reason); 
 
		
	
		
			
				    } 
 
		
	
		
			
				}  
		
	
		
			
				
 
		
	
		
			
				
 
		
	
		
			
				-  ( void ) protectSignalFiles  {  
		
	
		
			
				    [ self  protectFolderAtPath : [ TSAttachmentStream  attachmentsFolder ] ] ; 
 
		
	
		
			
				    [ self  protectFolderAtPath : [ self  dbPath ] ] ; 
 
		
	
	
		
			
				
					
						
							
								 
						
						
							
								 
						
						
					 
				
			
			@ -321,6 +344,8 @@ static NSString *keychainDBPassAccount    = @"TSDatabasePass";
 
		
	
		
			
				    [ [ self  init ]  setupDatabase ] ; 
 
		
	
		
			
				}  
		
	
		
			
				
 
		
	
		
			
				#pragma  mark  -  Logging 
 
		
	
		
			
				
 
		
	
		
			
				+  ( NSString  * ) tag  
		
	
		
			
				{  
		
	
		
			
				    return  [ NSString  stringWithFormat : @ "[ %@]", self.class];