From 6a365b258ac77d7e4759e0ae14ccc9e882c4c86f Mon Sep 17 00:00:00 2001 From: Dudemanguy Date: Fri, 7 Jul 2023 11:09:36 -0500 Subject: player: delete watch_later file after successful load Currently, mpv immediately deletes the watch_later file after an attempt at playing the file is made. This is not really ideal because the file may fail to load for a variety of reasons (including not even existing), but the state is cleared anyway unconditionally. Instead, just wait until after playback is successfully initialized before deleting it. This way silly mistakes like forgetting to mount the drive doesn't result in deleting your watch_later data. Fixes #3427. --- player/configfiles.c | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) (limited to 'player/configfiles.c') diff --git a/player/configfiles.c b/player/configfiles.c index f98495d1ac..d3df836eea 100644 --- a/player/configfiles.c +++ b/player/configfiles.c @@ -396,17 +396,18 @@ void mp_delete_watch_later_conf(struct MPContext *mpctx, const char *file) talloc_free(fname); } -void mp_load_playback_resume(struct MPContext *mpctx, const char *file) +bool mp_load_playback_resume(struct MPContext *mpctx, const char *file) { + bool resume = false; if (!mpctx->opts->position_resume) - return; + return resume; char *fname = mp_get_playback_resume_config_filename(mpctx, file); if (fname && mp_path_exists(fname)) { if (mpctx->opts->position_check_mtime && !mp_is_url(bstr0(file)) && !check_mtime(file, fname)) { talloc_free(fname); - return; + return resume; } // Never apply the saved start position to following files @@ -414,9 +415,10 @@ void mp_load_playback_resume(struct MPContext *mpctx, const char *file) MP_INFO(mpctx, "Resuming playback. This behavior can " "be disabled with --no-resume-playback.\n"); try_load_config(mpctx, fname, M_SETOPT_PRESERVE_CMDLINE, MSGL_V); - unlink(fname); + resume = true; } talloc_free(fname); + return resume; } // Returns the first file that has a resume config. -- cgit v1.2.3