The delete modal allows users to permanently delete files or folders from S3. This action cannot be undone.
To use the delete modal in your code:
from s3ranger.ui.modals import DeleteModal
# For deleting a file
def delete_file(self, s3_path: str):
modal = DeleteModal(s3_path=s3_path, is_folder=False)
self.app.push_screen(modal, callback=self.on_delete_complete)
# For deleting a folder
def delete_folder(self, s3_path: str):
modal = DeleteModal(s3_path=s3_path, is_folder=True)
self.app.push_screen(modal, callback=self.on_delete_complete)
def on_delete_complete(self, success: bool):
if success:
# Refresh the file listing
self.refresh_objects()