log move/remove errors during update
This commit is contained in:
parent
de875a6cb4
commit
1412cb4e39
1 changed files with 24 additions and 7 deletions
|
@ -155,7 +155,8 @@ def install():
|
||||||
old_version = current_version('openmedialibrary')
|
old_version = current_version('openmedialibrary')
|
||||||
new_version = release['modules']['openmedialibrary']['version']
|
new_version = release['modules']['openmedialibrary']['version']
|
||||||
if verify(release) and old_version < new_version:
|
if verify(release) and old_version < new_version:
|
||||||
os.chdir(os.path.dirname(settings.base_dir))
|
base = os.path.dirname(settings.base_dir)
|
||||||
|
os.chdir(base)
|
||||||
platform = get_platform()
|
platform = get_platform()
|
||||||
for module in release['modules']:
|
for module in release['modules']:
|
||||||
if release['modules'][module].get('platform', platform) == platform and \
|
if release['modules'][module].get('platform', platform) == platform and \
|
||||||
|
@ -169,14 +170,16 @@ def install():
|
||||||
tar = tarfile.open(module_tar)
|
tar = tarfile.open(module_tar)
|
||||||
tar.extractall()
|
tar.extractall()
|
||||||
tar.close()
|
tar.close()
|
||||||
os.chdir(os.path.dirname(settings.base_dir))
|
os.chdir(base)
|
||||||
module_old = '%s_old' % module
|
module_old = '%s_old' % module
|
||||||
if os.path.exists(module):
|
|
||||||
shutil.move(module, module_old)
|
|
||||||
shutil.move(os.path.join(new, module), module)
|
|
||||||
if os.path.exists(module_old):
|
if os.path.exists(module_old):
|
||||||
shutil.rmtree(module_old)
|
rmtree(module_old)
|
||||||
shutil.rmtree(new)
|
if os.path.exists(module):
|
||||||
|
move(module, module_old)
|
||||||
|
move(os.path.join(new, module), module)
|
||||||
|
if os.path.exists(module_old):
|
||||||
|
rmtree(module_old)
|
||||||
|
rmtree(new)
|
||||||
else:
|
else:
|
||||||
if os.path.exists(module_tar):
|
if os.path.exists(module_tar):
|
||||||
os.unlink(module_tar)
|
os.unlink(module_tar)
|
||||||
|
@ -189,6 +192,20 @@ def install():
|
||||||
return True
|
return True
|
||||||
return True
|
return True
|
||||||
|
|
||||||
|
def move(src, dst):
|
||||||
|
try:
|
||||||
|
shutil.move(src, dst)
|
||||||
|
except:
|
||||||
|
logger.debug('failed to move %s to %s', src, dst)
|
||||||
|
raise
|
||||||
|
|
||||||
|
def rmtree(path):
|
||||||
|
try:
|
||||||
|
shutil.rmtree(path)
|
||||||
|
except:
|
||||||
|
logger.debug('failed to remove %s', path)
|
||||||
|
raise
|
||||||
|
|
||||||
def update_available():
|
def update_available():
|
||||||
db_version = settings.server.get('db_version', 0)
|
db_version = settings.server.get('db_version', 0)
|
||||||
if db_version < settings.DB_VERSION:
|
if db_version < settings.DB_VERSION:
|
||||||
|
|
Loading…
Reference in a new issue