From 63b997a4ed078a778339be0244eb3521eeef5cb5 Mon Sep 17 00:00:00 2001 From: Olivier Dony Date: Tue, 2 May 2017 13:03:21 +0200 Subject: [PATCH] [FIX] runbot: make checkout safer wrt addons layout Avoid errors/crash when the server/addons directory in the build branch contains symlinks. Exhibited by e.g. odoo/odoo#16720 --- runbot/runbot.py | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/runbot/runbot.py b/runbot/runbot.py index f637262a..93e4addd 100644 --- a/runbot/runbot.py +++ b/runbot/runbot.py @@ -851,12 +851,16 @@ class runbot_build(osv.osv): # move all addons to server addons path for module in uniq_list(glob.glob(build._path('addons/*')) + modules_to_move): basename = os.path.basename(module) - if os.path.exists(build._server('addons', basename)): + addon_path = build._server('addons', basename) + if os.path.exists(addon_path): build._log( 'Building environment', 'You have duplicate modules in your branches "%s"' % basename ) - shutil.rmtree(build._server('addons', basename)) + if os.path.islink(addon_path) or os.path.isfile(addon_path): + os.remove(addon_path) + else: + shutil.rmtree(addon_path) shutil.move(module, build._server('addons')) available_modules = [