add option move-sym to create symlink to renamed files. Fixes #894

This commit is contained in:
clinton-hall 2015-12-15 22:52:01 +10:30
commit 316cc64075
3 changed files with 24 additions and 4 deletions

View file

@ -249,6 +249,10 @@ def processTorrent(inputDirectory, inputName, inputCategory, inputHash, inputID,
core.update_downloadInfoStatus(inputName, 1)
# remove torrent
if core.USELINK == 'move-sym' and not core.DELETE_ORIGINAL == 1:
inputFiles = core.listMediaFiles(inputDirectory)
for link in inputFiles:
core.replace_links(link)
core.remove_torrent(clientAgent, inputHash, inputID, inputName)
if not sectionName == 'UserScript': # for user script, we assume this is cleaned by the script or option USER_SCRIPT_CLEAN

View file

@ -221,7 +221,7 @@
[Torrent]
###### clientAgent - Supported clients: utorrent, transmission, deluge, rtorrent, vuze, other
clientAgent = other
###### useLink - Set to hard for physical links, sym for symbolic links, move to move, and no to not use links (copy)
###### useLink - Set to hard for physical links, sym for symbolic links, move to move, move-sym to move and link back, and no to not use links (copy)
useLink = hard
###### outputDirectory - Default output directory (categories will be appended as sub directory to outputDirectory)
outputDirectory = /abs/path/to/complete/

View file

@ -232,10 +232,13 @@ def copy_link(src, targetLink, useLink):
return True
elif useLink == "sym":
logger.info("Sym linking SOURCE MEDIAFILE -> TARGET FOLDER", 'COPYLINK')
#shutil.move(src, targetLink)
#linktastic.symlink(targetLink, src)
linktastic.symlink(src, targetLink)
return True
elif useLink == "move-sym":
logger.info("Sym linking SOURCE MEDIAFILE -> TARGET FOLDER", 'COPYLINK')
shutil.move(src, targetLink)
linktastic.symlink(targetLink, src)
return True
elif useLink == "move":
logger.info("Moving SOURCE MEDIAFILE -> TARGET FOLDER", 'COPYLINK')
shutil.move(src, targetLink)
@ -248,6 +251,19 @@ def copy_link(src, targetLink, useLink):
return True
def replace_links(link):
if not os.path.islink(link):
return
target = link
n = 0
while os.path.islink(target):
target = os.readlink(target)
n = n + 1
if n > 1:
logger.info("Changing sym-link: %s to point directly to file: %s" % (link, target), 'COPYLINK')
os.unlink(link)
linktastic.symlink(target, link)
def flatten(outputDestination):
logger.info("FLATTEN: Flattening directory: %s" % (outputDestination))
for outputFile in listMediaFiles(outputDestination):
@ -782,7 +798,7 @@ def remove_torrent(clientAgent, inputHash, inputID, inputName):
time.sleep(5)
except:
logger.warning("Failed to delete torrent %s in %s" % (inputName, clientAgent))
else:
else:
resume_torrent(clientAgent, inputHash, inputID, inputName)
def find_download(clientAgent, download_id):