Folders pagination issue results in significant load time

The issue

I face two problems with a large amount of folders:

Folders pagination. When a large number of folders are created in the Media Library, pagination fails to function correctly, allowing thousands of folders to load on a single page without pagination while limiting images to 10 with pagination. This discrepancy significantly degrades performance and can cause backend unresponsiveness.
The loading of the entire folder structure. When editing an image, the Location section calls the /upload/folder-structure endpoint, which loads the entire folder structure simultaneously. This approach, especially with many folders, leads to excessive load times—approximately 7 minutes—or may even cause the backend service to fail.

System information

Node.js version: 19.1.0
NPM version: 8.19.3
Strapi version: 4.13.5
Database: postgres
Operating system: Ubuntu
Is your project Javascript or Typescript: javascript

Steps to reproduce the behavior

Folders pagination

Create more than 10 folders in the Media Library.
Navigate through the Media Library.
Observe the lack of pagination for folders and its presence for images.

Loading the entire folder structure

Create a significant number of folders (1000+) within the Media Library, ensuring to include several layers of nested folders to mimic a complex directory structure commonly found in large-scale projects.
Navigate to the Media Library and select an image to edit.
Observe the response time and system behavior, noting any prolonged loading times or backend instability.

Expected behavior

Folders pagination

Expected pagination to work for both folders and images, limiting the number displayed on a single page to enhance performance and prevent backend issues.

Loading the entire folder structure

The expected behavior is an optimized loading mechanism for the folder structure in the Media Library’s Location section. Solutions that do not require loading the entire directory structure simultaneously

This topic has been created from a Discord post (1272902490873921546) to give it more visibility.
It will be on Read-Only mode here.
Join the conversation on Discord