From e89adfe1daba103cf835eef46e765e7755f6920a Mon Sep 17 00:00:00 2001 From: FondMemoryVVV Date: Wed, 28 Sep 2022 10:11:03 +0800 Subject: [PATCH] fix tar_files.py Signed-off-by: FondMemoryVVV --- commonlibrary/toolchain/libc-test/tar_files.py | 18 ++++++++++-------- 1 file changed, 10 insertions(+), 8 deletions(-) diff --git a/commonlibrary/toolchain/libc-test/tar_files.py b/commonlibrary/toolchain/libc-test/tar_files.py index 1d745e6eb..4d358caf4 100755 --- a/commonlibrary/toolchain/libc-test/tar_files.py +++ b/commonlibrary/toolchain/libc-test/tar_files.py @@ -30,14 +30,16 @@ def copyFiles(sourceDir, targetDir): if not os.path.isfile(sourceF): if os.path.isdir(sourceF): copyFiles(sourceF, targetF) - elif os.path.isfile(sourceF): - if os.path.exists(targetDir): - copyFileCounts += 1 - open(targetF, "wb").write(open(sourceF, "rb").read()) - elif not os.path.exists(targetDir): - os.makedirs(targetDir) - copyFileCounts += 1 - open(targetF, "wb").write(open(sourceF, "rb").read()) + continue + if os.path.exists(targetDir): + copyFileCounts += 1 + with open(targetF, "wb") as fp: + fp.write(open(sourceF, "rb").read()) + elif not os.path.exists(targetDir): + os.makedirs(targetDir) + copyFileCounts += 1 + with open(targetF, "wb") as fp: + fp.write(open(sourceF, "rb").read()) def make_targz_one_by_one(output_filename, source_dir): tar = tarfile.open(output_filename,"w") -- GitLab