Bucket.download_file_by_name fails when getting bucket with B2Api.get_bucket_by_id

Aberta
#112 4 comentários 0 reações 0 responsáveis Ver no GitHub

Mantenedores costumam responder em até 1 dia

Ninguém assumiu esta issue ainda.

Avaliação

Dificuldade
3/5
Tempo estimado
Meio dia
Facilidade para iniciantes
42/100
Tipo de issue
Bug
Clareza
Razoavelmente clara
Status de atividade
Estagnada
Stack de tecnologia
python
Domínio
cloud

Direção de pesquisa

Start with download_file_by_name() in b2sdk/bucket.py, which assumes self.name is set, and compare it with get_bucket_by_name() to see how a Bucket built by B2Api.get_bucket_by_id() gets its name. Reproduce with the snippet in the issue, then check that a download by name works after fetching the bucket by id. The work is probably already superseded in the current release, so confirm against the latest code before starting.

Escrita pelo modelo de indexação a partir do texto da issue.

Descrição

bug good first issue

After getting a Bucket instance by calling B2Api.get_bucket_by_id(), I'm unable to download files with bucket.download_file_by_name(). A minimal example of the problem:

from b2sdk.v1 import InMemoryAccountInfo, B2Api, DownloadDestLocalFile

app_id = '<app_id>'
app_key = '<app_key>'
bucket_id = '<bucket_id>'
bucket_name = '<bucket_name>'

b2 = B2Api(InMemoryAccountInfo())
b2.authorize_account('production', app_id, app_key)

bucket = b2.get_bucket_by_id(bucket_id)
# bucket = b2.get_bucket_by_name(bucket_name)

dst = DownloadDestLocalFile('local_file_name')
bucket.download_file_by_name('<b2_file_path>', dst)

If the commented line that calls get_bucket_by_name() is used instead, the snippet works as expected.

Tried both v1.0.2 on PyPI and installing directly from master (more specifically 1707190972a5d6807c7d928dd5d295dce6920915).

The problem seems to be that the Bucket class assumes that its name attribute is always set in download_file_by_name() which is not a correct assumption when the bucket is instantiated with B2Api.get_bucket_by_id().

Is this a bug or have I missed something in the documentation?

Linguagem predominante
Python
Estrelas
214
Forks
68
Merge médio
51min
PRs com merge (30d)
6

Preparar o ambiente

Primeiros passos

  1. Leia a issue inteira e depois o guia de contribuição do projeto.
  2. Comente na issue dizendo que vai assumir — evita que duas pessoas façam o mesmo trabalho.
  3. Faça um fork do repositório e trabalhe em uma branch.
  4. Abra um pull request que referencie o número da issue.

Mais de Backblaze/b2-sdk-python

Todas as issues de Backblaze/b2-sdk-python

Issues semelhantes

Mais issues de Python

Receba novas issues na sua caixa de entrada

Um resumo curto de issues do GitHub para quem está começando.