From: pablozg Date: Thu, 24 May 2018 19:28:03 +0000 (+0200) Subject: DVR: Erase cutlist files when a recording is removed X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=1098ff8579230ae239eaeb78d432814da19b7806;p=thirdparty%2Ftvheadend.git DVR: Erase cutlist files when a recording is removed --- diff --git a/src/dvr/dvr_cutpoints.c b/src/dvr/dvr_cutpoints.c index 8a12a2214..88154bb30 100644 --- a/src/dvr/dvr_cutpoints.c +++ b/src/dvr/dvr_cutpoints.c @@ -274,3 +274,34 @@ dvr_cutpoint_list_destroy (dvr_cutpoint_list_t *list) } free(list); } + +/* + * Delete cutpoint files + */ +void +dvr_cutpoint_delete_files (const char *s) +{ + char *path, *dot; + int i; + + path = alloca(strlen(s) + 1); + + /* Check each cutlist extension */ + for (i = 0; i < ARRAY_SIZE(dvr_cutpoint_parsers); i++) { + + strcpy(path, s); + if ((dot = (strrchr(path, '.') + 1))) + *dot = 0; + + strcat(path, dvr_cutpoint_parsers[i].ext); + + /* Check file exists */ + if (access(path, F_OK)) + continue; + + /* Delete File */ + tvhinfo(LS_MAIN, "Erasing cutpoint file '%s'", (const char *)path); + if (unlink(path)) + tvherror(LS_MAIN, "unable to remove cutpoint file '%s'", (const char *)path); + } +} diff --git a/src/tvheadend.h b/src/tvheadend.h index 4b09c77e2..27367d234 100644 --- a/src/tvheadend.h +++ b/src/tvheadend.h @@ -378,6 +378,7 @@ void http_deescape(char *str); int mpegts_word_count(const uint8_t *tsb, int len, uint32_t mask); int deferred_unlink(const char *filename, const char *rootdir); +void dvr_cutpoint_delete_files (const char *s); void sha1_calc(uint8_t *dst, const uint8_t *d1, size_t d1_len, const uint8_t *d2, size_t d2_len); diff --git a/src/utils.c b/src/utils.c index 53cf95bc2..ae588bba7 100644 --- a/src/utils.c +++ b/src/utils.c @@ -841,8 +841,10 @@ deferred_unlink(const char *filename, const char *rootdir) free(s); return r; } - if (rootdir == NULL) + if (rootdir == NULL){ + dvr_cutpoint_delete_files (filename); tasklet_arm_alloc(deferred_unlink_cb, s); + } else { du = calloc(1, sizeof(*du)); if (du == NULL) { @@ -851,6 +853,7 @@ deferred_unlink(const char *filename, const char *rootdir) } du->filename = s; du->rootdir = strdup(rootdir); + dvr_cutpoint_delete_files (filename); tasklet_arm_alloc(deferred_unlink_dir_cb, du); } return 0;