Skip to content

Commit

Permalink
[fix] zip file duplication bug
Browse files Browse the repository at this point in the history
  • Loading branch information
ArekKuczynski authored and lucagiove committed Oct 26, 2024
1 parent 6dd68aa commit c0e3ba5
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 1 deletion.
3 changes: 2 additions & 1 deletion ArchiveLibrary/keywords.py
Original file line number Diff line number Diff line change
Expand Up @@ -130,7 +130,8 @@ def create_zip_from_files_in_directory(cls, directory, filename, sub_directories

files = return_files_lists(directory, sub_directories)
for filepath, name in files:
the_zip.write(filepath, arcname=name)
if name != os.path.basename(filename):
the_zip.write(filepath, arcname=name)

the_zip.close()

Expand Down
10 changes: 10 additions & 0 deletions atests/testcase.robot
Original file line number Diff line number Diff line change
Expand Up @@ -105,6 +105,16 @@ Create ZIP Package from files in directory and subdirectory with no compression
Archive Should Contain File ${zipfilename} subdir${/}file3.txt
Remove File ${zipfilename}

Create ZIP Package from files in same directory as files
${zipfilename}= set variable ${CURDIR}${/}FilesToTar${/}newZipFile.zip
Remove File ${zipfilename}
Create zip from Files in directory ${CURDIR}${/}FilesToTar ${zipfilename}
Archive Should Contain File ${zipfilename} file1.txt
Archive Should Contain File ${zipfilename} file2.txt
Run Keyword And Expect Error *does not contain value 'newZipFile.zip'* Archive Should Contain File ${zipfilename} newZipFile.zip
Run Keyword And Expect Error *does not contain value 'subdir${/}file3.txt'* Archive Should Contain File ${zipfilename} subdir${/}file3.txt
Remove File ${zipfilename}

Create ZIP Package from files in directory and subdirectory with compression deflated
${zipfilename}= set variable newZipFile.zip
Remove File ${zipfilename}
Expand Down

0 comments on commit c0e3ba5

Please sign in to comment.