Bucket.download_file_by_name fails when getting bucket with B2Api.get_bucket_by_id

オープン
#112 コメント 4 件 リアクション 0 件 担当者 0 名 GitHub で見る

メンテナーはふだん 1 日以内に返信

まだ誰も着手していません。

評価

難易度
3/5
見積もり時間
半日
初心者へのやさしさ
42/100
issue の種類
バグ
明瞭さ
おおむね明確
活発さ
停滞
技術スタック
python
領域
cloud

調査の方向性

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.

索引モデルが issue の本文から書いたものです。

説明

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?

主要言語
Python
スター
214
フォーク
68
平均マージ
51分
マージ済み PR(30日)
6

環境構築

はじめの一歩

  1. issue を最後まで読み、次にプロジェクトのコントリビューションガイドを読みます。
  2. 着手することを issue にコメントします — 二人が同じ作業をするのを防げます。
  3. リポジトリをフォークし、ブランチを切って変更します。
  4. issue 番号を参照したプルリクエストを送ります。

Backblaze/b2-sdk-python のほかの issue

Backblaze/b2-sdk-python の issue をすべて見る

似ている issue

Python の issue をもっと見る

新しい issue をメールで受け取る

初心者向けの GitHub issue を短くまとめたダイジェスト。