Fix bw tool (#4167)

Signed-off-by: Denis Bykhov <bykhov.denis@gmail.com>
This commit is contained in:
Denis Bykhov 2023-12-08 19:29:25 +06:00 committed by GitHub
parent 47b4f3f14d
commit 56d05e28f7
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 25 additions and 0 deletions

View File

@ -145,6 +145,25 @@ export async function cleanWorkspace (
}
}
export async function fixMinioBW (workspaceId: WorkspaceId, minio: MinioService): Promise<void> {
console.log('try clean bw miniature for ', workspaceId.name)
const from = new Date(new Date().setDate(new Date().getDate() - 7))
const list = await minio.list(workspaceId)
console.log('found', list.length)
let removed = 0
for (const obj of list) {
if (obj.lastModified < from) continue
if (obj.name.includes('%size%')) {
await minio.remove(workspaceId, [obj.name])
removed++
if (removed % 100 === 0) {
console.log('removed: ', removed)
}
}
}
console.log('FINISH, removed: ', removed)
}
export async function cleanRemovedTransactions (workspaceId: WorkspaceId, transactorUrl: string): Promise<void> {
const connection = (await connect(transactorUrl, workspaceId, undefined, {
mode: 'backup'

View File

@ -59,6 +59,7 @@ import {
cleanRemovedTransactions,
cleanWorkspace,
fixCommentDoubleIdCreate,
fixMinioBW,
fixSkills,
optimizeModel
} from './clean'
@ -493,6 +494,11 @@ export function devTool (
})
})
program.command('fix-bw-workspace <workspace>').action(async (workspace: string) => {
const { minio } = prepareTools()
await fixMinioBW(getWorkspaceId(workspace, productId), minio)
})
program
.command('clean-removed-transactions <workspace>')
.description('set user role')