added protection agains deletion

This commit is contained in:
Gabriel Radureau
2025-10-21 19:14:17 +02:00
parent 30e4a35362
commit 73b2ccb917

View File

@@ -63,14 +63,17 @@ def show_video_row(
(st.rerun if hasattr(st, "rerun") else st.experimental_rerun)()
with c3:
if st.button("🗑️", key=f"del_{video.file_name}"):
st.session_state[play_key] = False
if os.path.exists(video.raw_file ):
os.remove(video.raw_file)
if os.path.exists(video.mp4_file):
shutil.rmtree(os.path.dirname(video.mp4_file))
db.delete_video(video.file_name)
st.warning("Vidéo supprimée.")
(st.rerun if hasattr(st, "rerun") else st.experimental_rerun)()
if preselected_labels and len(preselected_labels) > 0:
st.warning("Vidéo labelisée.")
else:
st.session_state[play_key] = False
if os.path.exists(video.raw_file ):
os.remove(video.raw_file)
if os.path.exists(video.mp4_file):
shutil.rmtree(os.path.dirname(video.mp4_file))
db.delete_video(video.file_name)
st.warning("Vidéo supprimée.")
(st.rerun if hasattr(st, "rerun") else st.experimental_rerun)()
if st.session_state[play_key]:
mp4_path = getattr(video, "mp4_file", None)