@tools.ormcache()
def _filestore(self, cr, uid, context=None):
- return os.path.join(tools.config['data_dir'], 'filestore', cr.dbname)
+ return tools.config.filestore(cr.dbname)
# 'data' field implementation
def _full_path(self, cr, uid, location, path):
with closing(db.cursor()) as cr:
cr.autocommit(True) # avoid transaction block
cr.execute("""CREATE DATABASE "%s" ENCODING 'unicode' TEMPLATE "%s" """ % (db_name, db_original_name))
+
+ from_fs = openerp.tools.config.filestore(db_original_name)
+ to_fs = openerp.tools.config.filestore(db_name)
+ if os.path.exists(from_fs) and not os.path.exists(to_fs):
+ shutil.copy(from_fs, to_fs)
return True
def exp_get_progress(id):
raise Exception("Couldn't drop database %s: %s" % (db_name, e))
else:
_logger.info('DROP DB: %s', db_name)
+
+ fs = openerp.tools.config.filestore(db_name)
+ if os.path.exists(fs):
+ shutil.rmtree(fs)
return True
def _set_pg_password_in_environment(func):
except Exception, e:
_logger.error('RENAME DB: %s -> %s failed:\n%s', old_name, new_name, e)
raise Exception("Couldn't rename database %s to %s: %s" % (old_name, new_name, e))
+
+ old_fs = openerp.tools.config.filestore(old_name)
+ new_fs = openerp.tools.config.filestore(new_name)
+ if os.path.exists(old_fs) and not os.path.exists(new_fs):
+ shutil.move(old_fs, new_fs)
return True
@openerp.tools.mute_logger('openerp.sql_db')