mirror of
				https://github.com/blakeblackshear/frigate.git
				synced 2025-10-27 10:52:11 +01:00 
			
		
		
		
	Migrate export filenames (#11005)
* Migrate export filenames * formatting * Remove test.yaml saving
This commit is contained in:
		
							parent
							
								
									392ff1319d
								
							
						
					
					
						commit
						8230813b79
					
				@ -223,8 +223,6 @@ def update_yaml_file(file_path, key_path, new_value):
 | 
				
			|||||||
        data = yaml.load(f)
 | 
					        data = yaml.load(f)
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    data = update_yaml(data, key_path, new_value)
 | 
					    data = update_yaml(data, key_path, new_value)
 | 
				
			||||||
    with open("/config/test.yaml", "w") as f:
 | 
					 | 
				
			||||||
        yaml.dump(data, f)
 | 
					 | 
				
			||||||
    with open(file_path, "w") as f:
 | 
					    with open(file_path, "w") as f:
 | 
				
			||||||
        yaml.dump(data, f)
 | 
					        yaml.dump(data, f)
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
				
			|||||||
@ -6,7 +6,7 @@ import shutil
 | 
				
			|||||||
 | 
					
 | 
				
			||||||
from ruamel.yaml import YAML
 | 
					from ruamel.yaml import YAML
 | 
				
			||||||
 | 
					
 | 
				
			||||||
from frigate.const import CONFIG_DIR
 | 
					from frigate.const import CONFIG_DIR, EXPORT_DIR
 | 
				
			||||||
 | 
					
 | 
				
			||||||
logger = logging.getLogger(__name__)
 | 
					logger = logging.getLogger(__name__)
 | 
				
			||||||
 | 
					
 | 
				
			||||||
@ -46,6 +46,16 @@ def migrate_frigate_config(config_file: str):
 | 
				
			|||||||
            yaml.dump(new_config, f)
 | 
					            yaml.dump(new_config, f)
 | 
				
			||||||
        previous_version = 0.14
 | 
					        previous_version = 0.14
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					        logger.info("Migrating export file names...")
 | 
				
			||||||
 | 
					        for file in os.listdir(EXPORT_DIR):
 | 
				
			||||||
 | 
					            if "@" not in file:
 | 
				
			||||||
 | 
					                continue
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					            new_name = file.replace("@", "_")
 | 
				
			||||||
 | 
					            os.rename(
 | 
				
			||||||
 | 
					                os.path.join(EXPORT_DIR, file), os.path.join(EXPORT_DIR, new_name)
 | 
				
			||||||
 | 
					            )
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    with open(version_file, "w") as f:
 | 
					    with open(version_file, "w") as f:
 | 
				
			||||||
        f.write(str(CURRENT_CONFIG_VERSION))
 | 
					        f.write(str(CURRENT_CONFIG_VERSION))
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
				
			|||||||
		Loading…
	
		Reference in New Issue
	
	Block a user