|
6 | 6 | #include "../../types/token_info.h"
|
7 | 7 | #include "migrations/config_migration_v1_to_v2.h"
|
8 | 8 |
|
9 |
| -#define CONFIG_FILE_DIRECTORY_PATH "/ext/apps/Misc" |
| 9 | +#define CONFIG_FILE_DIRECTORY_PATH EXT_PATH("authenticator") |
10 | 10 | #define CONFIG_FILE_PATH CONFIG_FILE_DIRECTORY_PATH "/totp.conf"
|
11 | 11 | #define CONFIG_FILE_BACKUP_PATH CONFIG_FILE_PATH ".backup"
|
| 12 | +#define CONFIG_FILE_PATH_PREVIOUS EXT_PATH("apps/Misc") "/totp.conf" |
12 | 13 |
|
13 | 14 | static char* token_info_get_algo_as_cstr(const TokenInfo* token_info) {
|
14 | 15 | switch(token_info->algo) {
|
@@ -53,6 +54,24 @@ FlipperFormat* totp_open_config_file(Storage* storage) {
|
53 | 54 | totp_close_config_file(fff_data_file);
|
54 | 55 | return NULL;
|
55 | 56 | }
|
| 57 | + } else if(storage_common_stat(storage, CONFIG_FILE_PATH_PREVIOUS, NULL) == FSE_OK) { |
| 58 | + FURI_LOG_D(LOGGING_TAG, "Old config file %s found", CONFIG_FILE_PATH_PREVIOUS); |
| 59 | + if(storage_common_stat(storage, CONFIG_FILE_DIRECTORY_PATH, NULL) == FSE_NOT_EXIST) { |
| 60 | + FURI_LOG_D( |
| 61 | + LOGGING_TAG, |
| 62 | + "Directory %s doesn't exist. Will create new.", |
| 63 | + CONFIG_FILE_DIRECTORY_PATH); |
| 64 | + if(!storage_simply_mkdir(storage, CONFIG_FILE_DIRECTORY_PATH)) { |
| 65 | + FURI_LOG_E(LOGGING_TAG, "Error creating directory %s", CONFIG_FILE_DIRECTORY_PATH); |
| 66 | + return NULL; |
| 67 | + } |
| 68 | + } |
| 69 | + if(storage_common_rename(storage, CONFIG_FILE_PATH_PREVIOUS, CONFIG_FILE_PATH) != FSE_OK) { |
| 70 | + FURI_LOG_E(LOGGING_TAG, "Error moving config to %s", CONFIG_FILE_PATH); |
| 71 | + return NULL; |
| 72 | + } |
| 73 | + FURI_LOG_I(LOGGING_TAG, "Applied config file path migration"); |
| 74 | + return totp_open_config_file(storage); |
56 | 75 | } else {
|
57 | 76 | FURI_LOG_D(LOGGING_TAG, "Config file %s is not found. Will create new.", CONFIG_FILE_PATH);
|
58 | 77 | if(storage_common_stat(storage, CONFIG_FILE_DIRECTORY_PATH, NULL) == FSE_NOT_EXIST) {
|
|
0 commit comments