PlaylistFile: use TruncateFile()
As a side effect, "playlistclear" no longer creates a new playlist if the given one doesn't yet exist.
This commit is contained in:
parent
2bca3cd247
commit
b6b8fb7d73
@ -302,11 +302,15 @@ spl_clear(const char *utf8path)
|
|||||||
const auto path_fs = spl_map_to_fs(utf8path);
|
const auto path_fs = spl_map_to_fs(utf8path);
|
||||||
assert(!path_fs.IsNull());
|
assert(!path_fs.IsNull());
|
||||||
|
|
||||||
FILE *file = FOpen(path_fs, FOpenMode::WriteText);
|
try {
|
||||||
if (file == nullptr)
|
TruncateFile(path_fs);
|
||||||
ThrowPlaylistErrno();
|
} catch (const std::system_error &e) {
|
||||||
|
if (IsFileNotFound(e))
|
||||||
fclose(file);
|
throw PlaylistError(PlaylistResult::NO_SUCH_LIST,
|
||||||
|
"No such playlist");
|
||||||
|
else
|
||||||
|
throw;
|
||||||
|
}
|
||||||
|
|
||||||
idle_add(IDLE_STORED_PLAYLIST);
|
idle_add(IDLE_STORED_PLAYLIST);
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user