Skip to content

Commit

Permalink
[fix] SQLiteIndexedTar: Also call close on deletion
Browse files Browse the repository at this point in the history
This avoids the error when running rapidgzip threads are detected.
And, in the case of fsspec.open, the context manager cannot be
reasonably used for SQLiteIndexedTar.
  • Loading branch information
mxmlnkn committed Oct 13, 2024
1 parent 05cbd66 commit 4d63b2c
Showing 1 changed file with 12 additions and 5 deletions.
17 changes: 12 additions & 5 deletions core/ratarmountcore/SQLiteIndexedTar.py
Original file line number Diff line number Diff line change
Expand Up @@ -890,15 +890,22 @@ def _detectGnuIncremental(self, fileObject: Any) -> bool:

return False

def close(self):
if hasattr(self, "tarFileObject") and self.tarFileObject:
self.tarFileObject.close()

if getattr(self, "isFileObject", False) and hasattr(self, "rawFileObject") and self.rawFileObject:
self.rawFileObject.close()

@overrides(MountSource)
def __exit__(self, exception_type, exception_value, exception_traceback):
self.close()
super().__exit__(exception_type, exception_value, exception_traceback)

if self.tarFileObject:
self.tarFileObject.close()

if not self.isFileObject and self.rawFileObject:
self.rawFileObject.close()
def __del__(self):
self.close()
if hasattr(super(), '__del__'):
super().__del__()

def _getArchivePath(self) -> Optional[str]:
return None if self.tarFileName == '<file object>' else self.tarFileName
Expand Down

0 comments on commit 4d63b2c

Please sign in to comment.