Commit c555f887 authored by Martin Urban's avatar Martin Urban
Browse files

file: Handle filename collision in move

parent e093e788
......@@ -304,11 +304,18 @@ class FileSystem(object):
for s in source:
self.move(s, destination)
else:
#source = self.handle_file_name_collision(source, path)
source = self.expand(source)
destination = self.expand(destination)
if os.path.isdir(destination):
shutil.move(source, destination)
name = os.path.split(source)[1]
newname = self.handle_file_name_collision(name, destination)
destination = os.path.join(destination, newname)
if os.path.isdir(source):
shutil.copytree(source, destination)
shutil.rmtree(source)
else:
shutil.copy2(source, destination)
os.remove(source)
def compress(self, path, paths, name):
# paths has to be a list of strings
......@@ -339,7 +346,7 @@ class FileSystem(object):
paths.append(fullp)
else:
ap = fullp[
len(path):] if fullp.startswith(path) else fullp
len(path):] if fullp.startswith(path) else fullp
logger.debug(fullp)
archive.write(fullp, ap)
else:
......@@ -651,7 +658,6 @@ class FileSystem(object):
class WatchService(object):
def __init__(self):
self.subscriber_buffer = []
self.subscribers = {}
......@@ -776,7 +782,7 @@ class WatchSubscriber(object): # this should never be instanced manually
now = time()
if event in self.event_buffer:
self.event_buffer[event][1] = now + \
WatchSubscriber.EVENT_DELAYS[event][1]
WatchSubscriber.EVENT_DELAYS[event][1]
else:
self.event_buffer[event] = [now + delay for delay in
WatchSubscriber.EVENT_DELAYS[event]] # first & last event
......
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