Changeset - 3648a2b2e17a
[Not reviewed]
default
0 3 0
Marcin Kuzminski - 12 years ago 2013-06-10 14:54:37
marcin@python-works.com
Grafted from: cc975d543131
accept that repos are read-only - very convenient for testing.

Users are prompt to confirm they want to use read only paths.
org author: Mads Kiilerich
3 files changed with 25 insertions and 12 deletions:
0 comments (0 inline, 0 general)
rhodecode/lib/db_manage.py
Show inline comments
 
@@ -614,16 +614,24 @@ class DbManage(object):
 
        # check proper dir
 
        if not os.path.isdir(path):
 
            path_ok = False
 
            log.error('Given path %s is not a valid directory' % path)
 
            log.error('Given path %s is not a valid directory' % (path,))
 

	
 
        elif not os.path.isabs(path):
 
            path_ok = False
 
            log.error('Given path %s is not an absolute path' % path)
 
            log.error('Given path %s is not an absolute path' % (path,))
 

	
 
        # check if path is at least readable.
 
        if not os.access(path, os.R_OK):
 
            path_ok = False
 
            log.error('Given path %s is not readable' % (path,))
 

	
 
        # check write access
 
        # check write access, warn user about non writeable paths
 
        elif not os.access(path, os.W_OK) and path_ok:
 
            path_ok = False
 
            log.error('No write permission to given path %s' % path)
 
            log.warn('No write permission to given path %s' % (path,))
 
            if not ask_ok('Given path %s is not writeable, do you want to '
 
                          'continue with read only mode ? [y/n]' % (path,)):
 
                log.error('Canceled by user')
 
                sys.exit(-1)
 

	
 
        if retries == 0:
 
            sys.exit('max retries reached')
 
@@ -635,7 +643,7 @@ class DbManage(object):
 

	
 
        if real_path != os.path.normpath(path):
 
            if not ask_ok(('Path looks like a symlink, Rhodecode will store '
 
                           'given path as %s ? [y/n]') % (real_path)):
 
                           'given path as %s ? [y/n]') % (real_path,)):
 
                log.error('Canceled by user')
 
                sys.exit(-1)
 

	
rhodecode/lib/utils.py
Show inline comments
 
@@ -201,9 +201,11 @@ def get_filesystem_repos(path, recursive
 
    log.debug('now scanning in %s location recursive:%s...' % (path, recursive))
 

	
 
    def _get_repos(p):
 
        if not os.access(p, os.R_OK) or not os.access(p, os.X_OK):
 
            log.warn('ignoring repo path without access: %s', p)
 
            return
 
        if not os.access(p, os.W_OK):
 
            log.warn('ignoring repo path without write access: %s', p)
 
            return
 
            log.warn('repo path without write access: %s', p)
 
        for dirpath in os.listdir(p):
 
            if os.path.isfile(os.path.join(p, dirpath)):
 
                continue
rhodecode/model/scm.py
Show inline comments
 
@@ -744,9 +744,12 @@ class ScmModel(BaseModel):
 

	
 
            if _rhodecode_hook or force_create:
 
                log.debug('writing %s hook file !' % (h_type,))
 
                with open(_hook_file, 'wb') as f:
 
                    tmpl = tmpl.replace('_TMPL_', rhodecode.__version__)
 
                    f.write(tmpl)
 
                os.chmod(_hook_file, 0755)
 
                try:
 
                    with open(_hook_file, 'wb') as f:
 
                        tmpl = tmpl.replace('_TMPL_', rhodecode.__version__)
 
                        f.write(tmpl)
 
                    os.chmod(_hook_file, 0755)
 
                except IOError, e:
 
                    log.error('error writing %s: %s' % (_hook_file, e))
 
            else:
 
                log.debug('skipping writing hook file')
0 comments (0 inline, 0 general)