From 6faeb578a79be80c265c17701b5b79d3158fea13 Mon Sep 17 00:00:00 2001 From: shypike Date: Wed, 9 Apr 2014 21:11:08 +0200 Subject: [PATCH] Don't trim file names when renaming them (so revert to old behavior). --- sabnzbd/misc.py | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/sabnzbd/misc.py b/sabnzbd/misc.py index 2259cd3..0ce2440 100644 --- a/sabnzbd/misc.py +++ b/sabnzbd/misc.py @@ -226,7 +226,7 @@ FL_LEGAL = CH_LEGAL + "-''" uFL_ILLEGAL = FL_ILLEGAL.decode('latin-1') uFL_LEGAL = FL_LEGAL.decode('latin-1') -def sanitize_foldername(name): +def sanitize_foldername(name, limit=True): """ Return foldername with dodgy chars converted to safe ones Remove any leading and trailing dot and space characters """ @@ -260,7 +260,7 @@ def sanitize_foldername(name): name = 'unknown' maxlen = cfg.folder_max_length() - if len(name) > maxlen: + if limit and len(name) > maxlen: name = name[:maxlen] return name @@ -1237,7 +1237,9 @@ def renamer(old, new): """ Rename file/folder with retries for Win32 """ # Sanitize last part of new name path, name = os.path.split(new) - new = os.path.join(path, sanitize_foldername(name)) + # Use the more stringent folder rename to end up with a nicer name, + # but do not trim size + new = os.path.join(path, sanitize_foldername(name, False)) if sabnzbd.WIN32: retries = 15