Added support for symbolic linking.

This commit is contained in:
Kyle Klein 2013-04-18 19:43:49 -07:00
parent cecd34c626
commit 6ee08b99b0
4 changed files with 29 additions and 7 deletions

View file

@ -150,9 +150,9 @@ def is_sample(filePath, inputName, minSampleSize):
def copy_link(filePath, targetDirectory, useLink, outputDestination):
create_destination(outputDestination)
if useLink != 0:
if useLink == "hard":
try:
Logger.info("COPYLINK: Linking %s to %s", filePath, targetDirectory)
Logger.info("COPYLINK: Hard linking %s to %s", filePath, targetDirectory)
linktastic.link(filePath, targetDirectory)
except:
if os.path.isfile(targetDirectory):
@ -161,6 +161,19 @@ def copy_link(filePath, targetDirectory, useLink, outputDestination):
Logger.info("COPYLINK: Something went wrong in linktastic.link, copying instead")
Logger.debug("COPYLINK: Copying %s to %s", filePath, targetDirectory)
shutil.copy(filePath, targetDirectory)
elif useLink == "sym":
try:
Logger.info("COPYLINK: Moving %s to %s before sym linking", filePath, targetDirectory)
shutil.move(filePath, targetDirectory)
Logger.info("COPYLINK: Sym linking %s to %s", targetDirectory, filePath)
linktastic.symlink(targetDirectory, filePath)
except:
if os.path.isfile(targetDirectory):
Logger.info("COPYLINK: Something went wrong in linktastic.link, but the destination file was created")
else:
Logger.info("COPYLINK: Something went wrong in linktastic.link, copying instead")
Logger.debug("COPYLINK: Copying %s to %s", filePath, targetDirectory)
shutil.copy(filePath, targetDirectory)
else:
Logger.debug("Copying %s to %s", filePath, targetDirectory)
shutil.copy(filePath, targetDirectory)