How to use the ratarmount.SQLiteIndexedTar.FileInfo function in ratarmount

To help you get started, we’ve selected a few ratarmount examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github mxmlnkn / ratarmount / ratarmount.py View on Github external
except:
            pass

        self.mountSources = [ self._openTar( tarFile, clearIndexCache, recursive, gzipSeekPointSpacing )
                              if not os.path.isdir( tarFile ) else os.path.realpath( tarFile )
                              for tarFile in pathToMount ]

        # make the mount point read only and executable if readable, i.e., allow directory listing
        tarStats = os.stat( pathToMount[0] )
        # clear higher bits like S_IFREG and set the directory bit instead
        mountMode = ( tarStats.st_mode & 0o777 ) | stat.S_IFDIR
        if mountMode & stat.S_IRUSR != 0: mountMode |= stat.S_IXUSR
        if mountMode & stat.S_IRGRP != 0: mountMode |= stat.S_IXGRP
        if mountMode & stat.S_IROTH != 0: mountMode |= stat.S_IXOTH

        self.rootFileInfo = SQLiteIndexedTar.FileInfo(
            offset       = None             ,
            offsetheader = None             ,
            size         = tarStats.st_size ,
            mtime        = tarStats.st_mtime,
            mode         = mountMode        ,
            type         = tarfile.DIRTYPE  ,
            linkname     = ""               ,
            uid          = tarStats.st_uid  ,
            gid          = tarStats.st_gid  ,
            istar        = True             ,
            issparse     = False
        )

        # Create mount point if it does not exist
        self.mountPointWasCreated = False
        if mountPoint and not os.path.exists( mountPoint ):
github mxmlnkn / ratarmount / ratarmount.py View on Github external
"""Wrapper for _getUnionMountFileInfo, which also resolves special file version specifications in the path."""
        result = self._getUnionMountFileInfo( filePath )
        if result:
            return result

        # If no file was found, check if a special .versions folder to an existing file/folder was queried.
        result = self._decodeVersionsPathAPI( filePath )
        if not result:
            raise fuse.FuseOSError( fuse.errno.ENOENT )
        filePath, pathIsVersions, fileVersion = result

        # 2.) Check if the request was for the special .versions folder and return its contents or stats
        # At this point, filePath is assured to actually exist!
        if pathIsVersions:
            parentFileInfo, mountSource = self._getUnionMountFileInfo( filePath )
            return SQLiteIndexedTar.FileInfo(
                offset       = None                ,
                offsetheader = None                ,
                size         = 0                   ,
                mtime        = parentFileInfo.mtime,
                mode         = 0o777 | stat.S_IFDIR,
                type         = tarfile.DIRTYPE     ,
                linkname     = ""                  ,
                uid          = parentFileInfo.uid  ,
                gid          = parentFileInfo.gid  ,
                istar        = False               ,
                issparse     = False
            ), mountSource

        # 3.) At this point the request is for an actual version of a file or folder
        result = self._getUnionMountFileInfo( filePath, fileVersion = fileVersion )
        if result:
github mxmlnkn / ratarmount / ratarmount.py View on Github external
return None

        # fileVersion >= 1
        for mountSource in self.mountSources:
            if isinstance( mountSource, str ):
                realFilePath = os.path.join( mountSource, filePath.lstrip( os.path.sep ) )
                if os.path.lexists( realFilePath ):
                    if fileVersion == 1:
                        return self._getFileInfoFromRealFile( realFilePath ), \
                               os.path.join( mountSource, filePath.lstrip( os.path.sep ) )
                    fileVersion -= 1

            else:
                fileInfo = mountSource.getFileInfo( filePath, listDir = False, fileVersion = fileVersion )
                if isinstance( fileInfo, SQLiteIndexedTar.FileInfo ):
                    return fileInfo, mountSource
                fileVersion -= len( mountSource.getFileInfo( filePath, listVersions = True ) )

            if fileVersion < 1:
                return None

        return None