Skip to content

Commit

Permalink
fix performance bug with uncompressed TAR
Browse files Browse the repository at this point in the history
  • Loading branch information
mxmlnkn committed Dec 6, 2019
1 parent d51dd4e commit a74cd54
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 5 deletions.
5 changes: 4 additions & 1 deletion package.sh
Original file line number Diff line number Diff line change
Expand Up @@ -9,4 +9,7 @@ rm -rf build dist *.egg-info __pycache__
python3 setup.py build_ext --inplace --cython
python3 setup.py sdist bdist_wheel

#twine upload dist/*
tests/runtests.sh

srcPackage=$( find dist -name '*.tar.gz' -printf "%T@ %p\n" | sort -n | sed -n -r '1{ s|[0-9.]+ ||p; }' )
twine upload "$srcPackage"
11 changes: 8 additions & 3 deletions ratarmount.py
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@
import fuse


__version__ = '0.3.3'
__version__ = '0.3.4'

printDebug = 1

Expand Down Expand Up @@ -218,7 +218,12 @@ def createIndex( self, fileObject, progressBar = None, pathPrefix = '', streamOf

# 2. Open TAR file reader
try:
loadedTarFile = tarfile.open( fileobj = fileObject, mode = 'r|' )
streamed = ( hasBzip2Support and isinstance( fileObject, SeekableBzip2 ) ) or \
( hasGzipSupport and isinstance( fileObject, IndexedGzipFile ) )
# r: uses seeks to skip to the next file inside the TAR while r| doesn't do any seeks.
# r| might be slower but for compressed files we have to go over all the data once anyways
# and I had problems with seeks at this stage. Maybe they are gone now after the bz2 bugfix though.
loadedTarFile = tarfile.open( fileobj = fileObject, mode = 'r|' if streamed else 'r:' )
except tarfile.ReadError as exception:
print( "Archive can't be opened! This might happen for compressed TAR archives, "
"which currently is not supported." )
Expand Down Expand Up @@ -265,7 +270,7 @@ def createIndex( self, fileObject, progressBar = None, pathPrefix = '', streamOf
oldPrintName = self.tarFileName
try:
self.tarFileName = tarInfo.name.lstrip( '/' ) # This is for output of the recursive call
self.createIndex( fileObject, progressBar, fullPath, globalOffset )
self.createIndex( fileObject, progressBar, fullPath, globalOffset if streamed else 0 )

# if the TAR file contents could be read, we need to adjust the actual
# TAR file's metadata to be a directory instead of a file
Expand Down
2 changes: 1 addition & 1 deletion setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@

setup(
name = 'ratarmount',
version = '0.3.3',
version = '0.3.4',

description = 'Random Access Read-Only Tar Mount',
url = 'https://github.com/mxmlnkn/ratarmount',
Expand Down

0 comments on commit a74cd54

Please sign in to comment.