@RetroLeoxo For your in-game library, it sounds very much like OneDrive is syncing your files by deleting the new ones and redownloading the old. You could try removing the old Sims 4 content from OneDrive, or at least the Tray folder; if there's something you want to keep, back it up elsewhere.
Please also check OneDrive for any newer files, especially in Tray, that are dated recently but have additional text in their names. For example, there might be a ⚽ at the end, or some other number; or you might see your computer name, e.g. DESKTOP-[some characters]. Or the Tray folder itself might be renamed. OneDrive does this to avoid duplicate names and to notate where the files originated. But in either case, the game can't read those files when the names have the extra text.
If you find newer files you want to recover, just delete the extra characters in the name. You can see examples of the correct file formats here:
https://www.carls-sims-4-guide.com/forum/index.php?topic=26535.0
For the Gallery issue, if this is only happening recently, that may be because the Gallery is having intermittent outages. But it's also possible that the issue with your in-game library, whatever that turns out to be, is happening before the Gallery upload succeeds. So if you fix the former, the latter may be resolved as well.