]> git.ipfire.org Git - thirdparty/tvheadend.git/commitdiff
DVR: Erase cutlist files when a recording is removed
authorpablozg <pablozg@gmail.com>
Thu, 24 May 2018 19:28:03 +0000 (21:28 +0200)
committerperexg <perex@perex.cz>
Thu, 7 Jun 2018 16:15:04 +0000 (18:15 +0200)
src/dvr/dvr_cutpoints.c
src/tvheadend.h
src/utils.c

index 8a12a221449eff408397f1f11cc2a1f6435485d4..88154bb303cd4b526c5bbac301cf0e6ece436ca9 100644 (file)
@@ -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);
+  }
+}
index 4b09c77e23d624f7d49c626df42e034c1c436700..27367d2346436bd8491298dda2839910bcd01d59 100644 (file)
@@ -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);
 
index 53cf95bc2bd01423fcf32d655ea21af4c27910d3..ae588bba791985d1b18434e246b91b553e953ae9 100644 (file)
@@ -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;