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

Aperta
#478 11 commenti 0 reazioni 0 assegnatari Vedi su GitHub

I maintainer di solito rispondono entro 1 giorno

Nessuno ha ancora preso questa issue.

Valutazione

Difficoltà
3/5
Tempo stimato
1-2 giorni
Idoneità per principianti
25/100
Tipo di issue
Bug
Chiarezza
Abbastanza chiara
Stato di attività
Ferma
Stack tecnologico
python
Ambito
cli

Direzione di ricerca

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.

Scritto dal modello di indicizzazione a partire dal testo della issue.

Descrizione

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.

Lingua principale
Python
Stelle
638
Fork
138
Merge medio
8h 27m
PR unite (30g)
8

Preparare l'ambiente

Come iniziare

  1. Leggi tutta la issue e poi la guida ai contributi del progetto.
  2. Commenta sulla issue per dire che te ne occupi tu — evita che due persone facciano lo stesso lavoro.
  3. Fai un fork del repository e lavora su un branch.
  4. Apri una pull request che faccia riferimento al numero della issue.

Altre issue di Backblaze/B2_Command_Line_Tool

Tutte le issue di Backblaze/B2_Command_Line_Tool

Issue simili

Altre issue su Python

Ricevi le nuove issue nella tua casella

Un breve riepilogo di issue GitHub adatte ai principianti.