The media library service has a small registry of playlist folders. The save method accepts a mutable buffer of paths and must store an independent copy of the state at the moment it is called. The renameFolder method must rename only a specific folder in already saved snapshots, without affecting external collections and without changing the number of elements.
save(id, folders) saves a snapshot of folders under the id key.mutable.Buffer[String].save for the same id must completely replace the old snapshot with new data.renameFolder(id, from, to):
from after trim,save.folders(id) returns the saved values in storage order.val source = scala.collection.mutable.Buffer("/mix/intro", "/mix/live")
val store = PlaylistFolderStore()
store.save("p1", source)
source += "/mix/bonus"
store.folders("p1").val source2 = scala.collection.mutable.Buffer(" /mix/live ", "/mix/archive")
store.save("p1", source2)
store.renameFolder("p1", "/mix/live", "/mix/live-2024")
store.folders("p1") and the original source2.source, the already saved result for "p1" remains List("/mix/intro", "/mix/live").renameFolder, the result for "p1" is List("/mix/live-2024", "/mix/archive").source2 remains unchanged.3.3.121scala.collection.mutable.Buffer, scala.collection.mutable.Mapfolders may contain strings with surrounding spacesUse line comments to explain the problem, its impact, the fix and how to test it.