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

View File

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