summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorNick Scheibenpflug <zorchenhimer@gmail.com>2015-06-17 21:04:16 (GMT)
committerNick Scheibenpflug <zorchenhimer@gmail.com>2015-06-17 21:04:16 (GMT)
commitaeafbb08f40ad45f8208eff5f3b2c28890bfca49 (patch)
tree3e4cbf756091933d128101f007591a72b2e31e4d
parentea4d4b5a92411bb743dfded99cca78286bf1a3e3 (diff)
downloadmanga-reader-aeafbb08f40ad45f8208eff5f3b2c28890bfca49.zip
manga-reader-aeafbb08f40ad45f8208eff5f3b2c28890bfca49.tar.gz
Remove orphan files after they've been moved to their permanent directory.
-rw-r--r--file_management/views.py6
1 files changed, 6 insertions, 0 deletions
diff --git a/file_management/views.py b/file_management/views.py
index b8e27d9..27c7c60 100644
--- a/file_management/views.py
+++ b/file_management/views.py
@@ -5,6 +5,8 @@ from django.core import serializers
5from django.core.urlresolvers import reverse 5from django.core.urlresolvers import reverse
6from django.utils import timezone 6from django.utils import timezone
7 7
8from shutil import rmtree
9
8import time 10import time
9import os 11import os
10import zipfile 12import zipfile
@@ -117,3 +119,7 @@ def move_orphan(oid, mid):
117 orphan_dir = os.path.join( 'tmp', '{n}_extracted'.format(n=orphan.filename)) 119 orphan_dir = os.path.join( 'tmp', '{n}_extracted'.format(n=orphan.filename))
118 for f in os.listdir(orphan_dir): 120 for f in os.listdir(orphan_dir):
119 os.rename( os.path.join(orphan_dir, f), os.path.join('manga_data', new_directory, f) ) 121 os.rename( os.path.join(orphan_dir, f), os.path.join('manga_data', new_directory, f) )
122
123 ## Remove orphan files.
124 rmtree(orphan_dir)
125 os.remove(os.path.join('tmp', orphan.filename))