Skip to content

Commit

Permalink
[FL-3055] Getter for application data path (flipperdevices#2181)
Browse files Browse the repository at this point in the history
* Threads: application id
* Unit tests: appsdata getter test
* Unit tests: moar test cases for appsdata getter
* Unit tests: remove folders after test
* Storage: dir_is_exist, migrate, + unit_tests
* Plugins: migration
* Storage: common_exists, moar unit_tests 4 "common_migrate", "common_migrate" and "common_merge" bugfixes
* Storage: use FuriString for path handling
* Storage API: send caller thread id with path
* Storage: remove StorageType field in storage file list
* Storage: simplify processing
* Storage API: send caller thread id with path everywhere
* Storage: /app alias, unit tests and path creation
* Storage, path helper: remove unused
* Examples: app data example
* App plugins: use new VFS path
* Storage: file_info_is_dir
* Services: handle alias if the service accepts a path.
* App plugins: fixes
* Make PVS happy
* Storage: fix storage_merge_recursive
* Storage: rename process_aliases to resolve_path. Rename APPS_DATA to APP_DATA.
* Apps: use predefined macro instead of raw paths. Example Apps Data: README fixes.
* Storage: rename storage_common_resolve_path to storage_common_resolve_path_and_ensure_app_directory
* Api: fix version
* Storage: rename alias message
* Storage: do not create app folders in path resolving process in certain cases.

---------

Co-authored-by: Astra <93453568+Astrrra@users.noreply.github.com>
Co-authored-by: Aleksandr Kutuzov <alleteam@gmail.com>
  • Loading branch information
3 people authored and nvx committed Apr 30, 2023
1 parent e5b5c60 commit c18ef0f
Show file tree
Hide file tree
Showing 52 changed files with 870 additions and 576 deletions.
3 changes: 3 additions & 0 deletions .pvsconfig
Original file line number Diff line number Diff line change
Expand Up @@ -44,3 +44,6 @@

# Functions that always return the same error code
//-V:picopass_device_decrypt:1048

# Examples
//V_EXCLUDE_PATH applications/examples/
9 changes: 4 additions & 5 deletions applications/debug/unit_tests/rpc/rpc_test.c
Original file line number Diff line number Diff line change
Expand Up @@ -191,7 +191,7 @@ static void clean_directory(Storage* fs_api, const char* clean_dir) {
size_t size = strlen(clean_dir) + strlen(name) + 1 + 1;
char* fullname = malloc(size);
snprintf(fullname, size, "%s/%s", clean_dir, name);
if(fileinfo.flags & FSF_DIRECTORY) {
if(file_info_is_dir(&fileinfo)) {
clean_directory(fs_api, fullname);
}
FS_Error error = storage_common_remove(fs_api, fullname);
Expand Down Expand Up @@ -608,9 +608,8 @@ static void test_rpc_storage_list_create_expected_list(
}

if(path_contains_only_ascii(name)) {
list->file[i].type = (fileinfo.flags & FSF_DIRECTORY) ?
PB_Storage_File_FileType_DIR :
PB_Storage_File_FileType_FILE;
list->file[i].type = file_info_is_dir(&fileinfo) ? PB_Storage_File_FileType_DIR :
PB_Storage_File_FileType_FILE;
list->file[i].size = fileinfo.size;
list->file[i].data = NULL;
/* memory free inside rpc_encode_and_send() -> pb_release() */
Expand Down Expand Up @@ -873,7 +872,7 @@ static void test_rpc_storage_stat_run(const char* path, uint32_t command_id) {
if(error == FSE_OK) {
response->which_content = PB_Main_storage_stat_response_tag;
response->content.storage_stat_response.has_file = true;
response->content.storage_stat_response.file.type = (fileinfo.flags & FSF_DIRECTORY) ?
response->content.storage_stat_response.file.type = file_info_is_dir(&fileinfo) ?
PB_Storage_File_FileType_DIR :
PB_Storage_File_FileType_FILE;
response->content.storage_stat_response.file.size = fileinfo.size;
Expand Down
8 changes: 4 additions & 4 deletions applications/debug/unit_tests/storage/dirwalk_test.c
Original file line number Diff line number Diff line change
Expand Up @@ -179,7 +179,7 @@ MU_TEST_1(test_dirwalk_full, Storage* storage) {

while(dir_walk_read(dir_walk, path, &fileinfo) == DirWalkOK) {
furi_string_right(path, strlen(EXT_PATH("dirwalk/")));
mu_check(storage_test_paths_mark(paths, path, (fileinfo.flags & FSF_DIRECTORY)));
mu_check(storage_test_paths_mark(paths, path, file_info_is_dir(&fileinfo)));
}

dir_walk_free(dir_walk);
Expand All @@ -204,7 +204,7 @@ MU_TEST_1(test_dirwalk_no_recursive, Storage* storage) {

while(dir_walk_read(dir_walk, path, &fileinfo) == DirWalkOK) {
furi_string_right(path, strlen(EXT_PATH("dirwalk/")));
mu_check(storage_test_paths_mark(paths, path, (fileinfo.flags & FSF_DIRECTORY)));
mu_check(storage_test_paths_mark(paths, path, file_info_is_dir(&fileinfo)));
}

dir_walk_free(dir_walk);
Expand All @@ -219,7 +219,7 @@ static bool test_dirwalk_filter_no_folder_ext(const char* name, FileInfo* filein
UNUSED(ctx);

// only files
if(!(fileinfo->flags & FSF_DIRECTORY)) {
if(!file_info_is_dir(fileinfo)) {
// with ".test" in name
if(strstr(name, ".test") != NULL) {
return true;
Expand All @@ -243,7 +243,7 @@ MU_TEST_1(test_dirwalk_filter, Storage* storage) {

while(dir_walk_read(dir_walk, path, &fileinfo) == DirWalkOK) {
furi_string_right(path, strlen(EXT_PATH("dirwalk/")));
mu_check(storage_test_paths_mark(paths, path, (fileinfo.flags & FSF_DIRECTORY)));
mu_check(storage_test_paths_mark(paths, path, file_info_is_dir(&fileinfo)));
}

dir_walk_free(dir_walk);
Expand Down
Loading

0 comments on commit c18ef0f

Please sign in to comment.