mirror of
https://github.com/paperless-ngx/paperless-ngx.git
synced 2025-12-09 00:05:21 +01:00
Fix for #131: delete files on document.delete
This commit is contained in:
parent
58a299b671
commit
f5daded930
4 changed files with 39 additions and 7 deletions
|
|
@ -1,4 +1,5 @@
|
|||
import logging
|
||||
import os
|
||||
|
||||
from subprocess import Popen
|
||||
|
||||
|
|
@ -62,10 +63,7 @@ def run_pre_consume_script(sender, filename, **kwargs):
|
|||
if not settings.PRE_CONSUME_SCRIPT:
|
||||
return
|
||||
|
||||
Popen((
|
||||
settings.PRE_CONSUME_SCRIPT,
|
||||
filename
|
||||
)).wait()
|
||||
Popen((settings.PRE_CONSUME_SCRIPT, filename)).wait()
|
||||
|
||||
|
||||
def run_post_consume_script(sender, document, **kwargs):
|
||||
|
|
@ -84,3 +82,10 @@ def run_post_consume_script(sender, document, **kwargs):
|
|||
str(document.correspondent),
|
||||
str(",".join(document.tags.all().values_list("slug", flat=True)))
|
||||
)).wait()
|
||||
|
||||
|
||||
def cleanup_document_deletion(sender, instance, using, **kwargs):
|
||||
try:
|
||||
os.unlink(instance.source_path)
|
||||
except FileNotFoundError:
|
||||
pass # The file's already gone, so we're cool with it.
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue