Improved Input::checkHeaderTimes function to be less spammy about non-file inputs
This commit is contained in:
		
							parent
							
								
									26f4b2efd9
								
							
						
					
					
						commit
						29c37fd4e9
					
				
					 1 changed files with 9 additions and 21 deletions
				
			
		|  | @ -69,32 +69,20 @@ namespace Mist { | ||||||
|     isBuffer = false; |     isBuffer = false; | ||||||
|   } |   } | ||||||
| 
 | 
 | ||||||
|   void Input::checkHeaderTimes(std::string streamFile){ |   void Input::checkHeaderTimes(std::string streamFile) { | ||||||
|     if (streamFile == "-" || streamFile == "push://") { |     struct stat bufStream; | ||||||
|  |     struct stat bufHeader; | ||||||
|  |     if (stat(streamFile.c_str(), &bufStream) != 0) { | ||||||
|  |       INSANE_MSG("Source is not a file - ignoring header check"); | ||||||
|       return; |       return; | ||||||
|     } |     } | ||||||
|     std::string headerFile = streamFile + ".dtsh"; |     std::string headerFile = streamFile + ".dtsh"; | ||||||
|     FILE * tmp = fopen(headerFile.c_str(),"r"); |     if (stat(headerFile.c_str(), &bufHeader) != 0) { | ||||||
|     if (tmp == NULL){ |       INSANE_MSG("No header exists to compare - ignoring header check"); | ||||||
|       DEBUG_MSG(DLVL_HIGH, "Can't open header: %s. Assuming all is fine.", headerFile.c_str() );   |  | ||||||
|       return; |       return; | ||||||
|     } |     } | ||||||
|     struct stat bufStream; |     if (bufHeader.st_mtime < bufStream.st_mtime) { | ||||||
|     struct stat bufHeader; |       INFO_MSG("Overwriting outdated DTSH header file: %s ", headerFile.c_str()); | ||||||
|     //fstat(fileno(streamFile), &bufStream);
 |  | ||||||
|     //fstat(fileno(tmp), &bufHeader);
 |  | ||||||
|     if (stat(streamFile.c_str(), &bufStream) !=0 || stat(headerFile.c_str(), &bufHeader) !=0){ |  | ||||||
|       DEBUG_MSG(DLVL_HIGH, "Could not compare stream and header timestamps - assuming all is fine."); |  | ||||||
|       fclose(tmp); |  | ||||||
|       return; |  | ||||||
|     } |  | ||||||
| 
 |  | ||||||
|     int timeStream = bufStream.st_mtime; |  | ||||||
|     int timeHeader = bufHeader.st_mtime; |  | ||||||
|     fclose(tmp);     |  | ||||||
|     if (timeHeader < timeStream){ |  | ||||||
|       //delete filename
 |  | ||||||
|       INFO_MSG("Overwriting outdated DTSH header file: %s ",headerFile.c_str()); |  | ||||||
|       remove(headerFile.c_str()); |       remove(headerFile.c_str()); | ||||||
|     } |     } | ||||||
|   } |   } | ||||||
|  |  | ||||||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue
	
	 Thulinma
						Thulinma