logs清理
This commit is contained in:
		
							parent
							
								
									e5902632fd
								
							
						
					
					
						commit
						195f30cc3f
					
				
										
											Binary file not shown.
										
									
								
							
							
								
								
									
										22
									
								
								entry/src/main/ets/common/service/logService.ts
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										22
									
								
								entry/src/main/ets/common/service/logService.ts
									
									
									
									
									
										Normal file
									
								
							| @ -0,0 +1,22 @@ | ||||
| import fs from '@ohos.file.fs'; | ||||
| 
 | ||||
| 
 | ||||
| export function delLog(offset: number) { | ||||
|   try { | ||||
|     const path = "/mnt/hmdfs/100/account/device_view/local/files/duolun/logs" | ||||
|     const list = fs.listFileSync(path) | ||||
|     const now = new Date().getTime() | ||||
|     list.forEach(filename => { | ||||
|       const year = Number(filename.split("_")[0]) | ||||
|       const month = Number(filename.split("_")[1]) - 1 | ||||
|       const date = Number(filename.split("_")[2]) | ||||
|       const fileDate = new Date(year, month, date).getTime() | ||||
|       if (now - fileDate >= offset * 24 * 60 * 60 * 1000) { | ||||
|         fs.rmdirSync(path + "/" + filename) | ||||
|         console.log("lixiao delete log success path: ", path + "/" + filename) | ||||
|       } | ||||
|     }) | ||||
|   } catch (e) { | ||||
|     console.log("lixiao delete log error", JSON.stringify(e)) | ||||
|   } | ||||
| } | ||||
| @ -23,6 +23,7 @@ import IdlServiceExtProxy from '../IdlServiceExt/idl_service_ext_proxy'; | ||||
| import Want from '@ohos.app.ability.Want'; | ||||
| import emitter from '@ohos.events.emitter'; | ||||
| import { examJudgeVersion } from './judgeSDK/api'; | ||||
| import { delLog } from '../common/service/logService'; | ||||
| 
 | ||||
| @Entry | ||||
| @Component | ||||
| @ -445,6 +446,7 @@ struct Index { | ||||
|           // globalThis.param854Str=sys.v_value | ||||
|           delPic(Number(sys.v_value), 1) | ||||
|           delPic(Number(sys.v_value), 2) | ||||
|           delLog(Number(sys.v_value)) | ||||
|           // this.delLoading=false | ||||
| 
 | ||||
|         } | ||||
|  | ||||
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user