axewater / sharewarez

SharewareZ transforms any game folder into a dynamic, searchable and shareable library.
145 stars 1 forks source link

Settings BASE_FOLDER_WINDOWS to Drive Installed on Breaks "Browse Folder Path" Button #35

Closed Bovive closed 2 months ago

Bovive commented 2 months ago

If hosting on Windows the drive to set as root for the "Browse Folder Path" buttons on the Scan Management pages is set in the config.py as:

Default: BASE_FOLDER_WINDOWS = os.getenv('BASE_FOLDER_WINDOWS', 'C:)

If the app is installed on the same drive that is set for BASE_FOLDER_WINDOWS it will show the app directory as root when clicking the "Browse Folder Path" button:

BrowseFolder1

If you click on a folder such as "venv" and then click the "Up" button it does take you to the drive root and functions correctly from there.

If the config is set to "/" it will show the root of the drive installed on:

BASE_FOLDER_WINDOWS = os.getenv('BASE_FOLDER_WINDOWS', '/:)

However, it will not function correctly. It will propagate the folder clicked on but will not show any subfolders.

Setting the option to a drive that the app is not installed on works fine.

If you change the BASE_FOLDER_WINDOWS to include a trailing '/' it works correctly and shows the drive root as expected:

BASE_FOLDER_WINDOWS = os.getenv('BASE_FOLDER_WINDOWS', 'C:/)

Long writeup to say to change the default config to be:

BASE_FOLDER_WINDOWS = os.getenv('BASE_FOLDER_WINDOWS', 'C:/)

instead of:

BASE_FOLDER_WINDOWS = os.getenv('BASE_FOLDER_WINDOWS', 'C:)

axewater commented 2 months ago

thanks for full explanation. and thanks for all your other submissions. I have some time this weekend, going to work on some of these. I will also have another go at cleaning up the routes.py file which is way too long.

Bovive commented 2 months ago

No problem. I think it is ok as is, just an update to the config instructions would be ok.

axewater commented 2 months ago

fixed as proposed .. thanks again!

Bovive commented 2 months ago

I must had been wrong, or it changed somehow. Now 'D:/' is not working. It just works like '/' and does not allow you to access any folders.

It appears to be trying a forward slash instead of a backslash. Here is the console output:

SS folder browser: Folder path: D:\Program Files (x86) SS folder browser: Access denied: D:\Program Files (x86) outside of base directory: D:/ 127.0.0.1 - - [17/Sep/2024 18:39:55] "GET /browse_folders_ss?path=Program%20Files%20(x86)/ HTTP/1.1" 403 -

Using 'D:\' for BASE_FOLDER_WINDOWS leads to an error:

SyntaxError: unterminated string literal (detected at line 26)

Stack Overflow Explanation

On the client side you make it work by doing this:

BASE_FOLDER_WINDOWS = os.getenv('BASE_FOLDER_WINDOWS', 'D:\\')

But that breaks scanning games.