|  |  |  | @ -31,6 +31,11 @@ | 
		
	
		
			
				|  |  |  |  | // * Orphan attachments (with no message). | 
		
	
		
			
				|  |  |  |  | // * Orphan attachment files (with no attachment). | 
		
	
		
			
				|  |  |  |  | // * Missing attachment files (cannot be cleaned up). | 
		
	
		
			
				|  |  |  |  | //   These are attachments which have no file on disk.  They should be extremely rare - | 
		
	
		
			
				|  |  |  |  | //   the only cases I have seen are probably due to debugging. | 
		
	
		
			
				|  |  |  |  | //   They can't be cleaned up - we don't want to delete the TSAttachmentStream or | 
		
	
		
			
				|  |  |  |  | //   its corresponding message.  Better that the broken message shows up in the | 
		
	
		
			
				|  |  |  |  | //   conversation view. | 
		
	
		
			
				|  |  |  |  | + (void)auditAndCleanup:(BOOL)shouldCleanup | 
		
	
		
			
				|  |  |  |  | { | 
		
	
		
			
				|  |  |  |  |     NSString *attachmentsFolder = [TSAttachmentStream attachmentsFolder]; | 
		
	
	
		
			
				
					|  |  |  | @ -152,7 +157,10 @@ | 
		
	
		
			
				|  |  |  |  |     // being created/written, so we don't clean up anything recent. | 
		
	
		
			
				|  |  |  |  |     const NSTimeInterval kMinimumOrphanAge = 15 * 60.f; | 
		
	
		
			
				|  |  |  |  | 
 | 
		
	
		
			
				|  |  |  |  |     if (shouldCleanup) { | 
		
	
		
			
				|  |  |  |  |     if (!shouldCleanup) { | 
		
	
		
			
				|  |  |  |  |         return; | 
		
	
		
			
				|  |  |  |  |     } | 
		
	
		
			
				|  |  |  |  | 
 | 
		
	
		
			
				|  |  |  |  |     [databaseConnection readWriteWithBlock:^(YapDatabaseReadWriteTransaction *_Nonnull transaction) { | 
		
	
		
			
				|  |  |  |  |         for (NSString *interactionId in orphanInteractionIds) { | 
		
	
		
			
				|  |  |  |  |             TSInteraction *interaction = [TSInteraction fetchObjectWithUniqueID:interactionId]; | 
		
	
	
		
			
				
					|  |  |  | @ -206,7 +214,6 @@ | 
		
	
		
			
				|  |  |  |  |             OWSFail(@"Could not remove orphan file at: %@", filePath); | 
		
	
		
			
				|  |  |  |  |         } | 
		
	
		
			
				|  |  |  |  |     } | 
		
	
		
			
				|  |  |  |  |     } | 
		
	
		
			
				|  |  |  |  | } | 
		
	
		
			
				|  |  |  |  | 
 | 
		
	
		
			
				|  |  |  |  | + (void)printPaths:(NSArray<NSString *> *)paths label:(NSString *)label | 
		
	
	
		
			
				
					|  |  |  | 
 |