|  | @@ -20,6 +20,7 @@ static NSUInteger diskCapacity = 40 * 1024 * 1024;
 | 
	
		
			
				|  |  |  
 | 
	
		
			
				|  |  |  static NSTimeInterval cacheTime = 7 * 24 * 60 * 60;
 | 
	
		
			
				|  |  |  
 | 
	
		
			
				|  |  | +#define CACHE_PATH ([NSSearchPathForDirectoriesInDomains(NSCachesDirectory, NSUserDomainMask, YES) firstObject])
 | 
	
		
			
				|  |  |  @implementation KSCacheManager
 | 
	
		
			
				|  |  |  
 | 
	
		
			
				|  |  |  + (KSCacheManager *)shareManager {
 | 
	
	
		
			
				|  | @@ -64,10 +65,11 @@ static NSTimeInterval cacheTime = 7 * 24 * 60 * 60;
 | 
	
		
			
				|  |  |          NSString *directoryPath = nil;
 | 
	
		
			
				|  |  |          directoryPath = [[NSUserDefaults standardUserDefaults] objectForKey:cacheDirKey];
 | 
	
		
			
				|  |  |          if (!directoryPath) {
 | 
	
		
			
				|  |  | -            directoryPath = [[NSSearchPathForDirectoriesInDomains(NSCachesDirectory, NSUserDomainMask, YES)[0] stringByAppendingPathComponent:@"YQNetworking"] stringByAppendingPathComponent:@"networkCache"];
 | 
	
		
			
				|  |  | +            directoryPath = @"KSNetworking/networkCache";
 | 
	
		
			
				|  |  |              [[NSUserDefaults standardUserDefaults] setObject:directoryPath forKey:cacheDirKey];
 | 
	
		
			
				|  |  |              [[NSUserDefaults standardUserDefaults] synchronize];
 | 
	
		
			
				|  |  |          }
 | 
	
		
			
				|  |  | +        directoryPath = [CACHE_PATH stringByAppendingPathComponent:directoryPath];
 | 
	
		
			
				|  |  |          [KSDiskCache writeData:data toDir:directoryPath filename:hash];
 | 
	
		
			
				|  |  |          
 | 
	
		
			
				|  |  |          [[KSLRUManager shareManager] addFileNode:hash];
 | 
	
	
		
			
				|  | @@ -90,7 +92,7 @@ static NSTimeInterval cacheTime = 7 * 24 * 60 * 60;
 | 
	
		
			
				|  |  |      
 | 
	
		
			
				|  |  |      if (!cacheData) {
 | 
	
		
			
				|  |  |          NSString *directoryPath = [[NSUserDefaults standardUserDefaults] objectForKey:cacheDirKey];
 | 
	
		
			
				|  |  | -        
 | 
	
		
			
				|  |  | +        directoryPath = [CACHE_PATH stringByAppendingPathComponent:directoryPath];
 | 
	
		
			
				|  |  |          if (directoryPath) {
 | 
	
		
			
				|  |  |              cacheData = [KSDiskCache readDataFromDir:directoryPath filename:hash];
 | 
	
		
			
				|  |  |              
 | 
	
	
		
			
				|  | @@ -125,13 +127,12 @@ static NSTimeInterval cacheTime = 7 * 24 * 60 * 60;
 | 
	
		
			
				|  |  |      NSString *directoryPath = nil;
 | 
	
		
			
				|  |  |      directoryPath = [[NSUserDefaults standardUserDefaults] objectForKey:downloadDirKey];
 | 
	
		
			
				|  |  |      if (!directoryPath) {
 | 
	
		
			
				|  |  | -        directoryPath = [[NSSearchPathForDirectoriesInDomains(NSCachesDirectory, NSUserDomainMask, YES)[0] stringByAppendingPathComponent:@"YQNetworking"] stringByAppendingPathComponent:@"download"];
 | 
	
		
			
				|  |  | -        
 | 
	
		
			
				|  |  | +        directoryPath = @"KSNetworking/download";
 | 
	
		
			
				|  |  |          [[NSUserDefaults standardUserDefaults] setObject:directoryPath forKey:downloadDirKey];
 | 
	
		
			
				|  |  |          [[NSUserDefaults standardUserDefaults] synchronize];
 | 
	
		
			
				|  |  |      }
 | 
	
		
			
				|  |  |      
 | 
	
		
			
				|  |  | -    
 | 
	
		
			
				|  |  | +    directoryPath = [CACHE_PATH stringByAppendingPathComponent:directoryPath];
 | 
	
		
			
				|  |  |      [KSDiskCache writeData:data toDir:directoryPath filename:fileName];
 | 
	
		
			
				|  |  |      
 | 
	
		
			
				|  |  |  }
 | 
	
	
		
			
				|  | @@ -159,7 +160,7 @@ static NSTimeInterval cacheTime = 7 * 24 * 60 * 60;
 | 
	
		
			
				|  |  |      
 | 
	
		
			
				|  |  |      
 | 
	
		
			
				|  |  |      NSString *directoryPath = [[NSUserDefaults standardUserDefaults] objectForKey:downloadDirKey];
 | 
	
		
			
				|  |  | -    
 | 
	
		
			
				|  |  | +    directoryPath = [CACHE_PATH stringByAppendingPathComponent:directoryPath];
 | 
	
		
			
				|  |  |      if (directoryPath) data = [KSDiskCache readDataFromDir:directoryPath filename:fileName];
 | 
	
		
			
				|  |  |      
 | 
	
		
			
				|  |  |      if (data) {
 | 
	
	
		
			
				|  | @@ -171,36 +172,38 @@ static NSTimeInterval cacheTime = 7 * 24 * 60 * 60;
 | 
	
		
			
				|  |  |  }
 | 
	
		
			
				|  |  |  
 | 
	
		
			
				|  |  |  - (NSUInteger)totalCacheSize {
 | 
	
		
			
				|  |  | -    NSString *diretoryPath = [[NSUserDefaults standardUserDefaults] objectForKey: cacheDirKey];
 | 
	
		
			
				|  |  | -    
 | 
	
		
			
				|  |  | +    NSString *diretoryPath = [[NSUserDefaults standardUserDefaults] objectForKey:cacheDirKey];
 | 
	
		
			
				|  |  | +    diretoryPath = [CACHE_PATH stringByAppendingPathComponent:diretoryPath];
 | 
	
		
			
				|  |  |      return [KSDiskCache dataSizeInDir:diretoryPath];
 | 
	
		
			
				|  |  |  }
 | 
	
		
			
				|  |  |  
 | 
	
		
			
				|  |  |  - (NSUInteger)totalDownloadDataSize {
 | 
	
		
			
				|  |  | -    NSString *diretoryPath = [[NSUserDefaults standardUserDefaults] objectForKey: downloadDirKey];
 | 
	
		
			
				|  |  | -    
 | 
	
		
			
				|  |  | +    NSString *diretoryPath = [[NSUserDefaults standardUserDefaults] objectForKey:downloadDirKey];
 | 
	
		
			
				|  |  | +    diretoryPath = [CACHE_PATH stringByAppendingPathComponent:diretoryPath];
 | 
	
		
			
				|  |  |      return [KSDiskCache dataSizeInDir:diretoryPath];
 | 
	
		
			
				|  |  |  }
 | 
	
		
			
				|  |  |  
 | 
	
		
			
				|  |  |  - (void)clearDownloadData {
 | 
	
		
			
				|  |  |      NSString *diretoryPath = [[NSUserDefaults standardUserDefaults] objectForKey:downloadDirKey];
 | 
	
		
			
				|  |  | -    
 | 
	
		
			
				|  |  | +    diretoryPath = [CACHE_PATH stringByAppendingPathComponent:diretoryPath];
 | 
	
		
			
				|  |  |      [KSDiskCache clearDataIinDir:diretoryPath];
 | 
	
		
			
				|  |  |  }
 | 
	
		
			
				|  |  |  
 | 
	
		
			
				|  |  |  - (NSString *)getDownDirectoryPath {
 | 
	
		
			
				|  |  |      NSString *diretoryPath = [[NSUserDefaults standardUserDefaults] objectForKey:downloadDirKey];
 | 
	
		
			
				|  |  | +    diretoryPath = [CACHE_PATH stringByAppendingPathComponent:diretoryPath];
 | 
	
		
			
				|  |  |      return diretoryPath;
 | 
	
		
			
				|  |  |  }
 | 
	
		
			
				|  |  |  
 | 
	
		
			
				|  |  |  - (NSString *)getCacheDiretoryPath {
 | 
	
		
			
				|  |  |      NSString *diretoryPath = [[NSUserDefaults standardUserDefaults] objectForKey:cacheDirKey];
 | 
	
		
			
				|  |  | +    diretoryPath = [CACHE_PATH stringByAppendingPathComponent:diretoryPath];
 | 
	
		
			
				|  |  |      return diretoryPath;
 | 
	
		
			
				|  |  |  }
 | 
	
		
			
				|  |  |  
 | 
	
		
			
				|  |  |  - (void)clearTotalCache {
 | 
	
		
			
				|  |  |      NSString *directoryPath = [[NSUserDefaults standardUserDefaults] objectForKey:cacheDirKey];
 | 
	
		
			
				|  |  | -    
 | 
	
		
			
				|  |  | +    directoryPath = [CACHE_PATH stringByAppendingPathComponent:directoryPath];
 | 
	
		
			
				|  |  |      [KSDiskCache clearDataIinDir:directoryPath];
 | 
	
		
			
				|  |  |  }
 | 
	
		
			
				|  |  |  
 | 
	
	
		
			
				|  | @@ -208,6 +211,7 @@ static NSTimeInterval cacheTime = 7 * 24 * 60 * 60;
 | 
	
		
			
				|  |  |      if ([self totalCacheSize] > diskCapacity) {
 | 
	
		
			
				|  |  |          NSArray *deleteFiles = [[KSLRUManager shareManager] removeLRUFileNodeWithCacheTime:cacheTime];
 | 
	
		
			
				|  |  |          NSString *directoryPath = [[NSUserDefaults standardUserDefaults] objectForKey:cacheDirKey];
 | 
	
		
			
				|  |  | +        directoryPath = [CACHE_PATH stringByAppendingPathComponent:directoryPath];
 | 
	
		
			
				|  |  |          if (directoryPath && deleteFiles.count > 0) {
 | 
	
		
			
				|  |  |              [deleteFiles enumerateObjectsUsingBlock:^(NSString *obj, NSUInteger idx, BOOL * _Nonnull stop) {
 | 
	
		
			
				|  |  |                  NSString *filePath = [directoryPath stringByAppendingPathComponent:obj];
 |