Patchwork [1/1] image.py: check file exists before deleting

login
register
mail settings
Submitter Laurentiu Palcu
Date March 28, 2014, 1:07 p.m.
Message ID <52dc7313677c1fe5e609d0e38d60c7f842e94d55.1396012002.git.laurentiu.palcu@intel.com>
Download mbox | patch
Permalink /patch/69575/
State New
Headers show

Comments

Laurentiu Palcu - March 28, 2014, 1:07 p.m.
When RM_OLD_IMAGE = "1", we delete old images but we didn't check they
actually exist...

[YOCTO #6029]

Signed-off-by: Laurentiu Palcu <laurentiu.palcu@intel.com>
---
 meta/lib/oe/image.py |    3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

Patch

diff --git a/meta/lib/oe/image.py b/meta/lib/oe/image.py
index a03b73e..c9b9033 100644
--- a/meta/lib/oe/image.py
+++ b/meta/lib/oe/image.py
@@ -192,7 +192,8 @@  class Image(ImageDepGraph):
                 if img.find(self.d.getVar('IMAGE_LINK_NAME', True)) == 0:
                     img = os.path.join(deploy_dir, img)
                     if os.path.islink(img):
-                        if self.d.getVar('RM_OLD_IMAGE', True) == "1":
+                        if self.d.getVar('RM_OLD_IMAGE', True) == "1" and \
+                                os.path.exists(os.path.realpath(img)):
                             os.remove(os.path.realpath(img))
 
                         os.remove(img)