]> git.ipfire.org Git - thirdparty/tvheadend.git/commitdiff
dvr_storage: Also support server configurations for recordings
authorOlliver Schinagl <oliver@schinagl.nl>
Fri, 16 Jun 2023 15:02:19 +0000 (17:02 +0200)
committerFlole998 <Flole998@users.noreply.github.com>
Wed, 21 Jun 2023 09:17:24 +0000 (11:17 +0200)
Like in commit e15c1abe9737 ("config: Support server configurations"),
dvr_recordings are probably best stored in a 'server known
configuration', as otherwise they can end up in `/Videos`. While the
user can always configure this nicely, having a server sensible default
is good.

Signed-off-by: Olliver Schinagl <oliver@schinagl.nl>
src/dvr/dvr_config.c

index 88f4e96864f10d413aa66ae2ae1deca21f558852..eb0292c0d8eaf515bc247f90e5659adaf8413a57 100644 (file)
@@ -277,8 +277,10 @@ dvr_config_destroy(dvr_config_t *cfg, int delconf)
 static void
 dvr_config_storage_check(dvr_config_t *cfg)
 {
+  char recordings_dir[] = "/var/lib/tvheadend/recordings";
   char home_dir[PATH_MAX + sizeof("/Videos")];
   char dvr_dir[PATH_MAX];
+  uid_t uid = getuid();
   char *xdg_dir;
   struct stat st;
 
@@ -304,7 +306,9 @@ dvr_config_storage_check(dvr_config_t *cfg)
     free(xdg_dir);
   }
 
-  if((stat(dvr_dir, &st) == 0) && S_ISDIR(st.st_mode))
+  if ((stat(recordings_dir, &st) == 0) && (st.st_uid == uid))
+    cfg->dvr_storage = strndup(recordings_dir, sizeof(recordings_dir));
+  else if((stat(dvr_dir, &st) == 0) && S_ISDIR(st.st_mode))
       cfg->dvr_storage = strndup(dvr_dir, PATH_MAX);
   else if(stat(home_dir, &st) == 0 && S_ISDIR(st.st_mode))
       cfg->dvr_storage = strndup(home_dir, sizeof(home_dir));