diff --git a/files/routes/admin.py b/files/routes/admin.py index c3767f570..870aaba31 100644 --- a/files/routes/admin.py +++ b/files/routes/admin.py @@ -1785,7 +1785,7 @@ def delete_media_post(v): if not os.path.isfile(path): return render_template("admin/delete_media.html", v=v, url=url, error="File not found on the server!") - remove_media(path) + remove_media_using_link(path) ma=ModAction( kind="delete_media", diff --git a/files/routes/asset_submissions.py b/files/routes/asset_submissions.py index 033d0e992..e4f6b8faf 100644 --- a/files/routes/asset_submissions.py +++ b/files/routes/asset_submissions.py @@ -204,8 +204,8 @@ def remove_asset(cls, type_name:str, v:User, name:str) -> dict[str, str]: g.db.add(ma) g.db.delete(asset) - remove_media(f"/asset_submissions/{type_name}s/{name}.webp") - remove_media(f"/asset_submissions/{type_name}s/{name}") + remove_media_using_link(f"/asset_submissions/{type_name}s/{name}.webp") + remove_media_using_link(f"/asset_submissions/{type_name}s/{name}") return {"message": f"'{name}' removed!"} @@ -270,7 +270,7 @@ def submit_hat(v:User): with Image.open(highquality) as i: if i.width > 100 or i.height > 130: - remove_media(highquality) + remove_media_using_link(highquality) return error("Images must be 100x130") if len(list(Iterator(i))) > 1: price = 1000 @@ -416,7 +416,7 @@ def update_marsey(v): for x in IMAGE_FORMATS: if path.isfile(f'/asset_submissions/marseys/original/{name}.{x}'): - remove_media(f'/asset_submissions/marseys/original/{name}.{x}') + remove_media_using_link(f'/asset_submissions/marseys/original/{name}.{x}') highquality = f"/asset_submissions/marseys/{name}" file.save(highquality) @@ -482,7 +482,7 @@ def update_hat(v): with Image.open(highquality) as i: if i.width > 100 or i.height > 130: - remove_media(highquality) + remove_media_using_link(highquality) return error("Images must be 100x130") format = i.format.lower() @@ -490,7 +490,7 @@ def update_hat(v): for x in IMAGE_FORMATS: if path.isfile(f'/asset_submissions/hats/original/{name}.{x}'): - remove_media(f'/asset_submissions/hats/original/{name}.{x}') + remove_media_using_link(f'/asset_submissions/hats/original/{name}.{x}') rename(highquality, new_path) diff --git a/files/routes/settings.py b/files/routes/settings.py index 85e195381..fd0f28ce9 100644 --- a/files/routes/settings.py +++ b/files/routes/settings.py @@ -45,7 +45,7 @@ def settings_personal(v:User): def remove_background(v): if v.background: if v.background.startswith('/images/'): - remove_media(v.background) + remove_media_using_link(v.background) v.background = None g.db.add(v) return {"message": "Background removed!"} @@ -69,7 +69,7 @@ def upload_custom_background(v): if background: if v.background and v.background.startswith('/images/'): - remove_media(v.background) + remove_media_using_link(v.background) v.background = background g.db.add(v) @@ -91,7 +91,7 @@ def upload_profile_background(v): if background: if v.profile_background and path.isfile(v.profile_background): - remove_media(v.profile_background) + remove_media_using_link(v.profile_background) v.profile_background = background g.db.add(v) badge_grant(badge_id=193, user=v) @@ -103,7 +103,7 @@ def upload_profile_background(v): @auth_required def delete_profile_background(v): if v.profile_background: - remove_media(v.profile_background) + remove_media_using_link(v.profile_background) v.profile_background = None return {"message": "Profile background removed!"} @@ -549,10 +549,10 @@ def settings_images_profile(v): if not imageurl: abort(400) if v.highres and '/images/' in v.highres and path.isfile(v.highres): - remove_media(v.highres) + remove_media_using_link(v.highres) if v.profileurl and '/images/' in v.profileurl and path.isfile(v.profileurl): - remove_media(v.profileurl) + remove_media_using_link(v.profileurl) v.highres = highres v.profileurl = imageurl @@ -582,7 +582,7 @@ def settings_images_banner(v): if bannerurl: if v.bannerurl and '/images/' in v.bannerurl and path.isfile(v.bannerurl): - remove_media(v.bannerurl) + remove_media_using_link(v.bannerurl) v.bannerurl = bannerurl g.db.add(v) @@ -749,11 +749,11 @@ def settings_song_change_mp3(v): size = os.stat(name).st_size if size > 8 * 1024 * 1024: - remove_media(name) + remove_media_using_link(name) return redirect("/settings/personal?error=MP3 file must be smaller than 8MB") if path.isfile(f"/songs/{v.song}.mp3") and g.db.query(User).filter_by(song=v.song).count() == 1: - remove_media(f"/songs/{v.song}.mp3") + remove_media_using_link(f"/songs/{v.song}.mp3") v.song = song g.db.add(v) @@ -766,7 +766,7 @@ def _change_song_youtube(vid, id): v = db.get(User, vid) if v.song and path.isfile(f"/songs/{v.song}.mp3") and db.query(User).filter_by(song=v.song).count() == 1: - remove_media(f"/songs/{v.song}.mp3") + remove_media_using_link(f"/songs/{v.song}.mp3") ydl_opts = { 'cookiefile': '/cookies', @@ -807,7 +807,7 @@ def settings_song_change(v): if song == "" and v.song: if path.isfile(f"/songs/{v.song}.mp3") and g.db.query(User).filter_by(song=v.song).count() == 1: - remove_media(f"/songs/{v.song}.mp3") + remove_media_using_link(f"/songs/{v.song}.mp3") v.song = None g.db.add(v) return redirect("/settings/personal?msg=Profile Anthem successfully removed!") diff --git a/files/routes/subs.py b/files/routes/subs.py index e22f7b7d2..26f69ed79 100644 --- a/files/routes/subs.py +++ b/files/routes/subs.py @@ -544,7 +544,7 @@ def delete_sub_banner(v:User, sub:str, index:int): abort(404, f'Banner not found (banner index {index} is not between 0 and {len(sub.bannerurls)})') banner = sub.bannerurls[index] try: - remove_media(banner) + remove_media_using_link(banner) except FileNotFoundError: pass del sub.bannerurls[index] @@ -570,7 +570,7 @@ def delete_all_sub_banners(v:User, sub:str): if v.shadowbanned: return redirect(f'/h/{sub}/settings') for banner in sub.banner_urls: try: - remove_media(banner) + remove_media_using_link(banner) except FileNotFoundError: pass sub.bannerurls = [] @@ -605,7 +605,7 @@ def sub_sidebar(v:User, sub): if sidebarurl: if sub.sidebarurl: - remove_media(sub.sidebarurl) + remove_media_using_link(sub.sidebarurl) sub.sidebarurl = sidebarurl g.db.add(sub) @@ -637,7 +637,7 @@ def sub_marsey(v:User, sub): if marseyurl: if sub.marseyurl: - remove_media(sub.marseyurl) + remove_media_using_link(sub.marseyurl) sub.marseyurl = marseyurl g.db.add(sub)