Tytan888 / CSSWENG-S11-G1

0 stars 0 forks source link

Delete image bug #1

Closed rpineda26 closed 11 months ago

rpineda26 commented 11 months ago

💾 Description: The delete image works but it doesn't delete all the data. The way an image is stored in the database is it will be separated into two collections, the files collection will hold the references for the images while the chunks collection keeps the actual data of the image that is cut into separate files if the image is too big. The current implementation of deleting an image, written as gfs.delete(image id) , only deletes the reference for the image and it doesn't delete the chunked data which takes the most space.

Expected Outcome: Both the image references in the uploads.files collection and the raw data in the uploads.chunks collection should be deleted for better space management in the database.

☎️ Actual Outcome: Only the image reference in the uploads.files collection is deleted so the ability to access the image is gone but most of the storage taken up by the image is still there in the database.

:notes: Steps to Reproduce

  1. Upload a test image in the database (can upload a project with an image)
  2. Take note of the image filename uploaded (can check Mongo DB Compass for quick manual reference)
  3. Take note of the corresponding uploads.chunks entries of the image
  4. Either delete the project or update the project and replace the image with a new one.
  5. See if the uploads.files entry is deleted and the uploads.chunks remain
rpineda26 commented 11 months ago

Fix: The issue is solved with along with the other bug where file_uploads.js middleware is using the link for the actual environment's database instead of the test database.