1
0
Fork 0
forked from len0rd/rockbox

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
This commit is contained in:
Christian Soffke 2024-10-08 22:44:21 +02:00
parent 7592d2ca5e
commit 04a796fd15

View file

@ -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) static void create_control_unlocked(struct playlist_info* playlist)
{ {
if (playlist == &current_playlist && file_exists(PLAYLIST_CONTROL_FILE))
rename(PLAYLIST_CONTROL_FILE, PLAYLIST_CONTROL_FILE".old");
playlist->control_fd = open(playlist->control_filename, playlist->control_fd = open(playlist->control_filename,
O_CREAT|O_RDWR|O_TRUNC, 0666); O_CREAT|O_RDWR|O_TRUNC, 0666);