aboutsummaryrefslogtreecommitdiff
path: root/src/rss.c
diff options
context:
space:
mode:
authordec05eba <dec05eba@protonmail.com>2020-07-31 22:30:16 +0200
committerdec05eba <dec05eba@protonmail.com>2020-07-31 22:30:16 +0200
commit14d0e432238f058d7bc854e5051ee2bcec6e2b62 (patch)
treed7feebbba860970fcf2cc6fb9a65fe13923e7c1f /src/rss.c
parent4b8b6cce11623d208c03595a241d9af21fba04ba (diff)
Fix add html/rss not working if previous add failed and .in_progress still exists
Diffstat (limited to 'src/rss.c')
-rw-r--r--src/rss.c13
1 files changed, 9 insertions, 4 deletions
diff --git a/src/rss.c b/src/rss.c
index 0f3aafd..c71c1ce 100644
--- a/src/rss.c
+++ b/src/rss.c
@@ -299,6 +299,8 @@ static int get_rss_url_from_episode_info(const char *episode_name, EpisodeInfo *
return 0;
}
+/* TODO: Fix the remove() calls. They wont work since they are not recursive and the directories has files in them */
+/* Same for add_html */
int add_rss(const char *name, const char *url, char *rss_config_dir, const char *start_after) {
int result = 0;
@@ -364,7 +366,11 @@ int add_rss(const char *name, const char *url, char *rss_config_dir, const char
strcat(rss_tracked_dir, "/tracked/");
strcat(rss_tracked_dir, name);
- if(file_exists(rss_tracked_dir) == 0) {
+ char in_progress_filepath[PATH_MAX];
+ strcpy(in_progress_filepath, rss_tracked_dir);
+ strcat(in_progress_filepath, "/.in_progress");
+
+ if(file_exists(rss_tracked_dir) == 0 && file_exists(in_progress_filepath) != 0) {
fprintf(stderr, "You are already tracking %s\n", url);
result = -1;
goto cleanup;
@@ -380,12 +386,11 @@ int add_rss(const char *name, const char *url, char *rss_config_dir, const char
Create an ".in_progress" file to prevent periodic sync from reading rss data
before we have finished adding all the data.
*/
- char in_progress_filepath[PATH_MAX];
- strcpy(in_progress_filepath, rss_tracked_dir);
- strcat(in_progress_filepath, "/.in_progress");
+ remove(in_progress_filepath);
result = create_lock_file(in_progress_filepath);
if(result != 0) {
fprintf(stderr, "Failed to create %s/.in_progress\n", rss_tracked_dir);
+ remove(rss_tracked_dir);
goto cleanup;
}