From 7861416dc535324af22290a883d098a92d8a5e13 Mon Sep 17 00:00:00 2001 From: Ruud Date: Sun, 21 Sep 2014 10:43:53 +0200 Subject: [PATCH] Don't write over files already renamed --- couchpotato/core/plugins/renamer.py | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/couchpotato/core/plugins/renamer.py b/couchpotato/core/plugins/renamer.py index a2d993ed..77840531 100755 --- a/couchpotato/core/plugins/renamer.py +++ b/couchpotato/core/plugins/renamer.py @@ -10,7 +10,7 @@ from couchpotato.api import addApiView from couchpotato.core.event import addEvent, fireEvent, fireEventAsync from couchpotato.core.helpers.encoding import toUnicode, ss, sp from couchpotato.core.helpers.variable import getExt, mergeDicts, getTitle, \ - getImdb, link, symlink, tryInt, splitString, fnEscape, isSubFolder, getIdentifier + getImdb, link, symlink, tryInt, splitString, fnEscape, isSubFolder, getIdentifier, randomString from couchpotato.core.logger import CPLog from couchpotato.core.plugins.base import Plugin from couchpotato.environment import Env @@ -586,6 +586,10 @@ class Renamer(Plugin): if rename_files[src]: dst = rename_files[src] + if dst in group['renamed_files']: + log.error('File "%s" already exists, adding random string at the end to prevent data loss', dst) + dst = '%s.random-%s' % (dst, randomString()) + # Create dir self.makeDir(os.path.dirname(dst))