updog icon indicating copy to clipboard operation
updog copied to clipboard

Serving "/" leads to miss the first letter of directory

Open Alveona opened this issue 4 years ago • 9 comments

As stated, when I try to run updog from root or if I do updog -d / or updog -d \/, all links in http interface seems to miss their first letter, like /etc becomes 0.0.0.0:9090/tc and so on

To reproduce:

  • updog -d /
  • open web interface
  • see what is a http link to /etc - it would be /tc
image

Alveona avatar Feb 21 '20 11:02 Alveona

The hiccup is in the get_relative_path method:

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

Replacing this function with os.path.relpath seems to fix things.

adeutscher avatar Feb 25 '20 05:02 adeutscher

The hiccup is in the get_relative_path method:

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

Replacing this function with os.path.relpath seems to fix things.

@adeutscher Could you test it on Windows as well? It seems to also fix #23

Alveona avatar Feb 29 '20 18:02 Alveona

On Windows (Python 3.7.6), everything appears to go alright:

  • Running python -m updog -d / shares C:\, and subdirectories can be navigated into.
  • Running python -m updog -d <relative local dir> also works.

adeutscher avatar Feb 29 '20 19:02 adeutscher

@Alveona Also just tested with a specific drive letter, more directly addressing #23.

Sharing with python -m updog -d T:\ successfully shares the T:\ drive on my Windows box and allows me to get into sub-directories.

adeutscher avatar Feb 29 '20 20:02 adeutscher

@adeutscher Sounds great! Waiting for @sc0tfree

Alveona avatar Feb 29 '20 22:02 Alveona

Hey @adeutscher and @Alveona - Thanks so much for working through this issue. I’m on a plane home from vacation and will dive in ASAP!

sc0tfree avatar Feb 29 '20 22:02 sc0tfree

dive in ASAP

How is it going?

vient avatar Jul 21 '20 09:07 vient

On Windows (Python 3.6.8 miniconda virtual env) with updog v1.4, still same error. i test some commands:

python -m updog -d d: -p 1234
python -m updog -d d:\ -p 1234
python -m updog -d d:\\ -p 1234
updog -d d: -p 1234
updog -d d:\ -p 1234
updog -d d:\\ -p 1234

when i want to go into the subfolder, it will miss the first letter of the subfolder's .

微信截图_20211014174609

zhizunbao84 avatar Oct 14 '21 09:10 zhizunbao84

but if i input the subfolder in the address bar of the broswer, everything is ok!

zhizunbao84 avatar Oct 14 '21 09:10 zhizunbao84