don't remove a file before renaming under windows because os.remove('test') will remove 'TEST' under window. Fixes #5279

This commit is contained in:
Yann Leboulanger 2009-09-23 22:27:52 +02:00
parent cb1fccca7c
commit 245c3f12d4
2 changed files with 9 additions and 2 deletions

View File

@ -170,6 +170,11 @@ def prep(user, server, resource):
else:
return server
def windowsify(s):
if os.name == 'nt':
return s.capitalize()
return s
def temp_failure_retry(func, *args, **kwargs):
while True:
try:

View File

@ -1271,8 +1271,10 @@ class GroupchatControl(ChatControlBase, GroupChatCommands):
os.path.join(path, puny_new_nick + ext)
for old_file in files:
if os.path.exists(old_file) and old_file != files[old_file]:
if os.path.exists(files[old_file]):
# Windows require this
if os.path.exists(files[old_file]) and helpers.windowsify(
old_file) != helpers.windowsify(files[old_file]):
# Windows require this, but os.remove('test') will also
# remove 'TEST'
os.remove(files[old_file])
os.rename(old_file, files[old_file])
self.print_conversation(s, 'info', tim)