Skip to content

Commit e689c73

Browse files
authored
Merge pull request #1397 from leggedrobotics/dev
Release 0.43.3
2 parents 09811bc + 56fb416 commit e689c73

File tree

12 files changed

+142
-23
lines changed

12 files changed

+142
-23
lines changed

backend/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "kleinkram-backend",
3-
"version": "0.43.2",
3+
"version": "0.43.3",
44
"description": "",
55
"author": "",
66
"private": true,

backend/src/endpoints/project/project.controller.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -198,7 +198,7 @@ export class ProjectController {
198198

199199
// TODO: this controller should get removed at some point,
200200
// filtered and recent will effectively be replaced by `GET /projects`
201-
// for the getDefaultRights endpoint we should make a seperate controller that
201+
// for the getDefaultRights endpoint we should make a separate controller that
202202
// does all the access control stuff
203203
@Controller('oldProject')
204204
export class OldProjectController {

backend/src/endpoints/queue/queue.controller.ts

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -63,6 +63,16 @@ export class QueueController {
6363
};
6464
}
6565

66+
@Post('recalculateHashes')
67+
@AdminOnly()
68+
@OutputDto(null)
69+
async recalculateHashes(): Promise<{
70+
success: boolean;
71+
fileCount: number;
72+
}> {
73+
return await this.queueService.recalculateHashes();
74+
}
75+
6676
@Get('active')
6777
@LoggedIn()
6878
@OutputDto(null)

backend/src/services/queue.service.ts

Lines changed: 36 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ import { InjectRepository } from '@nestjs/typeorm';
44
import {
55
FindOptionsWhere,
66
In,
7+
IsNull,
78
LessThan,
89
Like,
910
MoreThan,
@@ -164,6 +165,41 @@ export class QueueService implements OnModuleInit {
164165
return {};
165166
}
166167

168+
/**
169+
* re-calculates the hashes for all files without a valid hash
170+
*/
171+
async recalculateHashes(): Promise<{
172+
success: boolean;
173+
fileCount: number;
174+
}> {
175+
// search for files with no hash (empty or null) and state OK
176+
const files = await this.fileRepository.find({
177+
where: [
178+
{ hash: IsNull(), state: FileState.OK },
179+
{ hash: '', state: FileState.OK },
180+
],
181+
relations: ['mission', 'mission.project'],
182+
});
183+
184+
logger.debug(`Add ${files.length} files to queue for hash calculation`);
185+
logger.debug(JSON.stringify(files.map((file) => file.uuid)));
186+
187+
for (const file of files) {
188+
try {
189+
await this.fileQueue.add('extractHashFromMinio', {
190+
file_uuid: file.uuid,
191+
});
192+
} catch (error: any) {
193+
logger.error(error);
194+
}
195+
}
196+
197+
return {
198+
success: true,
199+
fileCount: files.length,
200+
};
201+
}
202+
167203
async confirmUpload(uuid: string, md5: string): Promise<void> {
168204
const queue = await this.queueRepository.findOneOrFail({
169205
where: { identifier: uuid },
@@ -191,12 +227,6 @@ export class QueueService implements OnModuleInit {
191227
file.size = fileInfo.size;
192228
await this.fileRepository.save(file);
193229

194-
// abort if autoConvert is disabled
195-
if (!file.mission?.project?.autoConvert) {
196-
logger.debug(`Skip auto convert to mcap`);
197-
return;
198-
}
199-
200230
queue.state = QueueState.AWAITING_PROCESSING;
201231
await this.queueRepository.save(queue);
202232

cli/setup.cfg

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
[metadata]
22
name = kleinkram
3-
version = 0.43.2
3+
version = 0.43.3
44
description = give me your bags
55
long_description = file: README.md
66
long_description_content_type = text/markdown

common/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "kleinkram-common",
3-
"version": "0.43.2",
3+
"version": "0.43.3",
44
"license": "MIT",
55
"scripts": {
66
"seed:config": "ts-node ./node_modules/typeorm-seeding/dist/cli.js config",

docs/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "kleinkram-docs",
3-
"version": "0.43.2",
3+
"version": "0.43.3",
44
"license": "MIT",
55
"target": "es2022",
66
"scripts": {

frontend/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "kleinkram-frontend",
3-
"version": "0.43.2",
3+
"version": "0.43.3",
44
"description": "Data storage of ROS bags",
55
"productName": "Kleinkram",
66
"author": "Johann Schwabe <[email protected]>",

frontend/src/components/user-profile/admin-settings.vue

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,21 @@
2828
There is no confirmation!
2929
</div>
3030
</div>
31+
32+
<div style="width: 300px; margin-left: 20px">
33+
<q-btn
34+
label="Recalculate Hashes"
35+
class="button-border bg-button-primary full-width"
36+
icon="sym_o_fingerprint"
37+
flat
38+
@click="recalculateHashes"
39+
/>
40+
<div class="help-text q-pt-sm">
41+
This will extract the MD5 hash from the file (from minio) and
42+
store it in the database. This action cannot be undone. There is
43+
no confirmation!
44+
</div>
45+
</div>
3146
</div>
3247
</template>
3348
<script setup lang="ts">
@@ -57,4 +72,15 @@ async function resetFileSizes(): Promise<void> {
5772
timeout: 2000,
5873
});
5974
}
75+
76+
async function recalculateHashes(): Promise<void> {
77+
const { data } = await axios.post('queue/recalculateHashes');
78+
79+
$q.notify({
80+
message: `Recalculating hashes started. ${data.fileCount} files to process`,
81+
color: 'positive',
82+
position: 'bottom',
83+
timeout: 2000,
84+
});
85+
}
6086
</script>

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "kleinkram",
3-
"version": "0.43.2",
3+
"version": "0.43.3",
44
"main": "index.js",
55
"repository": "[email protected]:leggedrobotics/GrandTourDatasets.git",
66
"author": "Johann Schwabe <[email protected]>",

0 commit comments

Comments
 (0)