]> git.proxmox.com Git - mirror_edk2.git/commitdiff
BaseTools: use shutil.copyfile instead shutil.copy2
authorBob Feng <bob.c.feng@intel.com>
Wed, 28 Jul 2021 11:45:23 +0000 (19:45 +0800)
committermergify[bot] <37929162+mergify[bot]@users.noreply.github.com>
Mon, 2 Aug 2021 03:52:15 +0000 (03:52 +0000)
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 <bob.c.feng@intel.com>
Cc: Liming Gao <gaoliming@byosoft.com.cn>
Cc: Yuwei Chen <yuwei.chen@intel.com>
Reviewed-by: Yuwei Chen <yuwei.chen@intel.com>
BaseTools/Source/Python/Split/Split.py

index e223a72a94e14dcedd61b1ff925226d79930f304..e70d5c22c4681fe621b4c0c40e335639b5280bca 100644 (file)
@@ -148,14 +148,14 @@ def splitFile(inputfile, position, outputdir=None, outputfile1=None, outputfile2
 \r
     if position <= 0:\r
         if outputfile2 != os.path.abspath(inputfile):\r
-            shutil.copy2(os.path.abspath(inputfile), outputfile2)\r
+            shutil.copyfile(os.path.abspath(inputfile), outputfile2)\r
         with open(outputfile1, "wb") as fout:\r
             fout.write(b'')\r
     else:\r
         inputfilesize = getFileSize(inputfile)\r
         if position >= inputfilesize:\r
             if outputfile1 != os.path.abspath(inputfile):\r
-                shutil.copy2(os.path.abspath(inputfile), outputfile1)\r
+                shutil.copyfile(os.path.abspath(inputfile), outputfile1)\r
             with open(outputfile2, "wb") as fout:\r
                 fout.write(b'')\r
         else:\r
@@ -171,8 +171,8 @@ def splitFile(inputfile, position, outputdir=None, outputfile1=None, outputfile2
                     content2 = fin.read(inputfilesize - position)\r
                     with open(tempfile2, "wb") as fout2:\r
                         fout2.write(content2)\r
-                shutil.copy2(tempfile1, outputfile1)\r
-                shutil.copy2(tempfile2, outputfile2)\r
+                shutil.copyfile(tempfile1, outputfile1)\r
+                shutil.copyfile(tempfile2, outputfile2)\r
             except Exception as e:\r
                 logger.error("Split file failed")\r
                 raise(e)\r