Пример #1
0
    def get_file_key(self, generation_id, filename, key):
        if key not in self.get_allowed_file_keys():
            raise obnamlib.RepositoryFileKeyNotAllowed(
                client_name=generation_id.client_name, format=self.format)

        client = self._lookup_client_by_generation(generation_id)
        return client.get_file_key(generation_id.gen_number, filename, key)
Пример #2
0
 def set_file_key(self, generation_id, filename, key, value):
     client = self._client_list.get_client_by_generation_id(generation_id)
     if key not in self.get_allowed_file_keys():
         raise obnamlib.RepositoryFileKeyNotAllowed(
             format=self.format,
             client_name=client.name,
             key_name=obnamlib.repo_key_name(key))
     client.set_file_key(generation_id, filename, key, value)
Пример #3
0
    def set_file_key(self, generation_id, filename, key, value):
        if key not in self.get_allowed_file_keys():
            raise obnamlib.RepositoryFileKeyNotAllowed(
                client_name=generation_id.client_name,
                key_name=obnamlib.repo_key_name(key),
                format=self.format)

        self._require_got_client_lock(generation_id.client_name)
        client = self._lookup_client_by_generation(generation_id)
        return client.set_file_key(generation_id.gen_number, filename, key,
                                   value)
Пример #4
0
    def set_file_key(self, generation_id, filename, key, value):
        client_name, _ = self._unpack_gen_id(generation_id)
        self._require_client_lock(client_name)

        cache_key = self._get_file_key_cache_key(generation_id, filename)
        if cache_key not in self._file_key_cache:
            self._flush_file_key_cache()
            self._require_existing_file(generation_id, filename)
            self._cache_file_keys_from_storage(generation_id, filename)
        _, metadata = self._file_key_cache[cache_key]

        if key in self._file_keys:
            setattr(metadata, self._file_keys[key], value)
            self._file_key_cache[cache_key] = (True, metadata)
        else:
            raise obnamlib.RepositoryFileKeyNotAllowed(
                format=self.format,
                client_name=client_name,
                key_name=obnamlib.repo_key_name(key))
Пример #5
0
    def get_file_key(self, generation_id, filename, key):
        cache_key = self._get_file_key_cache_key(generation_id, filename)
        if cache_key not in self._file_key_cache:
            self._flush_file_key_cache()
            self._require_existing_file(generation_id, filename)
            self._cache_file_keys_from_storage(generation_id, filename)
        _, metadata = self._file_key_cache[cache_key]

        if key in self._file_keys:
            value = getattr(metadata, self._file_keys[key])
            if key in obnamlib.REPO_FILE_INTEGER_KEYS:
                return value or 0
            else:
                return value or ''
        else:
            client_name, _ = self._unpack_gen_id(generation_id)
            raise obnamlib.RepositoryFileKeyNotAllowed(
                format=self.format,
                client_name=client_name,
                key_name=obnamlib.repo_key_name(key))