Skip to content

Commit 1285c8c

Browse files
Merge pull request #58414 from nextcloud/fix/transfer-ownership-service/remove-groupfolders-size
fix(TransferOwnershipService): Remove groupfolders size
2 parents 7e474a9 + 1ed7a0e commit 1285c8c

2 files changed

Lines changed: 24 additions & 0 deletions

File tree

apps/files/lib/Service/OwnershipTransferService.php

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@
1717
use OCA\Encryption\Util;
1818
use OCA\Files\Exception\TransferOwnershipException;
1919
use OCA\Files_External\Config\ConfigAdapter;
20+
use OCA\GroupFolders\Mount\GroupMountPoint;
2021
use OCP\Encryption\IManager as IEncryptionManager;
2122
use OCP\EventDispatcher\IEventDispatcher;
2223
use OCP\Files\Config\IHomeMountProvider;
@@ -169,6 +170,28 @@ public function transfer(
169170
);
170171
$sizeDifference = $sourceSize - $view->getFileInfo($finalTarget)->getSize();
171172

173+
// Files in Team folders are not transferred, so their size needs to be subtracted to avoid warnings about size differences
174+
$mounts = Server::get(IMountManager::class)->getAll();
175+
foreach ($mounts as $mount) {
176+
if (!$mount instanceof GroupMountPoint || !str_starts_with($mount->getMountPoint(), '/' . $sourcePath . '/')) {
177+
continue;
178+
}
179+
180+
$storage = $mount->getStorage();
181+
if ($storage === null) {
182+
$output->writeln('Failed to get storage for mount: ' . $mount->getMountPoint());
183+
continue;
184+
}
185+
186+
$rootCacheEntry = $storage->getCache()->get('');
187+
if ($rootCacheEntry === false) {
188+
$output->writeln('Failed to get root cache entry for storage: ' . $mount->getMountPoint());
189+
continue;
190+
}
191+
192+
$sizeDifference -= $rootCacheEntry->getSize();
193+
}
194+
172195
// transfer the incoming shares
173196
$sourceShares = $this->collectIncomingShares(
174197
$sourceUid,

psalm.xml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -114,6 +114,7 @@
114114
<referencedClass name="OCA\TwoFactorNextcloudNotification\Controller\APIController"/>
115115
<referencedClass name="OCA\GlobalSiteSelector\Service\SlaveService"/>
116116
<referencedClass name="OCA\Guests\UserBackend"/>
117+
<referencedClass name="OCA\GroupFolders\Mount\GroupMountPoint"/>
117118
</errorLevel>
118119
</UndefinedClass>
119120
<UndefinedFunction>

0 commit comments

Comments
 (0)