* [PATCH v2 0/1] BaseTools: Add more parameter checking for CopyFileOnChange()
@ 2019-09-18 3:21 Steven Shi
2019-09-18 3:21 ` [PATCH v2 1/1] " Steven Shi
0 siblings, 1 reply; 3+ messages in thread
From: Steven Shi @ 2019-09-18 3:21 UTC (permalink / raw)
To: devel; +Cc: liming.gao, bob.c.feng
This patch is to add directory input parameter type checking and error message output
for method CopyFileOnChange.
V2:
Remove the redundant os.path.exists checking for better performance
V1:
Initial patch
Steven Shi (1):
BaseTools: Add more parameter checking for CopyFileOnChange()
BaseTools/Source/Python/Common/Misc.py | 3 ++-
1 file changed, 2 insertions(+), 1 deletion(-)
--
2.17.1.windows.2
^ permalink raw reply [flat|nested] 3+ messages in thread
* [PATCH v2 1/1] BaseTools: Add more parameter checking for CopyFileOnChange()
2019-09-18 3:21 [PATCH v2 0/1] BaseTools: Add more parameter checking for CopyFileOnChange() Steven Shi
@ 2019-09-18 3:21 ` Steven Shi
2019-09-18 8:07 ` [edk2-devel] " Bob Feng
0 siblings, 1 reply; 3+ messages in thread
From: Steven Shi @ 2019-09-18 3:21 UTC (permalink / raw)
To: devel; +Cc: liming.gao, bob.c.feng
BZ: https://bugzilla.tianocore.org/show_bug.cgi?id=2193
The current CopyFileOnChange() method in Misc.py does not
accept the input SrcFile parameter as a dir, but the method
does not check the SrcFile is dir or not. This patch is to
add more input parameter type checking and error message output
for method CopyFileOnChange.
Cc: Liming Gao <liming.gao@intel.com>
Cc: Bob Feng <bob.c.feng@intel.com>
Signed-off-by: Steven Shi <steven.shi@intel.com>
---
BaseTools/Source/Python/Common/Misc.py | 3 ++-
1 file changed, 2 insertions(+), 1 deletion(-)
diff --git a/BaseTools/Source/Python/Common/Misc.py b/BaseTools/Source/Python/Common/Misc.py
index 714eb840ea..a488536cb4 100755
--- a/BaseTools/Source/Python/Common/Misc.py
+++ b/BaseTools/Source/Python/Common/Misc.py
@@ -536,7 +536,8 @@ def CopyFileOnChange(SrcFile, Dst, FileLock=None):
SrcFile = LongFilePath(SrcFile)
Dst = LongFilePath(Dst)
- if not os.path.exists(SrcFile):
+ if os.path.isdir(SrcFile):
+ EdkLogger.error(None, FILE_COPY_FAILURE, ExtraData='CopyFileOnChange SrcFile is a dir, not a file: %s' % SrcFile)
return False
if os.path.isdir(Dst):
--
2.17.1.windows.2
^ permalink raw reply related [flat|nested] 3+ messages in thread
* Re: [edk2-devel] [PATCH v2 1/1] BaseTools: Add more parameter checking for CopyFileOnChange()
2019-09-18 3:21 ` [PATCH v2 1/1] " Steven Shi
@ 2019-09-18 8:07 ` Bob Feng
0 siblings, 0 replies; 3+ messages in thread
From: Bob Feng @ 2019-09-18 8:07 UTC (permalink / raw)
To: devel@edk2.groups.io, Shi, Steven; +Cc: Gao, Liming
Reviewed-by: Bob Feng <bob.c.feng@intel.com>
-----Original Message-----
From: devel@edk2.groups.io [mailto:devel@edk2.groups.io] On Behalf Of Steven Shi
Sent: Wednesday, September 18, 2019 11:21 AM
To: devel@edk2.groups.io
Cc: Gao, Liming <liming.gao@intel.com>; Feng, Bob C <bob.c.feng@intel.com>
Subject: [edk2-devel] [PATCH v2 1/1] BaseTools: Add more parameter checking for CopyFileOnChange()
BZ: https://bugzilla.tianocore.org/show_bug.cgi?id=2193
The current CopyFileOnChange() method in Misc.py does not accept the input SrcFile parameter as a dir, but the method does not check the SrcFile is dir or not. This patch is to add more input parameter type checking and error message output for method CopyFileOnChange.
Cc: Liming Gao <liming.gao@intel.com>
Cc: Bob Feng <bob.c.feng@intel.com>
Signed-off-by: Steven Shi <steven.shi@intel.com>
---
BaseTools/Source/Python/Common/Misc.py | 3 ++-
1 file changed, 2 insertions(+), 1 deletion(-)
diff --git a/BaseTools/Source/Python/Common/Misc.py b/BaseTools/Source/Python/Common/Misc.py
index 714eb840ea..a488536cb4 100755
--- a/BaseTools/Source/Python/Common/Misc.py
+++ b/BaseTools/Source/Python/Common/Misc.py
@@ -536,7 +536,8 @@ def CopyFileOnChange(SrcFile, Dst, FileLock=None):
SrcFile = LongFilePath(SrcFile)
Dst = LongFilePath(Dst)
- if not os.path.exists(SrcFile):
+ if os.path.isdir(SrcFile):
+ EdkLogger.error(None, FILE_COPY_FAILURE,
+ ExtraData='CopyFileOnChange SrcFile is a dir, not a file: %s' %
+ SrcFile)
return False
if os.path.isdir(Dst):
--
2.17.1.windows.2
^ permalink raw reply related [flat|nested] 3+ messages in thread
end of thread, other threads:[~2019-09-18 8:07 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2019-09-18 3:21 [PATCH v2 0/1] BaseTools: Add more parameter checking for CopyFileOnChange() Steven Shi
2019-09-18 3:21 ` [PATCH v2 1/1] " Steven Shi
2019-09-18 8:07 ` [edk2-devel] " Bob Feng
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox