Avoid an error when attempting to remove previous data if it's not a
subdirectory - we were assuming that anything that wasn't named "latest"
or "latest_srcrev" had to be a directory. This makes it possible to have
a buildhistory_emit_pkghistory_append which writes additional files at
the recipe level.
Signed-off-by: Paul Eggleton <paul.eggleton@linux.intel.com>
Signed-off-by: Ross Burton <ross.burton@intel.com>
for item in os.listdir(pkghistdir):
if item != "latest" and item != "latest_srcrev":
if item not in packagelist:
- subdir = os.path.join(pkghistdir, item)
- for subfile in os.listdir(subdir):
- os.unlink(os.path.join(subdir, subfile))
- os.rmdir(subdir)
+ itempath = os.path.join(pkghistdir, item)
+ if os.path.isdir(itempath):
+ for subfile in os.listdir(itempath):
+ os.unlink(os.path.join(itempath, subfile))
+ os.rmdir(itempath)
+ else:
+ os.unlink(itempath)
rcpinfo = RecipeInfo(pn)
rcpinfo.pe = pe