Example #1
0
	def _set_cache_(self, attr):
		if attr == "_packfile_checksum":
			self._packfile_checksum = self._data[-40:-20]
		elif attr == "_packfile_checksum":
			self._packfile_checksum = self._data[-20:]
		elif attr == "_data":
			# Note: We don't lock the file when reading as we cannot be sure
			# that we can actually write to the location - it could be a read-only
			# alternate for instance
			self._data = file_contents_ro_filepath(self._indexpath)
		else:
			# now its time to initialize everything - if we are here, someone wants
			# to access the fanout table or related properties
			
			# CHECK VERSION
			self._version = (self._data[:4] == '\377tOc' and 2) or 1
			if self._version == 2:
				version_id = unpack_from(">L", self._data, 4)[0] 
				assert version_id == self._version, "Unsupported index version: %i" % version_id
			# END assert version
			
			# SETUP FUNCTIONS
			# setup our functions according to the actual version
			for fname in ('entry', 'offset', 'sha', 'crc'):
				setattr(self, fname, getattr(self, "_%s_v%i" % (fname, self._version)))
			# END for each function to initialize
			
			
			# INITIALIZE DATA
			# byte offset is 8 if version is 2, 0 otherwise
			self._initialize()
Example #2
0
    def _set_cache_(self, attr):
        if attr == "_packfile_checksum":
            self._packfile_checksum = self._data[-40:-20]
        elif attr == "_packfile_checksum":
            self._packfile_checksum = self._data[-20:]
        elif attr == "_data":
            # Note: We don't lock the file when reading as we cannot be sure
            # that we can actually write to the location - it could be a read-only
            # alternate for instance
            self._data = file_contents_ro_filepath(self._indexpath)
        else:
            # now its time to initialize everything - if we are here, someone wants
            # to access the fanout table or related properties

            # CHECK VERSION
            self._version = (self._data[:4] == '\377tOc' and 2) or 1
            if self._version == 2:
                version_id = unpack_from(">L", self._data, 4)[0]
                assert version_id == self._version, "Unsupported index version: %i" % version_id
            # END assert version

            # SETUP FUNCTIONS
            # setup our functions according to the actual version
            for fname in ('entry', 'offset', 'sha', 'crc'):
                setattr(self, fname,
                        getattr(self, "_%s_v%i" % (fname, self._version)))
            # END for each function to initialize

            # INITIALIZE DATA
            # byte offset is 8 if version is 2, 0 otherwise
            self._initialize()
Example #3
0
	def _set_cache_(self, attr):
		if attr == '_data':
			self._data = file_contents_ro_filepath(self._packpath)
			
			# read the header information
			type_id, self._version, self._size = unpack_from(">4sLL", self._data, 0)
			
			# TODO: figure out whether we should better keep the lock, or maybe
			# add a .keep file instead ?
		else: # must be '_size' or '_version'
			# read header info - we do that just with a file stream
			type_id, self._version, self._size = unpack(">4sLL", open(self._packpath).read(12))
Example #4
0
    def _set_cache_(self, attr):
        if attr == '_data':
            self._data = file_contents_ro_filepath(self._packpath)

            # read the header information
            type_id, self._version, self._size = unpack_from(
                ">4sLL", self._data, 0)

            # TODO: figure out whether we should better keep the lock, or maybe
            # add a .keep file instead ?
        else:  # must be '_size' or '_version'
            # read header info - we do that just with a file stream
            type_id, self._version, self._size = unpack(
                ">4sLL",
                open(self._packpath).read(12))