Delete torrent's files correctly now.
This commit is contained in:
parent
7cbb69bd20
commit
797ac38ca7
26
src/core.py
26
src/core.py
|
@ -312,12 +312,26 @@ class Manager:
|
||||||
# Note: can this be to the trash?
|
# Note: can this be to the trash?
|
||||||
for filedata in temp_fileinfo:
|
for filedata in temp_fileinfo:
|
||||||
filename = filedata['path']
|
filename = filedata['path']
|
||||||
try:
|
if filename.find(os.sep) != -1:
|
||||||
os.remove(os.path.join(temp.save_dir, filename))
|
# This is a file inside a directory inside the torrent. We can delete the
|
||||||
except OSError:
|
# directory itself, save time
|
||||||
pass # No file just means it wasn't downloaded, we can continue
|
try:
|
||||||
#clean up empty dir
|
shutil.rmtree(os.path.dirname(os.path.join(temp.save_dir, filename)))
|
||||||
os.removedirs(os.path.dirname(os.path.join(temp.save_dir, filename)))
|
except OSError: # Perhaps it wasn't downloaded
|
||||||
|
pass
|
||||||
|
else:
|
||||||
|
# This is just a file
|
||||||
|
try:
|
||||||
|
os.remove(os.path.join(temp.save_dir, filename))
|
||||||
|
except OSError:
|
||||||
|
pass # No file just means it wasn't downloaded, we can continue
|
||||||
|
|
||||||
|
### UNNEEDED, fixed already above
|
||||||
|
# # Clean up empty dir
|
||||||
|
# try:
|
||||||
|
# os.rmdir(os.path.dirname(os.path.join(temp.save_dir, filename)))
|
||||||
|
# except OSError:
|
||||||
|
# pass # Perhaps it wasn't a directory...
|
||||||
|
|
||||||
# A function to try and reload a torrent from a previous session. This is
|
# A function to try and reload a torrent from a previous session. This is
|
||||||
# used in the event that Deluge crashes and a blank state is loaded.
|
# used in the event that Deluge crashes and a blank state is loaded.
|
||||||
|
|
Loading…
Reference in New Issue