Commit db2da597 by Matthias Putz

Portable: fixing diverse file handling issues

parent 357d4603
......@@ -3,7 +3,9 @@ import os
import pager
import platform
import re
import shutil
import socket
import stat
import sys
import subprocess
import threading
......@@ -18,6 +20,24 @@ if isUnix():
def to_windows_path(path):
return path.replace('/', '\\')
def rmtree(path):
shutil.rmtree(path, onerror=onerror)
def rename(src, dst):
if isUnix():
os.rename(src, dst)
else:
if os.path.exists(dst):
os.remove(dst)
os.rename(src, dst)
def onerror(function, path, excinfo):
if not os.access(path, os.W_OK):
os.chmod(path, stat.S_IWUSR)
function(path)
else:
raise
def input_reader(src, dest, std_name):
if isUnix():
......
......@@ -55,7 +55,8 @@ def _lwrite(path, content):
fd.close()
try:
os.rename(lock, path)
# os.rename(lock, path)
portable.rename(lock, path)
except OSError:
os.remove(lock)
raise
......@@ -2401,7 +2402,8 @@ class Project(object):
self._CopyAndLinkFiles()
except Exception:
if init_dotgit:
shutil.rmtree(dotgit)
# shutil.rmtree(dotgit)
portable.rmtree(dotgit)
raise
def _gitdir_path(self, path):
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment