Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Added support for .rar and some other archives #7729

Merged
merged 13 commits into from
Apr 11, 2024
1 change: 1 addition & 0 deletions Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -110,6 +110,7 @@ ENV DJANGO_SETTINGS_MODULE="cvat.settings.${CVAT_CONFIGURATION}"
RUN apt-get update && \
DEBIAN_FRONTEND=noninteractive apt-get --no-install-recommends install -yq \
bzip2 \
unrar \
klakhov marked this conversation as resolved.
Show resolved Hide resolved
ca-certificates \
curl \
git \
Expand Down
4 changes: 4 additions & 0 deletions changelog.d/20240405_091941_klakhov_rar_support.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
### Added

- Support for `.rar` archives
klakhov marked this conversation as resolved.
Show resolved Hide resolved
(<https://github.com/opencv/cvat/pull/7729>)
2 changes: 1 addition & 1 deletion cvat/apps/engine/media.mimetypes
Original file line number Diff line number Diff line change
Expand Up @@ -200,7 +200,7 @@ image/x-quicktime qif

# possible archive mimetypes (limited set)
application/gzip gz
application/rar rar
application/x-rar-compressed rar
application/x-7z-compressed 7z
application/x-bzip bz bz2
application/x-bzip-compressed-tar tar.bz tar.bz2 tb2 tbz tbz2
Expand Down
5 changes: 4 additions & 1 deletion cvat/apps/engine/media_extractors.py
klakhov marked this conversation as resolved.
Show resolved Hide resolved
Original file line number Diff line number Diff line change
@@ -1,8 +1,10 @@
# Copyright (C) 2019-2022 Intel Corporation
# Copyright (C) 2024 CVAT.ai Corporation
#
# SPDX-License-Identifier: MIT

import os
import sys
import tempfile
import shutil
import zipfile
Expand Down Expand Up @@ -266,7 +268,8 @@ def __init__(self,

self._archive_source = source_path[0]
tmp_dir = extract_dir if extract_dir else os.path.dirname(source_path[0])
Archive(self._archive_source).extractall(tmp_dir)
patool_path = os.path.join(sys.exec_prefix, 'bin', 'patool')
klakhov marked this conversation as resolved.
Show resolved Hide resolved
Archive(self._archive_source).extractall(tmp_dir, False, patool_path)
if not extract_dir:
os.remove(self._archive_source)
super().__init__(
Expand Down
Loading