diff options
-rw-r--r-- | apps/tagtree.c | 22 |
1 files changed, 13 insertions, 9 deletions
diff --git a/apps/tagtree.c b/apps/tagtree.c index 1a49936f45..267fa4fba7 100644 --- a/apps/tagtree.c +++ b/apps/tagtree.c | |||
@@ -2205,34 +2205,35 @@ static bool insert_all_playlist(struct tree_context *c, | |||
2205 | bool fill_randomly = false; | 2205 | bool fill_randomly = false; |
2206 | bool *rand_bool_array = NULL; | 2206 | bool *rand_bool_array = NULL; |
2207 | char buf[MAX_PATH]; | 2207 | char buf[MAX_PATH]; |
2208 | struct playlist_insert_context context; | ||
2208 | 2209 | ||
2209 | cpu_boost(true); | 2210 | cpu_boost(true); |
2211 | |||
2210 | if (!tagcache_search(&tcs, tag_filename)) | 2212 | if (!tagcache_search(&tcs, tag_filename)) |
2211 | { | 2213 | { |
2212 | splash(HZ, ID2P(LANG_TAGCACHE_BUSY)); | 2214 | splash(HZ, ID2P(LANG_TAGCACHE_BUSY)); |
2213 | cpu_boost(false); | 2215 | cpu_boost(false); |
2214 | return false; | 2216 | return false; |
2215 | } | 2217 | } /* NOTE: you need to close this search before returning */ |
2216 | 2218 | ||
2217 | if (playlist == NULL && position == PLAYLIST_REPLACE) | 2219 | if (playlist == NULL) |
2218 | { | 2220 | { |
2219 | if (playlist_remove_all_tracks(NULL) == 0) | 2221 | if (playlist_insert_context_create(NULL, &context, position, queue, false) < 0) |
2220 | position = PLAYLIST_INSERT_LAST; | ||
2221 | else | ||
2222 | { | 2222 | { |
2223 | tagcache_search_finish(&tcs); | ||
2223 | cpu_boost(false); | 2224 | cpu_boost(false); |
2224 | return false; | 2225 | return false; |
2225 | } | 2226 | } |
2226 | } | 2227 | } |
2227 | else if (playlist != NULL) | 2228 | else |
2228 | { | 2229 | { |
2229 | if (new_playlist) | 2230 | if (new_playlist) |
2230 | fd = open_utf8(playlist, O_CREAT|O_WRONLY|O_TRUNC); | 2231 | fd = open_utf8(playlist, O_CREAT|O_WRONLY|O_TRUNC); |
2231 | else | 2232 | else |
2232 | fd = open(playlist, O_CREAT|O_WRONLY|O_APPEND, 0666); | 2233 | fd = open(playlist, O_CREAT|O_WRONLY|O_APPEND, 0666); |
2233 | |||
2234 | if(fd < 0) | 2234 | if(fd < 0) |
2235 | { | 2235 | { |
2236 | tagcache_search_finish(&tcs); | ||
2236 | cpu_boost(false); | 2237 | cpu_boost(false); |
2237 | return false; | 2238 | return false; |
2238 | } | 2239 | } |
@@ -2249,6 +2250,7 @@ static bool insert_all_playlist(struct tree_context *c, | |||
2249 | if (slots_remaining <= 0) | 2250 | if (slots_remaining <= 0) |
2250 | { | 2251 | { |
2251 | logf("Playlist has no space remaining"); | 2252 | logf("Playlist has no space remaining"); |
2253 | tagcache_search_finish(&tcs); | ||
2252 | cpu_boost(false); | 2254 | cpu_boost(false); |
2253 | return false; | 2255 | return false; |
2254 | } | 2256 | } |
@@ -2332,7 +2334,7 @@ static bool insert_all_playlist(struct tree_context *c, | |||
2332 | } | 2334 | } |
2333 | } | 2335 | } |
2334 | 2336 | ||
2335 | if (playlist_insert_track(NULL, buf, position, queue, false) < 0) { | 2337 | if (playlist_insert_context_add(&context, buf) < 0) { |
2336 | logf("playlist_insert_track failed"); | 2338 | logf("playlist_insert_track failed"); |
2337 | exit_loop_now = true; | 2339 | exit_loop_now = true; |
2338 | break; | 2340 | break; |
@@ -2350,10 +2352,12 @@ static bool insert_all_playlist(struct tree_context *c, | |||
2350 | if (exit_loop_now) | 2352 | if (exit_loop_now) |
2351 | break; | 2353 | break; |
2352 | } | 2354 | } |
2355 | |||
2353 | if (playlist == NULL) | 2356 | if (playlist == NULL) |
2354 | playlist_sync(NULL); | 2357 | playlist_insert_context_release(&context); |
2355 | else | 2358 | else |
2356 | close(fd); | 2359 | close(fd); |
2360 | |||
2357 | tagcache_search_finish(&tcs); | 2361 | tagcache_search_finish(&tcs); |
2358 | cpu_boost(false); | 2362 | cpu_boost(false); |
2359 | 2363 | ||