Skip to content

Commit

Permalink
medialib: squash leading folder paths
Browse files Browse the repository at this point in the history
  • Loading branch information
Oleksiy-Yakovenko committed Aug 19, 2023
1 parent cf24267 commit 57cbe0d
Showing 1 changed file with 20 additions and 0 deletions.
20 changes: 20 additions & 0 deletions plugins/medialib/medialibtree.c
Original file line number Diff line number Diff line change
Expand Up @@ -403,6 +403,26 @@ _create_folder_tree(medialib_source_t *source, ml_tree_item_t *root, int selecte
deadbeef->plt_sort_v2(source->ml_playlist, PL_MAIN, -1, sort_tf, DDB_SORT_ASCENDING);

_create_sorted_folder_tree(source->ml_playlist, root, selected, NULL, 0);

// squash single-item tree nodes
ml_tree_item_t *prev = NULL;
for (ml_tree_item_t *head = root->children; head != NULL; prev = head, head = head->next) {
while (head->num_children == 1) {
ml_tree_item_t *new_head = head->children;
new_head->next = head->next;

deadbeef->pl_item_unref(head->track);
deadbeef->metacache_remove_string(head->text);
free (head);
head = new_head;
if (prev != NULL) {
prev->next = head;
}
else {
root->children = head;
}
}
}
}

ml_tree_item_t *
Expand Down

0 comments on commit 57cbe0d

Please sign in to comment.