Skip to content

Commit 7251755

Browse files
bsekachevnmanovic
authored andcommitted
Fixed some issues with dump (#904)
* Changed method for downloading annotations * Initial commit * Initial commit * Updated download method for dataset * fixed eslint error
1 parent f3a3f4c commit 7251755

File tree

4 files changed

+13
-14
lines changed

4 files changed

+13
-14
lines changed

cvat-core/src/server-proxy.js

+5-7
Original file line numberDiff line numberDiff line change
@@ -563,20 +563,18 @@
563563

564564
return new Promise((resolve, reject) => {
565565
async function request() {
566-
try {
567-
const response = await Axios
568-
.get(`${url}`, {
569-
proxy: config.proxy,
570-
});
566+
Axios.get(`${url}`, {
567+
proxy: config.proxy,
568+
}).then((response) => {
571569
if (response.status === 202) {
572570
setTimeout(request, 3000);
573571
} else {
574572
url = `${url}&action=download`;
575573
resolve(url);
576574
}
577-
} catch (errorData) {
575+
}).catch((errorData) => {
578576
reject(generateError(errorData));
579-
}
577+
});
580578
}
581579

582580
setTimeout(request);

cvat-ui/src/actions/tasks-actions.ts

+6-6
Original file line numberDiff line numberDiff line change
@@ -164,9 +164,9 @@ ThunkAction<Promise<void>, {}, {}, AnyAction> {
164164
try {
165165
dispatch(dumpAnnotation(task, dumper));
166166
const url = await task.annotations.dump(task.name, dumper);
167-
// false positive
168-
// eslint-disable-next-line security/detect-non-literal-fs-filename
169-
window.open(url);
167+
const downloadAnchor = (window.document.getElementById('downloadAnchor') as HTMLAnchorElement);
168+
downloadAnchor.href = url;
169+
downloadAnchor.click();
170170
} catch (error) {
171171
dispatch(dumpAnnotationFailed(task, dumper, error));
172172
return;
@@ -270,9 +270,9 @@ ThunkAction<Promise<void>, {}, {}, AnyAction> {
270270

271271
try {
272272
const url = await task.annotations.exportDataset(exporter.tag);
273-
// false positive
274-
// eslint-disable-next-line security/detect-non-literal-fs-filename
275-
window.open(url, '_blank');
273+
const downloadAnchor = (window.document.getElementById('downloadAnchor') as HTMLAnchorElement);
274+
downloadAnchor.href = url;
275+
downloadAnchor.click();
276276
} catch (error) {
277277
dispatch(exportDatasetFailed(task, exporter, error));
278278
}

cvat-ui/src/components/cvat-app.tsx

+1
Original file line numberDiff line numberDiff line change
@@ -233,6 +233,7 @@ export default class CVATApplication extends React.PureComponent<CVATAppProps> {
233233
</Switch>
234234
<FeedbackComponent/>
235235
<ModelRunnerModalContainer/>
236+
<a id='downloadAnchor' style={{ display: 'none' }} download/>
236237
</Layout.Content>
237238
</Layout>
238239
</BrowserRouter>

cvat/apps/engine/views.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -364,7 +364,7 @@ def dump(self, request, pk, filename):
364364
"{}.{}.{}.{}".format(filename, username, timestamp, db_dumper.format.lower()))
365365

366366
queue = django_rq.get_queue("default")
367-
rq_id = "{}@/api/v1/tasks/{}/annotations/{}".format(username, pk, filename)
367+
rq_id = "{}@/api/v1/tasks/{}/annotations/{}/{}".format(username, pk, dump_format, filename)
368368
rq_job = queue.fetch_job(rq_id)
369369

370370
if rq_job:

0 commit comments

Comments
 (0)