Can I remove files from upload directory?

What will happen if I remove files that have been in the upload directory for some time (weeks). I noticed that the files seem to be corrupted, like only half the image will load (or the video will not play at all). I also noticed that a lot of files are quite large (by my library standard) 1gb+. Which led me to think that some sort of network problem may have stopped them from uploading correctly? Will any missing files be uploaded automatically from mobile devices? or do I need to identify the files and try to upload them manually?
10 Replies
jrasm91
jrasm912y ago
It is only considered a successful upload if they get added in the database. These probably are not. You can always do a query by file name to check though. A partial file upload would mean the request failed before the record would have been created in the database.
Tony P
Tony P2y ago
I have deleted those files without issue... though I did have to sudo rm them. They were all corrupt versions of files in my library.
jrasm91
jrasm912y ago
Great! The containers run as root by default unfortunately, so any files it creates will be owned by root. Which is why you had to sudo remove them
vakulenchuk
vakulenchukOP2y ago
Thank you both! is it correct to assume that the filename given in the upload directory will match the 'id' field of in the 'asset' table (less the '.jpg' extension) ?
bo0tzz
bo0tzz2y ago
No, it's randomly generated as the file is created during the upload, before anything gets added to the database
jrasm91
jrasm912y ago
You should be able to use these queries though https://immich.app/docs/guides/database-queries
Database Queries | Immich
Keep in mind that mucking around in the database might set the moon on fire. Avoid modifying the database directly when possible, and always have current backups.
vakulenchuk
vakulenchukOP2y ago
Thanks for this!
codekote
codekote2y ago
Hello, so I did't get it. Can I delete all files in upload folder? It just take a lot of space, but everything looks fine. there are only mp4 files still there
jrasm91
jrasm912y ago
try running the storage migration first to see if it moves anything else.
codekote
codekote2y ago
it's working) thanks

Did you find this page helpful?