b2 upload-file --sha1 <hash> gives no error when receives wrong hash.

未关闭
#478 11 条评论 0 个 reaction 已指派 0 人 在 GitHub 查看

维护者通常 1 天内回复

还没有人认领这个 Issue。

评估

难度
3/5
预计耗时
1-2 天
新手友好度
25/100
Issue 类型
缺陷
描述清晰度
基本清楚
活跃度
停滞
技术栈
python
领域
cli

调研方向

Start with the b2 upload-file command and its --sha1 option, and compare the behaviour in the issue with the help text quoted there. The open question is whether the tool should compare the supplied hash with the one the server computes, or only document that it skips computing it. Done means a decision on that question, and then either a clear error on mismatch or a clarified help string. Confirm the decision with the maintainers first, since the thread has been silent for about seven years.

由索引模型根据 Issue 内容生成。

描述

bug help wanted

I'm trying to automate some single-file backup tasks, and I've found that while the web API apparently works, I don't know how much I can trust the b2 CLI.

When I call the function with the correct SHA1 as argument:

b2 upload-file --sha1 f871a33490af899cf5476c002c513d1bc4e537b9 futuroapiteste test_file.txt test_file_b2_cli.txt
test_file.txt: 100%|██████████████████████████████████████████████████████████| 5.52k/5.52k [00:01<00:00, 5.42kB/s]
URL by file name: https://f002.backblazeb2.com/file/futuroapiteste/test_file_b2_cli.txt
URL by fileId: https://f002.backblazeb2.com/b2api/v1/b2_download_file_by_id?fileId=4_zeee396220d1bff11694a0a1d_f107a92e113ff0c11_d20180731_m193133_c002_v0001095_t0024
{
"action": "upload",
"fileId": "4_zeee396220d1bff11694a0a1d_f107a92e113ff0c11_d20180731_m193133_c002_v0001095_t0024",
"fileName": "arquivo_teste_b2_cli.txt",
"size": 5520,
"uploadTimestamp": 1533065493000
}

======================================================

When I call the function with the wrong SHA1 as argument:

b2 upload-file --sha1 1111111111111111111111111111111111111111 futuroapiteste test_file.txt test_file_b2_cli_wrong_sha1.txt
test_file.txt: 100%|██████████████████████████████████████████████████████████| 5.52k/5.52k [00:00<00:00, 6.10kB/s]
URL by file name: https://f002.backblazeb2.com/file/futuroapiteste/test_file_b2_cli_wrong_sha1.txt
URL by fileId: https://f002.backblazeb2.com/b2api/v1/b2_download_file_by_id?fileId=4_zeee396220d1bff11694a0a1d_f116da3bb244871bc_d20180731_m193245_c002_v0001094_t0044
{
"action": "upload",
"fileId": "4_zeee396220d1bff11694a0a1d_f116da3bb244871bc_d20180731_m193245_c002_v0001094_t0044",
"fileName": "arquivo_teste_b2_cli_wrong_sha1.txt",
"size": 5520,
"uploadTimestamp": 1533065565000
}

=======================================================
Using:
b2 command line tool, version 1.3.0

When I use b2 list-file-names, it shows me that b2 has the correct SHA1 for both files, which shows that the upload happened well, but then -
Did it check the hash I submitted?
If yes, why there was no error?
(Maybe it recalculated the hash anyway before submitting...?)
(Does b2 upload-file already compare the locally created hash with the hash b2 calculates and returns when the file gets there...? )

The built-in CLI help states:

"By default, upload_file will compute the sha1 checksum of the file
to be uploaded. But, if you already have it, you can provide it
on the command line to save a little time."

Which seems to suggest it does, but it doesn't explicitly say it compares, just 'computes', and the behavior would suggest otherwise.

主要语言
Python
星标
638
派生
138
平均合并
8 小时 27 分钟
30 天内合并 PR
8

环境准备

  • 没有 Dockerfile 或 Docker Compose 文件
  • 没有 Pull Request 模板
  • 阅读贡献指南

从这里开始

  1. 先读完整个 Issue,再读项目的贡献指南。
  2. 在 Issue 下留言说明你要接手 —— 这能避免两个人做同样的事。
  3. Fork 仓库,在一个分支上完成修改。
  4. 提交 Pull Request,并在描述里引用这个 Issue 编号。

Backblaze/B2_Command_Line_Tool 的其他 Issue

查看 Backblaze/B2_Command_Line_Tool 的全部 Issue

相似的 Issue

更多 Python Issue

把新 issue 发到你的邮箱

精选适合新手参与的 GitHub issue 摘要。