From 655d4877a144df67a24edd767afec2edb125d459 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Joel=20K=C3=A5berg?= Date: Wed, 13 Feb 2013 11:34:39 +0100 Subject: [PATCH 1/2] universal hardlink solution --- TorrentToMedia.py | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/TorrentToMedia.py b/TorrentToMedia.py index fee10a6b..8585e38e 100755 --- a/TorrentToMedia.py +++ b/TorrentToMedia.py @@ -141,7 +141,16 @@ elif useLink == 1 and packed == 0: ## hardlink os.mkdir(destination) for dirpath, dirnames, filenames in os.walk(Directory): for file in filenames: - os.link(os.path.join(dirpath, file), os.path.join(destination, file)) + + source = os.path.join(dirpath, file) + target = os.path.join(destination, file) + + if os.name == 'nt' + subprocess.call(['cmd', '/C', 'mklink', '/H', target, source], stdout=subprocess.PIPE) + elif os.name == 'posix': + os.link(source, target) + else: + print "ERROR: Hardlink failed, cannot determine OS." elif packed == 1: ## unpack ## Using Windows? From f817af3ddf1052e4ff0e2dc9dab0257dab50c2b0 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Joel=20K=C3=A5berg?= Date: Wed, 13 Feb 2013 11:38:05 +0100 Subject: [PATCH 2/2] my bad --- TorrentToMedia.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/TorrentToMedia.py b/TorrentToMedia.py index 8585e38e..d6eea844 100755 --- a/TorrentToMedia.py +++ b/TorrentToMedia.py @@ -146,7 +146,7 @@ elif useLink == 1 and packed == 0: ## hardlink target = os.path.join(destination, file) if os.name == 'nt' - subprocess.call(['cmd', '/C', 'mklink', '/H', target, source], stdout=subprocess.PIPE) + subprocess.call(['cmd', '/C', 'mklink', '/H', source, target], stdout=subprocess.PIPE) elif os.name == 'posix': os.link(source, target) else: