Fix CLI storage read (#1305)

* Fix cli storage read
* Github: install with web updater

Co-authored-by: あく <alleteam@gmail.com>
This commit is contained in:
Nikolay Minaylov 2022-06-10 04:28:05 +03:00 committed by GitHub
parent f5ab37ac99
commit 761de00501
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 7 additions and 7 deletions

View File

@ -161,7 +161,7 @@ jobs:
comment-id: ${{ steps.fc.outputs.comment-id }} comment-id: ${{ steps.fc.outputs.comment-id }}
issue-number: ${{ github.event.pull_request.number }} issue-number: ${{ github.event.pull_request.number }}
body: | body: |
[Click here](https://update.flipperzero.one/builds/firmware/${{steps.names.outputs.artifacts-path}}/flipper-z-${{steps.names.outputs.default-target}}-full-${{steps.names.outputs.suffix}}.dfu) for the DFU file to flash the `${{steps.names.outputs.short-hash}}` version of this branch with the [`Install from file` option in qFlipper](https://docs.flipperzero.one/basics/firmware-update). [Install with web updater](https://my.flipp.dev/?url=https://update.flipperzero.one/builds/firmware/${{steps.names.outputs.artifacts-path}}/flipper-z-${{steps.names.outputs.default-target}}-update-${{steps.names.outputs.suffix}}.tgz&channel=${{steps.names.outputs.artifacts-path}}&version=${{steps.names.outputs.short-hash}})
edit-mode: replace edit-mode: replace
compact: compact:

View File

@ -184,14 +184,14 @@ static void storage_cli_read(Cli* cli, string_t path) {
File* file = storage_file_alloc(api); File* file = storage_file_alloc(api);
if(storage_file_open(file, string_get_cstr(path), FSAM_READ, FSOM_OPEN_EXISTING)) { if(storage_file_open(file, string_get_cstr(path), FSAM_READ, FSOM_OPEN_EXISTING)) {
const uint16_t size_to_read = 128; const uint16_t buffer_size = 128;
uint16_t read_size = 0; uint16_t read_size = 0;
uint8_t* data = malloc(read_size); uint8_t* data = malloc(buffer_size);
printf("Size: %lu\r\n", (uint32_t)storage_file_size(file)); printf("Size: %lu\r\n", (uint32_t)storage_file_size(file));
do { do {
read_size = storage_file_read(file, data, size_to_read); read_size = storage_file_read(file, data, buffer_size);
for(uint16_t i = 0; i < read_size; i++) { for(uint16_t i = 0; i < read_size; i++) {
printf("%c", data[i]); printf("%c", data[i]);
} }
@ -449,15 +449,15 @@ static void storage_cli_md5(Cli* cli, string_t path) {
File* file = storage_file_alloc(api); File* file = storage_file_alloc(api);
if(storage_file_open(file, string_get_cstr(path), FSAM_READ, FSOM_OPEN_EXISTING)) { if(storage_file_open(file, string_get_cstr(path), FSAM_READ, FSOM_OPEN_EXISTING)) {
const uint16_t size_to_read = 512; const uint16_t buffer_size = 512;
const uint8_t hash_size = 16; const uint8_t hash_size = 16;
uint8_t* data = malloc(size_to_read); uint8_t* data = malloc(buffer_size);
uint8_t* hash = malloc(sizeof(uint8_t) * hash_size); uint8_t* hash = malloc(sizeof(uint8_t) * hash_size);
md5_context* md5_ctx = malloc(sizeof(md5_context)); md5_context* md5_ctx = malloc(sizeof(md5_context));
md5_starts(md5_ctx); md5_starts(md5_ctx);
while(true) { while(true) {
uint16_t read_size = storage_file_read(file, data, size_to_read); uint16_t read_size = storage_file_read(file, data, buffer_size);
if(read_size == 0) break; if(read_size == 0) break;
md5_update(md5_ctx, data, read_size); md5_update(md5_ctx, data, read_size);
} }