From: Jaroslav Kysela Date: Mon, 14 Sep 2015 18:51:58 +0000 (+0200) Subject: DVR: another autorec directory name improvements, fixes #3037 X-Git-Tag: v4.2.1~2125 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=e4aa0911cd79659550e22425d12e1f61e16f9403;p=thirdparty%2Ftvheadend.git DVR: another autorec directory name improvements, fixes #3037 The previous patch does not take care about possible substitutions from the explicit autorec directory. To keep all functionality, the substitutions are now handled only when prefix '$$' is in the autorec directory specification. --- diff --git a/src/dvr/dvr_rec.c b/src/dvr/dvr_rec.c index f9711041a..027c2db26 100644 --- a/src/dvr/dvr_rec.c +++ b/src/dvr/dvr_rec.c @@ -545,6 +545,7 @@ pvr_generate_filename(dvr_entry_t *de, const streaming_start_t *ss) htsmsg_t *m; size_t l, j; long max; + int dir_dosubs; if (de == NULL) return -1; @@ -553,6 +554,10 @@ pvr_generate_filename(dvr_entry_t *de, const streaming_start_t *ss) if (cfg->dvr_storage == NULL || *(cfg->dvr_storage) == '\0') return -1; + dir_dosubs = de->de_directory == NULL || + (de->de_directory[0] == '$' && + de->de_directory[1] == '$'); + localtime_r(&de->de_start, &tm); strncpy(path, cfg->dvr_storage, sizeof(path)); @@ -585,7 +590,12 @@ pvr_generate_filename(dvr_entry_t *de, const streaming_start_t *ss) strcpy(filename, dirsep + 1); else strcpy(filename, path + l); - htsstr_substitute(de->de_directory, ptmp, sizeof(ptmp), '$', dvr_subs_entry, de); + if (dir_dosubs) { + htsstr_substitute(de->de_directory+2, ptmp, sizeof(ptmp), '$', dvr_subs_entry, de); + } else { + strncpy(ptmp, de->de_directory, sizeof(ptmp)-1); + ptmp[sizeof(ptmp)-1] = '\0'; + } s = ptmp; while (*s == '/') s++; @@ -613,7 +623,7 @@ pvr_generate_filename(dvr_entry_t *de, const streaming_start_t *ss) break; *(dirsep - 1) = '\0'; if (*x) { - s = cleanup_filename(cfg, x, de->de_directory == NULL); + s = cleanup_filename(cfg, x, dir_dosubs); tvh_strlcatf(filename, sizeof(filename), j, "%s/", s); free(s); }