init
This commit is contained in:
		
							
								
								
									
										31
									
								
								core/objects/tree_object.py
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										31
									
								
								core/objects/tree_object.py
									
									
									
									
									
										Normal file
									
								
							| @@ -0,0 +1,31 @@ | ||||
| """ | ||||
| ******************************************** | ||||
| * @Date: 2024 09 27 | ||||
| * @Description: BackObject树对象,标记多个存储存储对象和树对象,为备份对象提供目标 | ||||
| ******************************************** | ||||
| """ | ||||
|  | ||||
| from typing import Dict, List | ||||
| from .blob_object import BlobObject | ||||
| import os | ||||
|  | ||||
|  | ||||
| class TreeObject: | ||||
|     __children: List[BlobObject] = []  # 备份树节点列表,节点为BlobObject备份存储对象 | ||||
|     __file_map: Dict[str, str] = {}  # 备份文件路径到blob对象的映射 | ||||
|  | ||||
|     def __init__(self, tree_path: str): | ||||
|         self.tree_path = tree_path | ||||
|         self.__loadChildren() | ||||
|  | ||||
|     def __loadChildren(self): | ||||
|         for root, dirs, files in os.walk(self.tree_path): | ||||
|             for name in files: | ||||
|                 blob_path = os.path.join(root, name) | ||||
|                 blob = BlobObject(blob_path) | ||||
|                 self.__children.append(blob) | ||||
|                 self.__file_map[blob_path] = blob.object_id | ||||
|  | ||||
|     def writeBlobs(self, base_path: str): | ||||
|         for child in self.__children: | ||||
|             child.writeBlob(base_path) | ||||
		Reference in New Issue
	
	Block a user