Skip to content

Commit

Permalink
[fix] SQLiteIndex: Do not fall back to libarchive when the specified …
Browse files Browse the repository at this point in the history
…index cannot be read or written
  • Loading branch information
mxmlnkn committed Oct 19, 2024
1 parent 7696280 commit f0f6b4a
Showing 1 changed file with 13 additions and 4 deletions.
17 changes: 13 additions & 4 deletions core/ratarmountcore/SQLiteIndex.py
Original file line number Diff line number Diff line change
Expand Up @@ -250,17 +250,26 @@ def getPossibleIndexFilePaths(
archiveFilePath: Optional[str] = None,
ignoreCurrentFolder: bool = False,
) -> List[str]:
if indexFilePath == ':memory:':
return []

# Prior versions did simply return indexFilePath as the only possible path if it was specified.
# This worked well enough because if the path did not exist, it would simply be created.
# However, for non-writable locations, or if parent folders are missing, or for remote URLs,
# this will fail badly and result in TAR files being opened with the fallback, libarchive, instead,
# which is unwanted behavior. It should fall back to another index storage location instead.
possibleIndexFilePaths = []
if indexFilePath:
return [] if indexFilePath == ':memory:' else [os.path.abspath(os.path.expanduser(indexFilePath))]
possibleIndexFilePaths.append(os.path.abspath(os.path.expanduser(indexFilePath)))

if not archiveFilePath:
return []
return possibleIndexFilePaths

defaultIndexFilePath = archiveFilePath + ".index.sqlite"
if not indexFolders:
return [defaultIndexFilePath, ':memory:']
possibleIndexFilePaths.extend([defaultIndexFilePath, ':memory:'])
return possibleIndexFilePaths

possibleIndexFilePaths = []
indexPathAsName = defaultIndexFilePath.replace("/", "_")
for folder in indexFolders:
if folder:
Expand Down

0 comments on commit f0f6b4a

Please sign in to comment.