Skip to content

Commit

Permalink
[fix] Do not mount uncompressed TARs inside TARs recursively twice
Browse files Browse the repository at this point in the history
This problem got introduced when making the original TAR available when
mounting recursively with SQLiteIndexedTar. This is to be consistent
with the behavior with AutoMountLayer.
  • Loading branch information
mxmlnkn committed Apr 10, 2022
1 parent 15fba83 commit 07bc0ec
Show file tree
Hide file tree
Showing 6 changed files with 32 additions and 7 deletions.
4 changes: 2 additions & 2 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@

# Version 0.11.0 built on 2022-04-10

- Fix compatibility of --commit-overlay with older GNU tar versions by removing the redundant
--verbatim-file option.
- Fix compatibility of --commit-overlay with older GNU tar versions by removing the redundant --verbatim-file option.
- (ratarmountcore 0.3.1) Fix duplicate mounting of uncompressed TARs inside TARs when using --recursive.

# Version 0.11.0 built on 2022-04-06

Expand Down
4 changes: 4 additions & 0 deletions core/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,8 @@

# Version 0.3.1 built on 2022-04-10

- Fix duplicate mounting of uncompressed TARs inside TARs when using --recursive.

# Version 0.3.0 built on 2022-04-06

- Relax the check for GNU incremental TAR detection because the prefix field
Expand Down
22 changes: 18 additions & 4 deletions core/ratarmountcore/AutoMountLayer.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
from .factory import openMountSource
from .FolderMountSource import FolderMountSource
from .MountSource import FileInfo, MountSource
from .SQLiteIndexedTar import SQLiteIndexedTar, SQLiteIndexedTarUserData
from .utils import overrides


Expand Down Expand Up @@ -115,11 +116,24 @@ def _tryToMountFile(self, path: str) -> Optional[str]:
parentMountPoint, pathInsideParentMountPoint = self._simplyFindMounted(path)
parentMountSource = self.mounted[parentMountPoint].mountSource

try:
archiveFileInfo = parentMountSource.getFileInfo(pathInsideParentMountPoint)
if archiveFileInfo is None:
return None
archiveFileInfo = parentMountSource.getFileInfo(pathInsideParentMountPoint)
if archiveFileInfo is None:
return None

# Do not mount uncompressed TARs inside SQLiteIndexedTar when they already were mounted recursively!
mountSourceResult = parentMountSource.getMountSource(archiveFileInfo)
if mountSourceResult:
realMountSource = mountSourceResult[1]
if (
isinstance(realMountSource, SQLiteIndexedTar)
and realMountSource.mountRecursively
and archiveFileInfo.userdata
):
indexedTarData = archiveFileInfo.userdata[0]
if isinstance(indexedTarData, SQLiteIndexedTarUserData) and indexedTarData.istar:
return None

try:
_, deepestMountSource, deepestFileInfo = parentMountSource.getMountSource(archiveFileInfo)
if isinstance(deepestMountSource, FolderMountSource):
# Open from file path on host file system in order to write out TAR index files.
Expand Down
5 changes: 5 additions & 0 deletions core/ratarmountcore/SQLiteIndexedTar.py
Original file line number Diff line number Diff line change
Expand Up @@ -1300,6 +1300,11 @@ def _createIndex(

self._setFileInfo(tuple(modifiedFileInfo))

# Update isTar to True for the tar
modifiedFileInfo = list(fileInfo)
modifiedFileInfo[11] = isTar
self._setFileInfo(tuple(modifiedFileInfo))

fileObject.seek(oldPos)
self.tarFileName = oldPrintName

Expand Down
2 changes: 1 addition & 1 deletion setup.cfg
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ long_description_content_type = text/markdown
[options]
py_modules = ratarmount
install_requires =
ratarmountcore~=0.3.0
ratarmountcore~=0.3.1
fusepy
indexed_bzip2>=1.3.1
indexed_gzip>=1.6.3
Expand Down
2 changes: 2 additions & 0 deletions tests/runtests.sh
Original file line number Diff line number Diff line change
Expand Up @@ -1661,6 +1661,7 @@ tests+=(
832c78afcb9832e1a21c18212fc6c38b tests/gnu-sparse-files.tar 03.sparse1.bin

b026324c6904b2a9cb4b88d6d61c81d1 tests/2k-recursive-tars.tar.bz2 mimi/00001.tar/foo
3059b91c3562cd29457192eb3c3fe376 tests/2k-recursive-tars.tar.bz2 mimi/01234.tar.versions/1
8f30b20831bade7a2236edf09a55af60 tests/2k-recursive-tars.tar.bz2 mimi/01333.tar/foo
f95f8943f6dcf7b3c1c8c2cab5455f8b tests/2k-recursive-tars.tar.bz2 mimi/02000.tar/foo
c157a79031e1c40f85931829bc5fc552 tests/2k-recursive-tars.tar.bz2 mimi/foo
Expand Down Expand Up @@ -1696,6 +1697,7 @@ checkIndexPathOption tests/single-file.tar bar d3b07384d113edec49eaa6238ad5ff00
checkIndexFolderFallback tests/single-file.tar bar d3b07384d113edec49eaa6238ad5ff00
checkIndexArgumentChangeDetection tests/single-file.tar bar d3b07384d113edec49eaa6238ad5ff00
checkSuffixStripping tests/2k-recursive-tars.tar mimi/00001/foo b026324c6904b2a9cb4b88d6d61c81d1
checkSuffixStripping tests/2k-recursive-tars.tar mimi/01234.tar 3059b91c3562cd29457192eb3c3fe376
checkNestedRecursiveFolderMounting tests/single-file.tar bar d3b07384d113edec49eaa6238ad5ff00

checkTarEncoding tests/single-file.tar utf-8 bar d3b07384d113edec49eaa6238ad5ff00
Expand Down

0 comments on commit 07bc0ec

Please sign in to comment.