Skip to content

Commit

Permalink
Make sure the path for repo.ini always exist
Browse files Browse the repository at this point in the history
If the path for the repo.ini file doesn't exist, create it.

Closes #1329

Signed-off-by: Castulo Martinez <[email protected]>
  • Loading branch information
castulo authored and Otavio Pontes committed Feb 27, 2020
1 parent 782edf6 commit ca0b6b9
Showing 1 changed file with 6 additions and 2 deletions.
8 changes: 6 additions & 2 deletions src/3rd_party_repos.c
Original file line number Diff line number Diff line change
Expand Up @@ -124,6 +124,7 @@ int third_party_add_repo(const char *repo_name, const char *repo_url)
{
int ret = 0;
struct list *repos;
char *repo_config_file = NULL;
char *repo_config_file_path = NULL;
FILE *fp = NULL;

Expand All @@ -140,8 +141,10 @@ int third_party_add_repo(const char *repo_name, const char *repo_url)
}

// If we are here, we are cleared to write to file
repo_config_file_path = get_repo_config_path();
fp = fopen(repo_config_file_path, "a");
repo_config_file = get_repo_config_path();
repo_config_file_path = sys_dirname(repo_config_file);
mkdir_p(repo_config_file_path);
fp = fopen(repo_config_file, "a");
if (!fp) {
ret = -errno;
}
Expand All @@ -160,6 +163,7 @@ int third_party_add_repo(const char *repo_name, const char *repo_url)
fclose(fp);
}

free(repo_config_file);
free(repo_config_file_path);
list_free_list_and_data(repos, repo_free_data);
return ret;
Expand Down

0 comments on commit ca0b6b9

Please sign in to comment.