Update the query when removing invalid folder