files:transfer-ownership fails with "not enough free space" when the target quota is unlimited

Open Beginner friendly
#64,019 1 comment 1 reaction 0 assignees View on GitHub

Nobody has claimed this yet.

Assessment

Difficulty
2/5
Estimated time
1-3 hours
Newbie friendliness
76/100
Issue type
Bug
Clarity
Clearly specified
Activity status
Active
Tech stack
php
Domain
backend

Research direction

Start in apps/files/lib/Service/OwnershipTransferService.php, especially OwnershipTransferService::analyse() around the free-space check, and trace the quota values described in the issue. Reproduce with an object store as primary storage and an unlimited destination quota using occ files:transfer-ownership; done means a non-empty transfer no longer aborts because the destination quota is unlimited or not computable.

Written by the indexing model from the issue text.

Description

0. Needs triage bug
Bug description

occ files:transfer-ownership aborts with Target user does not have enough free space available. when the destination user has unlimited quota on an instance using object storage as primary storage — it fails precisely because the target has no limit.

Cause

OwnershipTransferService::analyse():

$freeSpace = $view->free_space($destinationUid . '/files/');
if ($size > $freeSpace && $freeSpace !== FileInfo::SPACE_UNKNOWN) {

free_space() returns negative sentinels, but the guard exempts only SPACE_UNKNOWN (-2). For a quota-less user, Quota::free_space() passes through to ObjectStoreStorage::free_space(), which returns SPACE_UNLIMITED (-3) when no totalSizeLimit is set. $size > -3 is true for any non-empty source, so it throws. SPACE_NOT_COMPUTED (-1) has the same flaw.

Not reachable on local primary storage, where an unlimited-quota user gets real disk free space — which is probably why it hasn't surfaced before.

Steps to reproduce
  1. Object store as primary storage, no totalSizeLimit.
  2. Destination user quota none.
  3. occ files:transfer-ownership --path="<non-empty folder>" <source> <destination>
Workaround

Set a finite quota on the destination, transfer, set it back to none.

Version

34.0.3, and present on master @ 22bd34a.

Dominant language
PHP
Stars
36.9k
Forks
5.2k
Avg merge
2d
Merged PRs (30d)
725

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

More from nextcloud/server

All issues in nextcloud/server

Similar issues

More PHP issues

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.