diff --git a/etiquette/constants.py b/etiquette/constants.py index 4b2a436..5e91ba9 100644 --- a/etiquette/constants.py +++ b/etiquette/constants.py @@ -316,6 +316,8 @@ DEFAULT_CONFIGURATION = { 'thumbnail_width': 400, 'thumbnail_height': 400, + 'recycle_instead_of_delete': True, + 'motd_strings': [ 'Good morning, Paul. What will your first sequence of the day be?', ], diff --git a/etiquette/objects.py b/etiquette/objects.py index 1cbee4f..7b3558d 100644 --- a/etiquette/objects.py +++ b/etiquette/objects.py @@ -5,6 +5,7 @@ but are returned by the PDB accesses. import os import PIL.Image import string +import send2trash import traceback from voussoirkit import bytestring @@ -735,7 +736,13 @@ class Photo(ObjectBase): if delete_file: path = self.real_path.absolute_path - queue_action = {'action': os.remove, 'args': [path]} + if self.photodb.config['recycle_instead_of_delete']: + self.photodb.log.debug('Recycling %s', path) + action = send2trash.send2trash + else: + self.photodb.log.debug('Deleting %s', path) + action = os.remove + queue_action = {'action': action, 'args': [path]} self.photodb.on_commit_queue.append(queue_action) self._uncache() diff --git a/requirements.txt b/requirements.txt index 3609f27..a59b986 100644 --- a/requirements.txt +++ b/requirements.txt @@ -11,6 +11,9 @@ pillow # For probing and thumbnailing video files. git+https://github.com/senko/python-video-converter.git +# Supports the recycle_instead_of_delete config. +send2trash + # For serving downloadable zip files as a generator. zipstream