MCPcopy Create free account
hub / github.com/Moosync/Moosync / create_playlist

Method create_playlist

src-tauri/database/src/database.rs:159–187  ·  view source on GitHub ↗
(&self, mut playlist: QueryablePlaylist)

Source from the content-addressed store, hash-verified

157
158 #[tracing::instrument(level = "debug", skip(self))]
159 pub fn create_playlist(&self, mut playlist: QueryablePlaylist) -> Result<String> {
160 let mut conn = self.pool.get().unwrap();
161
162 trace!("Sanitizing playlist");
163
164 if playlist.playlist_id.is_none() {
165 playlist.playlist_id = Some(Uuid::new_v4().to_string());
166 }
167
168 if playlist.playlist_name.is_empty() {
169 playlist.playlist_name = "New playlist".to_string();
170 }
171
172 if playlist.playlist_path.is_some() {
173 let fetched = self.get_playlists(
174 QueryablePlaylist {
175 playlist_path: playlist.playlist_path.clone(),
176 ..Default::default()
177 },
178 false,
179 &mut conn,
180 )?;
181 if !fetched.is_empty() {
182 return Ok(fetched[0].playlist_id.clone().unwrap());
183 }
184 }
185
186 self.insert_playlist(&mut conn, &playlist)
187 }
188
189 #[tracing::instrument(level = "debug", skip(self))]
190 pub fn add_to_playlist_bridge(&self, playlist_id: String, song_id: String) -> Result<()> {

Callers 4

test_playlist_operationsFunction · 0.80
test_searchFunction · 0.80
start_scan_innerFunction · 0.80
add_playlistMethod · 0.80

Calls 4

getMethod · 0.80
get_playlistsMethod · 0.80
cloneMethod · 0.80
insert_playlistMethod · 0.80

Tested by 2

test_playlist_operationsFunction · 0.64
test_searchFunction · 0.64