server/sources/native.py
changeset 11127 6464edfa95bb
parent 11091 29aebc1edd29
parent 11122 fedcb69982af
child 11278 19fcce6dc6d1
equal deleted inserted replaced
11113:7f83e6a5acc3 11127:6464edfa95bb
    41 from six import PY2, text_type, binary_type, string_types
    41 from six import PY2, text_type, binary_type, string_types
    42 from six.moves import range, cPickle as pickle
    42 from six.moves import range, cPickle as pickle
    43 
    43 
    44 from logilab.common.decorators import cached, clear_cache
    44 from logilab.common.decorators import cached, clear_cache
    45 from logilab.common.configuration import Method
    45 from logilab.common.configuration import Method
    46 from logilab.common.shellutils import getlogin
    46 from logilab.common.shellutils import getlogin, ASK
    47 from logilab.database import get_db_helper, sqlgen
    47 from logilab.database import get_db_helper, sqlgen
    48 
    48 
    49 from yams.schema import role_name
    49 from yams.schema import role_name
    50 
    50 
    51 from cubicweb import (UnknownEid, AuthenticationError, ValidationError, Binary,
    51 from cubicweb import (UnknownEid, AuthenticationError, ValidationError, Binary,
  1735             self.logger.critical('Unsupported format in archive: %s', formatinfo)
  1735             self.logger.critical('Unsupported format in archive: %s', formatinfo)
  1736             raise ValueError('Unknown format in %s: %s' % (backupfile, formatinfo))
  1736             raise ValueError('Unknown format in %s: %s' % (backupfile, formatinfo))
  1737         tables = archive.read('tables.txt').splitlines()
  1737         tables = archive.read('tables.txt').splitlines()
  1738         sequences = archive.read('sequences.txt').splitlines()
  1738         sequences = archive.read('sequences.txt').splitlines()
  1739         numranges = archive.read('numranges.txt').splitlines()
  1739         numranges = archive.read('numranges.txt').splitlines()
  1740         file_versions = self._parse_versions(archive.read('versions.txt'))
  1740         archive_versions = self._parse_versions(archive.read('versions.txt'))
  1741         versions = set(self._get_versions())
  1741         db_versions = set(self._get_versions())
  1742         if file_versions != versions:
  1742         if archive_versions != db_versions:
  1743             self.logger.critical('Unable to restore : versions do not match')
  1743             self.logger.critical('Restore warning: versions do not match')
  1744             self.logger.critical('Expected:\n%s', '\n'.join('%s : %s' % (cube, ver)
  1744             new_cubes = db_versions - archive_versions
  1745                                                             for cube, ver in sorted(versions)))
  1745             if new_cubes:
  1746             self.logger.critical('Found:\n%s', '\n'.join('%s : %s' % (cube, ver)
  1746                 self.logger.critical('In the db:\n%s', '\n'.join('%s: %s' % (cube, ver)
  1747                                                          for cube, ver in sorted(file_versions)))
  1747                                                             for cube, ver in sorted(new_cubes)))
  1748             raise ValueError('Unable to restore : versions do not match')
  1748             old_cubes = archive_versions - db_versions
       
  1749             if old_cubes:
       
  1750                 self.logger.critical('In the archive:\n%s', '\n'.join('%s: %s' % (cube, ver)
       
  1751                                                             for cube, ver in sorted(old_cubes)))
       
  1752             if not ASK.confirm('Versions mismatch: continue anyway ?', False):
       
  1753                 raise ValueError('Unable to restore: versions do not match')
  1749         table_chunks = {}
  1754         table_chunks = {}
  1750         for name in archive.namelist():
  1755         for name in archive.namelist():
  1751             if not name.startswith('tables/'):
  1756             if not name.startswith('tables/'):
  1752                 continue
  1757                 continue
  1753             filename = basename(name)
  1758             filename = basename(name)