Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Relative path correction #18

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 2 additions & 7 deletions updog/utils/path.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,11 +15,6 @@ def is_valid_upload_path(path, base_directory):
in_question = os.path.abspath(path)
return os.path.commonprefix([base_directory, in_question]) == base_directory


def get_relative_path(file_path, base_directory):
return file_path.split(os.path.commonprefix([base_directory, file_path]))[1][1:]


def human_readable_file_size(size):
# Taken from Dipen Panchasara
# https://stackoverflow.com/questions/1094841/reusable-library-to-get-human-readable-version-of-file-size
Expand All @@ -40,7 +35,7 @@ def process_files(directory_files, base_directory):
files.append({
'name': file.name,
'is_dir': file.is_dir(),
'rel_path': get_relative_path(file.path, base_directory),
'rel_path': os.path.relpath(file.path, base_directory),
'size': size,
'size_sort': size_sort,
'last_modified': ctime(file.stat().st_mtime),
Expand All @@ -50,7 +45,7 @@ def process_files(directory_files, base_directory):


def get_parent_directory(path, base_directory):
difference = get_relative_path(path, base_directory)
difference = os.path.relpath(path, base_directory)
difference_fields = difference.split('/')
if len(difference_fields) == 1:
return ''
Expand Down