logs清理

This commit is contained in:
lixiao 2025-04-17 16:39:01 +08:00
parent e5902632fd
commit 195f30cc3f
3 changed files with 24 additions and 0 deletions

View 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))
}
}

View File

@ -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
}