Use send2trash to support recycle_instead_of_delete.
This commit is contained in:
parent
961ece0081
commit
3f2cde02e1
3 changed files with 13 additions and 1 deletions
|
@ -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?',
|
||||
],
|
||||
|
|
|
@ -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()
|
||||
|
||||
|
|
|
@ -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
|
||||
|
||||
|
|
Loading…
Reference in a new issue