File: 0001-player-create-missing-folders-for-watch-history-path.patch

package info (click to toggle)
mpv 0.40.0-3%2Bdeb13u1
  • links: PTS, VCS
  • area: main
  • in suites: trixie-proposed-updates
  • size: 12,540 kB
  • sloc: ansic: 152,062; python: 1,228; sh: 646; javascript: 612; cpp: 461; objc: 302; pascal: 49; xml: 29; makefile: 19
file content (27 lines) | stat: -rw-r--r-- 1,006 bytes parent folder | download | duplicates (2)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
From: sfan5 <sfan5@live.de>
Date: Sun, 1 Jun 2025 17:36:44 +0200
Subject: player: create missing folders for watch-history-path

fixes: #16357
---
 player/loadfile.c | 6 +++++-
 1 file changed, 5 insertions(+), 1 deletion(-)

diff --git a/player/loadfile.c b/player/loadfile.c
index b6b71fd..96c0fc4 100644
--- a/player/loadfile.c
+++ b/player/loadfile.c
@@ -1546,8 +1546,12 @@ static void append_to_watch_history(struct MPContext *mpctx)
     void *ctx = talloc_new(NULL);
     char *history_path = mp_get_user_path(ctx, mpctx->global,
                                           mpctx->opts->watch_history_path);
-    FILE *history_file = fopen(history_path, "ab");
+    char *history_path_dir = bstrto0(ctx, mp_dirname(history_path));
+    if (!mp_path_exists(history_path_dir)) {
+        mp_mkdirp(history_path_dir);
+    }
 
+    FILE *history_file = fopen(history_path, "ab");
     if (!history_file) {
         MP_ERR(mpctx, "Failed to open history file: %s\n",
                mp_strerror(errno));