I think you will fit window functions, something like:
file_list AS (
,SUM(filesize) OVER (PARTITION BY component ORDER BY id) AS filesize_summary
,SUM(rowcount) OVER (PARTITION BY component ORDER BY id) AS rowcount_summary
FROM file_chunks c
INNER JOIN l ON c file_list.id=l.id
AND (filesize_summary<=_SIZE_LIMIT OR rowcount_summary<=ROWS_LIMIT);
Here in CTE select id files that fall under the condition, and then on these id already choose all that nuyno from the main table. PARTITION BY is the area within which summarize the data (that is, in the example, the amount of componentid will be different), ORDER BY is the order in which we accumulate the result.