Saumya-Bhatt / Twitter-Clone

Made a frontend + backend of Twitter clone in python (Flask) with fully login functionalities, cookie management system, and relational databases for storing data.
http://saumyabhatt.pythonanywhere.com/home
35 stars 16 forks source link

Python script to remove images #4

Closed Saumya-Bhatt closed 4 years ago

Saumya-Bhatt commented 4 years ago

Introduction

When the user makes an account, a default profile image and a background image is added to the user's account. When the user updates it, a new profile image and/or a new background image is added to the user's account page.

What the issue is

When the user again changes his/her profile image and/or background image, the new image is added to the folder Static/Images/Users/profile_img and Static/Images/Users/bg_img respectively where the previously stored images are present. The older images (i.e the images which do not currently constitutes either the user's profile image or background image) are still present in those folders.

For a small user base, this may not seem much, but as the number of users grow, it would become problematic as it would require more and more storage space.

What needs to be done

When the user changes his/her profile picture and/or background image unless the earlier image was NOT the default profile and background image, make a python script that will delete those older images once the user has specified what the new bg/profile picture is.

Note: The default images in those folders are named as default.png and default_bg.png and should not be deleted under any circumstances

theopaid commented 4 years ago

Hi! I'll try to look into it :)

theopaid commented 4 years ago

I have a solution ready. I will make a PR on Oct 1st. Also, note that the default images have .jpg extension

Saumya-Bhatt commented 4 years ago

Noted. Thanks! :)

Saumya-Bhatt commented 4 years ago

Thanks a lot, man! Awesome work!