mirror of
https://github.com/EGroupware/egroupware.git
synced 2024-12-22 14:41:29 +01:00
Api: Fix out of memory error when deleting users and filesystem is large
Fixed by not deleting the files, just changing owner
This commit is contained in:
parent
5864368386
commit
0fdd8f87cb
@ -97,8 +97,6 @@ class Hooks
|
||||
|
||||
}
|
||||
Api\Vfs::rename('/home/'.$data['account_lid'],$new_dir);
|
||||
// make the new owner the owner of the dir and it's content
|
||||
Api\Vfs::find($new_dir, array(), 'EGroupware\Api\Vfs::chown', $data['new_owner']);
|
||||
}
|
||||
elseif(!empty($data['account_lid']) && $data['account_lid'] != '/')
|
||||
{
|
||||
@ -110,12 +108,8 @@ class Hooks
|
||||
throw new Api\Exception\AssertionFailed(__METHOD__.'('.array2string($data).') account_lid NOT set!');
|
||||
}
|
||||
|
||||
// Other files in home
|
||||
Api\Vfs::find(
|
||||
'/home',
|
||||
array('user' => $data['account_lid']),
|
||||
$data['new_owner'] ? 'EGroupware\Api\Vfs::chown' : 'EGroupware\Api\Vfs::remove', $data['new_owner']
|
||||
);
|
||||
// Change owner of all files
|
||||
Api\Vfs\Sqlfs\StreamWrapper::chownAll($data['account_id'], $data['new_owner'] ? $data['new_owner'] : 0);
|
||||
|
||||
Api\Vfs::$is_root = false;
|
||||
}
|
||||
|
@ -961,6 +961,21 @@ class StreamWrapper extends Api\Db\Pdo implements Vfs\StreamWrapperIface
|
||||
));
|
||||
}
|
||||
|
||||
/**
|
||||
* chown but for all files a user owns
|
||||
*
|
||||
* @param $old_uid
|
||||
* @param $new_uid
|
||||
*/
|
||||
public static function chownAll($old_uid, $new_uid)
|
||||
{
|
||||
$stmt = self::$pdo->prepare('UPDATE '.self::TABLE.' SET fs_uid=:fs_uid WHERE fs_uid=:old_uid');
|
||||
return $stmt->execute(array(
|
||||
'fs_uid' => (int) $new_uid,
|
||||
'old_uid' => $old_uid,
|
||||
));
|
||||
}
|
||||
|
||||
/**
|
||||
* Chgrp command, not yet a stream-wrapper function, but necessary
|
||||
*
|
||||
|
Loading…
Reference in New Issue
Block a user