From a6145d5bc896d9a2ad5ce723d24fb0934e715f6b Mon Sep 17 00:00:00 2001 From: James Bunton Date: Sun, 31 Jul 2016 14:58:36 +1000 Subject: [PATCH] mythsymlink: generate a random filename if there is a conflict --- mythsymlink | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/mythsymlink b/mythsymlink index c744210..42a4f9b 100755 --- a/mythsymlink +++ b/mythsymlink @@ -1,6 +1,7 @@ #!/usr/bin/env python2 import os +import random import re import socket import sys @@ -77,6 +78,9 @@ for row in cursor: if not os.path.isfile(source): continue + if os.path.isfile(dest): + dest = os.path.splitext(dest)[0] + ' - unique' + str(random.randint(1000, 9999)) + extn + dirnames = dest.split("/")[:-1] for i in xrange(1, len(dirnames)+1): dirname = "/".join(dirnames[:i]) -- 2.39.2