From 04a796fd15f582e38c0216f45a22c572b365457a Mon Sep 17 00:00:00 2001 From: Christian Soffke Date: Tue, 8 Oct 2024 22:44:21 +0200 Subject: playlist: create_control_unlocked: back up current playlist When creating a new control file for the current playlist, the existing file will now be renamed to serve as a backup, until the next time the control file is replaced again, allowing you to restore the previous state of the playlist, in case you accidentally cleared it. This also means that an entirely new file is created each time, instead of truncating the existing one. Change-Id: I2fd96eb8c3940b85df807fd7646dc0359a036351 --- apps/playlist.c | 3 +++ 1 file changed, 3 insertions(+) (limited to 'apps/playlist.c') diff --git a/apps/playlist.c b/apps/playlist.c index 23d3355708..f1edfe7323 100644 --- a/apps/playlist.c +++ b/apps/playlist.c @@ -367,6 +367,9 @@ static int convert_m3u_name(char* buf, int buf_len, int buf_max, char* temp) */ static void create_control_unlocked(struct playlist_info* playlist) { + if (playlist == ¤t_playlist && file_exists(PLAYLIST_CONTROL_FILE)) + rename(PLAYLIST_CONTROL_FILE, PLAYLIST_CONTROL_FILE".old"); + playlist->control_fd = open(playlist->control_filename, O_CREAT|O_RDWR|O_TRUNC, 0666); -- cgit v1.2.3