Can't upload in root of a Library. "p invalid" after upgrade to 8.0.7

Since we upgrade from seafile 6.3 to 8.0.7 we have a major issue

When a user visit the root folder of a shared Library, he can’t upload a file at root of the library. There is an error p invalid

As you can see, the variable p=& is empty, it should be p=/ the slash for the root is missing.

About “new file” using only office, creation works but the file doesn’t appear without a refresh

There is an easy workaround for theses 2 issues (probably same cause) by just creating and visiting (or just visiting if there is already a subfolder) a subfolder and come back to the root then it works the path become p=/

The error is for each user, once the users visited a subfolder it seems to not happen anymore.

Despite the easy workaround, it’s a critical issue for us and our users, every users failed to upload and doesn’t understand why

Is there a way to fix that easily ? we can’t wait for a patch

How to reproduce :

  • create a group toto-group with the API
  • create a Library Toto group
  • Share the library with the group with read/write access
  • add you user to this group
  • access and upload in the library

I have created a github ticket

This is code of class UploadLinkView in 6.3

    parent_dir = request.GET.get('p', '/')
    dir_id = seafile_api.get_dir_id_by_path(repo_id, parent_dir)
    if not dir_id:
        error_msg = 'Folder %s not found.' % parent_dir
        return api_error(status.HTTP_404_NOT_FOUND, error_msg)

same code in 8.0.7

    parent_dir = request.GET.get('p', '/')
    if not parent_dir:
        error_msg = 'p invalid.'
        return api_error(status.HTTP_400_BAD_REQUEST, error_msg)

    dir_id = seafile_api.get_dir_id_by_path(repo_id, parent_dir)
    if not dir_id:
        error_msg = 'Folder %s not found.' % parent_dir
        return api_error(status.HTTP_404_NOT_FOUND, error_msg)

I don’t know why this check if not parent_dir: was added but it’s not working. The front is sending p but empty, so the default / request.GET.get('p', '/') here is not applied

More info in the github ticket

There is a workaround. Add the library title in the URL /library/{id}/title

So the discussion here could be considered as solved, but the front react code have to be reviewed and fixed by a contributor

How to reproduce the bug

You can reproduce it on https://demo.seafile.com/demo

Create a library
Go in your library

For exemple I have created

https://demo.seafile.com/library/1a80750c-5d57-4360-a645-946a971e47bf/GitHubTicket5035/

Before we was able to share link with just library ID, it’s what our user did.

https://demo.seafile.com/library/1a80750c-5d57-4360-a645-946a971e47bf/

So if you access your library with just the repository ID without the title of the library at the end (above link) you will have a lot of issue

The webapp doesn’t setup the path variable correctly, resultating in p and parent_dir empty in every call

go on https://demo.seafile.com/library/1a80750c-5d57-4360-a645-946a971e47bf/

try to create a new file "test.txt". nothing appears, you have to refresh your browser
try to upload a file, you will have an error "parent_dir invalid."

Just because there is no title in the path, if you add the title, or navigate in a subfolder and them come back(same result it add the folder to the url) it works

So there is an easy workaround. But there is plenty of users or even apps which works just with library ID to share link to a library, and for thoses using just the ID like us, it result in a broken UI for all our users after they clicked on the shared link.