From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mga14.intel.com (mga14.intel.com [192.55.52.115]) by mx.groups.io with SMTP id smtpd.web11.3662.1627472731044636611 for ; Wed, 28 Jul 2021 04:45:31 -0700 Authentication-Results: mx.groups.io; dkim=missing; spf=pass (domain: intel.com, ip: 192.55.52.115, mailfrom: bob.c.feng@intel.com) X-IronPort-AV: E=McAfee;i="6200,9189,10058"; a="212372626" X-IronPort-AV: E=Sophos;i="5.84,276,1620716400"; d="scan'208";a="212372626" Received: from fmsmga001.fm.intel.com ([10.253.24.23]) by fmsmga103.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 28 Jul 2021 04:45:30 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.84,276,1620716400"; d="scan'208";a="580708616" Received: from shwdepsi1121.ccr.corp.intel.com ([10.239.158.137]) by fmsmga001.fm.intel.com with ESMTP; 28 Jul 2021 04:45:29 -0700 From: "Bob Feng" To: devel@edk2.groups.io Cc: Liming Gao , Yuwei Chen Subject: [Patch] BaseTools: use shutil.copyfile instead shutil.copy2 Date: Wed, 28 Jul 2021 19:45:23 +0800 Message-Id: <20210728114523.687-1-bob.c.feng@intel.com> X-Mailer: git-send-email 2.29.1.windows.1 MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable In Split tool, the copy file actions only need to copy file content but not need to copy file metadata. copy2() copies the file metadata that causes split unit test failed under edk2-basetools CI environment. So this patch changes the call of copy2() to copyfile(). Signed-off-by: Bob Feng Cc: Liming Gao Cc: Yuwei Chen --- BaseTools/Source/Python/Split/Split.py | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/BaseTools/Source/Python/Split/Split.py b/BaseTools/Source/Pyth= on/Split/Split.py index e223a72a94..e70d5c22c4 100644 --- a/BaseTools/Source/Python/Split/Split.py +++ b/BaseTools/Source/Python/Split/Split.py @@ -146,18 +146,18 @@ def splitFile(inputfile, position, outputdir=3DNone, = outputfile1=3DNone, outputfile2 logger.error("Can't make dir: %s" % outputfolder)=0D raise(e)=0D =0D if position <=3D 0:=0D if outputfile2 !=3D os.path.abspath(inputfile):=0D - shutil.copy2(os.path.abspath(inputfile), outputfile2)=0D + shutil.copyfile(os.path.abspath(inputfile), outputfile2)=0D with open(outputfile1, "wb") as fout:=0D fout.write(b'')=0D else:=0D inputfilesize =3D getFileSize(inputfile)=0D if position >=3D inputfilesize:=0D if outputfile1 !=3D os.path.abspath(inputfile):=0D - shutil.copy2(os.path.abspath(inputfile), outputfile1)=0D + shutil.copyfile(os.path.abspath(inputfile), outputfile1)=0D with open(outputfile2, "wb") as fout:=0D fout.write(b'')=0D else:=0D try:=0D tempdir =3D tempfile.mkdtemp()=0D @@ -169,12 +169,12 @@ def splitFile(inputfile, position, outputdir=3DNone, = outputfile1=3DNone, outputfile2 fout1.write(content1)=0D =0D content2 =3D fin.read(inputfilesize - position)=0D with open(tempfile2, "wb") as fout2:=0D fout2.write(content2)=0D - shutil.copy2(tempfile1, outputfile1)=0D - shutil.copy2(tempfile2, outputfile2)=0D + shutil.copyfile(tempfile1, outputfile1)=0D + shutil.copyfile(tempfile2, outputfile2)=0D except Exception as e:=0D logger.error("Split file failed")=0D raise(e)=0D finally:=0D if os.path.exists(tempdir):=0D --=20 2.29.1.windows.1