truncate unnecessary logic

pull/49/head
Aevann1 2022-12-05 17:10:15 +02:00
parent 847385ad87
commit 84ec5f5b46
2 changed files with 13 additions and 21 deletions

View File

@ -41,8 +41,7 @@ def settings_personal(v:User):
def remove_background(v):
if v.background:
if v.background.startswith('/images/'):
fpath = '/images/' + v.background.split('/images/')[1]
if path.isfile(fpath): os.remove(fpath)
os.remove(v.background)
v.background = None
if v.theme == 'transparent': v.theme = 'midnight'
g.db.add(v)
@ -66,8 +65,7 @@ def upload_custom_background(v):
if background:
if v.background and v.background.startswith('/images/'):
fpath = '/images/' + v.background.split('/images/')[1]
if path.isfile(fpath): os.remove(fpath)
os.remove(v.background)
v.background = background
g.db.add(v)
@ -88,8 +86,7 @@ def upload_profile_background(v):
if background:
if v.profile_background:
fpath = '/images/' + v.profile_background.split('/images/')[1]
if path.isfile(fpath): os.remove(fpath)
os.remove(v.profile_background)
v.profile_background = background
g.db.add(v)
badge_grant(badge_id=193, user=v)
@ -553,11 +550,10 @@ def settings_images_profile(v):
if not imageurl: abort(400)
if v.highres and '/images/' in v.highres:
fpath = '/images/' + v.highres.split('/images/')[1]
if path.isfile(fpath): os.remove(fpath)
os.remove(v.highres)
if v.profileurl and '/images/' in v.profileurl:
fpath = '/images/' + v.profileurl.split('/images/')[1]
if path.isfile(fpath): os.remove(fpath)
os.remove(v.profileurl)
v.highres = highres
v.profileurl = imageurl
g.db.add(v)
@ -582,8 +578,7 @@ def settings_images_banner(v):
if bannerurl:
if v.bannerurl and '/images/' in v.bannerurl:
fpath = '/images/' + v.bannerurl.split('/images/')[1]
if path.isfile(fpath): os.remove(fpath)
os.remove(v.bannerurl)
v.bannerurl = bannerurl
g.db.add(v)

View File

@ -480,9 +480,8 @@ def sub_banner(v, sub):
bannerurl = process_image(name, v, resize=1200)
if bannerurl:
if sub.bannerurl and '/images/' in sub.bannerurl:
fpath = '/images/' + sub.bannerurl.split('/images/')[1]
if path.isfile(fpath): os.remove(fpath)
if sub.bannerurl:
os.remove(sub.bannerurl)
sub.bannerurl = bannerurl
g.db.add(sub)
@ -512,9 +511,8 @@ def sub_sidebar(v, sub):
sidebarurl = process_image(name, v, resize=400)
if sidebarurl:
if sub.sidebarurl and '/images/' in sub.sidebarurl:
fpath = '/images/' + sub.sidebarurl.split('/images/')[1]
if path.isfile(fpath): os.remove(fpath)
if sub.sidebarurl:
os.remove(sub.sidebarurl)
sub.sidebarurl = sidebarurl
g.db.add(sub)
@ -544,9 +542,8 @@ def sub_marsey(v, sub):
marseyurl = process_image(name, v, resize=200)
if marseyurl:
if sub.marseyurl and '/images/' in sub.marseyurl:
fpath = '/images/' + sub.marseyurl.split('/images/')[1]
if path.isfile(fpath): os.remove(fpath)
if sub.marseyurl:
os.remove(sub.marseyurl)
sub.marseyurl = marseyurl
g.db.add(sub)