Commit 04cdc63d authored by Michal Čihař's avatar Michal Čihař

Use / as path separator

Always use / as path separator even on Windows, see issue #1067
Signed-off-by: default avatarMichal Čihař <michal@cihar.com>
parent 0b4da71c
......@@ -33,7 +33,7 @@ from django.utils.text import slugify
from weblate.trans.models import SubProject, Project
from weblate.trans.formats import FILE_FORMATS
from weblate.trans.util import is_repo_link
from weblate.trans.util import is_repo_link, path_separator
from weblate.trans.vcs import GitRepository
from weblate.logger import LOGGER
......@@ -183,7 +183,9 @@ class Command(BaseCommand):
Returns relative path of matched files.
'''
matches = glob(os.path.join(repo, self.filemask))
return [f.replace(repo, '').strip('/') for f in matches]
return [
path_separator(f.replace(repo, '')).strip('/') for f in matches
]
def get_matching_subprojects(self, repo):
'''
......
......@@ -43,7 +43,7 @@ from weblate.trans.filelock import FileLock
from weblate.trans.fields import RegexField
from weblate.trans.site import get_site_url
from weblate.trans.util import (
is_repo_link, cleanup_repo_url, cleanup_path, report_error,
is_repo_link, cleanup_repo_url, cleanup_path, report_error, path_separator,
)
from weblate.trans.signals import (
vcs_post_push, vcs_post_update, translation_post_add
......@@ -949,10 +949,10 @@ class SubProject(models.Model, PercentMixin, URLMixin, PathMixin):
def get_mask_matches(self):
"""Returns files matching current mask."""
prefix = os.path.join(self.get_path(), '')
prefix = path_separator(os.path.join(self.get_path(), ''))
matches = set()
for filename in glob(os.path.join(self.get_path(), self.filemask)):
path = filename.replace(prefix, '')
path = path_separator(filename).replace(prefix, '')
code = self.get_lang_code(path)
if re.match(self.language_regex, code):
matches.add(path)
......
......@@ -296,3 +296,10 @@ def render(request, template, context=None, status=None):
if 'project' in context:
context['description'] = get_project_description(context['project'])
return django_render(request, template, context, status=status)
def path_separator(path):
"""Always use / as path separator for consistency"""
if os.path.sep != '/':
return path.replace(os.path.sep, '/')
return path
......@@ -36,7 +36,9 @@ from dateutil import parser
import six
from six.moves.configparser import RawConfigParser
from weblate.trans.util import get_clean_env, add_configuration_error
from weblate.trans.util import (
get_clean_env, add_configuration_error, path_separator
)
from weblate.trans.ssh import ssh_file, SSH_WRAPPER
from weblate import appsettings
......@@ -130,8 +132,12 @@ class Repository(object):
Resolves any symlinks in the path.
"""
# Resolve symlinks first
real_path = os.path.realpath(os.path.join(self.path, path))
repository_path = os.path.realpath(self.path)
real_path = path_separator(
os.path.realpath(os.path.join(self.path, path))
)
repository_path = path_separator(
os.path.realpath(self.path)
)
if not real_path.startswith(repository_path):
raise ValueError('Too many symlinks or link outside tree')
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment