Ticket #1498: 0002-Fix-1498-On-folder-rename-ensures-trailing-slash-and.patch

File 0002-Fix-1498-On-folder-rename-ensures-trailing-slash-and.patch, 1.1 KB (added by Cas, 13 years ago)

Cas' Alternative Patch

  • deluge/core/torrent.py

    From b4b3b9c6b7a61dbe54ad3fab8628103fa81905e7 Mon Sep 17 00:00:00 2001
    From: Calum Lind <calumlind+deluge@gmail.com>
    Date: Thu, 27 Jan 2011 18:22:09 +0000
    Subject: [PATCH 2/2] Fix #1498: On folder rename ensures trailing slash and replaces any duplicates
    
    ---
     deluge/core/torrent.py |    6 ++++--
     1 files changed, 4 insertions(+), 2 deletions(-)
    
    diff --git a/deluge/core/torrent.py b/deluge/core/torrent.py
    index 7651b6e..5a4d723 100644
    a b  
    3737import os 
    3838import time 
    3939import logging 
     40import re 
    4041from urllib import unquote 
    4142from urlparse import urlparse 
    4243 
    def rename_folder(self, folder, new_folder): 
    903904            log.error("Attempting to rename a folder with an invalid folder name: %s", new_folder) 
    904905            return 
    905906 
    906         if new_folder[-1:] != "/": 
    907             new_folder += "/" 
     907        # Ensures trailing slash and replaces any duplicates  
     908        p = re.compile('/{2,}') 
     909        new_folder=p.sub('/',new_folder + "/") 
    908910 
    909911        wait_on_folder = (folder, new_folder, []) 
    910912        for f in self.get_files():