Commit 5f6f7e90 authored by Fabian-Andree Heidemann's avatar Fabian-Andree Heidemann
Browse files

Use handle_file_name_collision in decompress

parent d0e64380
...@@ -358,19 +358,11 @@ class FileSystem(object): ...@@ -358,19 +358,11 @@ class FileSystem(object):
def decompress(self, file): def decompress(self, file):
# filepath and extract path # filepath and extract path
filepath = self.expand(file) filepath = self.expand(file)
path = filepath.rsplit(".zip", 1)[0] path = filepath.rsplit("/", 1)[0]
# handle folder collision for extract path foldername = (filepath.rsplit("/", 1)[1]).rsplit(".zip", 1)[0]
while os.path.exists(path):
end = path.rsplit("/", 1)[1]
if len(end.split("_copy")) is not 1:
counter = int(end.rsplit("_copy", 1)[1])
counter += 1
path = path.rsplit("_copy", 1)[0] + "_copy" + str(counter)
else:
path = path + "_copy1"
with ZipFile(filepath, "r") as archive: with ZipFile(filepath, "r") as archive:
archive.extractall(path) archive.extractall(path + "/" + self.handle_file_name_collision(foldername, path))
def paste(self, path, fullsrc, cut): def paste(self, path, fullsrc, cut):
# TODO # TODO
......
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