Use send2trash to support recycle_instead_of_delete.

master
voussoir 2020-02-27 14:18:46 -08:00
parent 961ece0081
commit 3f2cde02e1
3 changed files with 13 additions and 1 deletions

View File

@ -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?',
],

View File

@ -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()

View File

@ -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