Skip to content

client.getQuota() does not return the correct quota #331

@pasenau

Description

@pasenau

Describe the bug
client.getQuota() returns two numbers that are not the real available or used quota of the user. These two numbers are from two separated entries of the PROPFIND command issued inside the getQuota() call.

To Reproduce
Steps to reproduce the behavior:

  1. create a user with a specific quota, an fill in some files and folders
  2. get the quota of that user:
const ncc = require( 'nextcloud-node-client');
const server_data = { basicAuth: { username: auth.username, password: auth.password }, url: server_url, };
const server = new ncc.Server( server_data );
const client = new ncc.Client( server);
const user_quota = await client.getQuota();

Correction
after looking into the code:

  public async getQuota(): Promise<IQuota> {
    log.debug("getQuota");
    const requestInit: RequestInit = {
      method: "PROPFIND",
    };

    const response: Response = await this.getHttpResponse(this.webDAVUrl + "/", requestInit, [207], { description: "Client get quota" });
    ...

In requestInit it seems that headers: new node_fetch_1.Headers({ "Depth": "0" }), is missing.
With

    const requestInit: RequestInit = {
      method: "PROPFIND",
      headers: new node_fetch_1.Headers({ "Depth": "0" }),
    };

it returns the expected result.
client_patch.txt

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions