From: "Yuwei Chen" <yuwei.chen@intel.com>
To: "Feng, Bob C" <bob.c.feng@intel.com>,
"devel@edk2.groups.io" <devel@edk2.groups.io>
Cc: Liming Gao <gaoliming@byosoft.com.cn>
Subject: Re: [Patch] BaseTools: use shutil.copyfile instead shutil.copy2
Date: Mon, 2 Aug 2021 00:56:01 +0000 [thread overview]
Message-ID: <DM5PR11MB1594DE8DAAEED68BA5ABD6F196EF9@DM5PR11MB1594.namprd11.prod.outlook.com> (raw)
In-Reply-To: <20210728114523.687-1-bob.c.feng@intel.com>
Reviewed-by: Yuwei Chen<yuwei.chen@intel.com>
> -----Original Message-----
> From: Feng, Bob C <bob.c.feng@intel.com>
> Sent: Wednesday, July 28, 2021 7:45 PM
> To: devel@edk2.groups.io
> Cc: Liming Gao <gaoliming@byosoft.com.cn>; Chen, Christine
> <yuwei.chen@intel.com>
> Subject: [Patch] BaseTools: use shutil.copyfile instead shutil.copy2
>
> 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>
> ---
> 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/Python/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=None,
> outputfile1=None, outputfile2
> logger.error("Can't make dir: %s" % outputfolder) raise(e) if
> position <= 0: if outputfile2 != os.path.abspath(inputfile):-
> shutil.copy2(os.path.abspath(inputfile), outputfile2)+
> shutil.copyfile(os.path.abspath(inputfile), outputfile2) with
> open(outputfile1, "wb") as fout: fout.write(b'') else:
> inputfilesize = getFileSize(inputfile) if position >= inputfilesize: if
> outputfile1 != os.path.abspath(inputfile):-
> shutil.copy2(os.path.abspath(inputfile), outputfile1)+
> shutil.copyfile(os.path.abspath(inputfile), outputfile1) with
> open(outputfile2, "wb") as fout: fout.write(b'') else: try:
> tempdir = tempfile.mkdtemp()@@ -169,12 +169,12 @@ def splitFile(inputfile,
> position, outputdir=None, outputfile1=None, outputfile2
> fout1.write(content1) content2 =
> fin.read(inputfilesize - position) with open(tempfile2, "wb") as
> fout2: fout2.write(content2)- shutil.copy2(tempfile1,
> outputfile1)- shutil.copy2(tempfile2, outputfile2)+
> shutil.copyfile(tempfile1, outputfile1)+ shutil.copyfile(tempfile2,
> outputfile2) except Exception as e: logger.error("Split file
> failed") raise(e) finally: if os.path.exists(tempdir):--
> 2.29.1.windows.1
next prev parent reply other threads:[~2021-08-02 0:56 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2021-07-28 11:45 [Patch] BaseTools: use shutil.copyfile instead shutil.copy2 Bob Feng
2021-08-02 0:56 ` Yuwei Chen [this message]
2021-08-09 8:15 ` [edk2-devel] " Philippe Mathieu-Daudé
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-list from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=DM5PR11MB1594DE8DAAEED68BA5ABD6F196EF9@DM5PR11MB1594.namprd11.prod.outlook.com \
--to=devel@edk2.groups.io \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox