Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
O
our_own_cloud_project
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Deploy
Releases
Model registry
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
die_coolen_jungs
our_own_cloud_project
Commits
a3999036
Commit
a3999036
authored
12 years ago
by
Björn Schießle
Browse files
Options
Downloads
Patches
Plain Diff
improved free space calculation if no quota is set, discussed in #2936
parent
f3c06ae4
Branches
Branches containing commit
No related tags found
No related merge requests found
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
apps/files_trashbin/lib/trash.php
+43
-23
43 additions, 23 deletions
apps/files_trashbin/lib/trash.php
with
43 additions
and
23 deletions
apps/files_trashbin/lib/trash.php
+
43
−
23
View file @
a3999036
...
...
@@ -105,26 +105,7 @@ class Trashbin {
\OC_Log
::
write
(
'files_trashbin'
,
'Couldn\'t move '
.
$file_path
.
' to the trash bin'
,
\OC_log
::
ERROR
);
}
// get available disk space for user
$quota
=
\OC_Preferences
::
getValue
(
$user
,
'files'
,
'quota'
);
if
(
$quota
===
null
||
$quota
===
'default'
)
{
$quota
=
\OC_Appconfig
::
getValue
(
'files'
,
'default_quota'
);
}
if
(
$quota
===
null
||
$quota
===
'none'
)
{
$quota
=
\OC\Files\Filesystem
::
free_space
(
'/'
)
/
count
(
\OCP\User
::
getUsers
());
}
else
{
$quota
=
\OCP\Util
::
computerFileSize
(
$quota
);
}
// calculate available space for trash bin
$rootInfo
=
$view
->
getFileInfo
(
'/files'
);
$free
=
$quota
-
$rootInfo
[
'size'
];
// remaining free space for user
if
(
$free
>
0
)
{
$availableSpace
=
(
$free
*
self
::
DEFAULTMAXSIZE
/
100
)
-
$trashbinSize
;
// how much space can be used for versions
}
else
{
$availableSpace
=
$free
-
$trashbinSize
;
}
$trashbinSize
-=
self
::
expire
(
$availableSpace
);
$trashbinSize
-=
self
::
expire
(
$trashbinSize
);
self
::
setTrashbinSize
(
$user
,
$trashbinSize
);
...
...
@@ -352,14 +333,53 @@ class Trashbin {
return
false
;
}
/**
* calculate remaining free space for trash bin
*
* @param $trashbinSize current size of the trash bin
* @return available free space for trash bin
*/
private
static
function
calculateFreeSpace
(
$trashbinSize
)
{
$softQuota
=
true
;
$user
=
\OCP\User
::
getUser
();
$quota
=
\OC_Preferences
::
getValue
(
$user
,
'files'
,
'quota'
);
$view
=
new
\OC\Files\View
(
'/'
.
$user
);
if
(
$quota
===
null
||
$quota
===
'default'
)
{
$quota
=
\OC_Appconfig
::
getValue
(
'files'
,
'default_quota'
);
}
if
(
$quota
===
null
||
$quota
===
'none'
)
{
$quota
=
\OC\Files\Filesystem
::
free_space
(
'/'
);
$softQuota
=
false
;
}
else
{
$quota
=
\OCP\Util
::
computerFileSize
(
$quota
);
}
// calculate available space for trash bin
// subtract size of files and current trash bin size from quota
if
(
$softQuota
)
{
$rootInfo
=
$view
->
getFileInfo
(
'/files/'
);
$free
=
$quota
-
$rootInfo
[
'size'
];
// remaining free space for user
if
(
$free
>
0
)
{
$availableSpace
=
(
$free
*
self
::
DEFAULTMAXSIZE
/
100
)
-
$trashbinSize
;
// how much space can be used for versions
}
else
{
$availableSpace
=
$free
-
$trashbinSize
;
}
}
else
{
$availableSpace
=
$quota
;
}
return
$availableSpace
;
}
/**
* clean up the trash bin
* @param
max. available disk space for
trashbin
* @param
current size of the
trash
bin
*/
private
static
function
expire
(
$
availableSpac
e
)
{
private
static
function
expire
(
$
trashbinSiz
e
)
{
$user
=
\OCP\User
::
getUser
();
$view
=
new
\OC\Files\View
(
'/'
.
$user
);
$availableSpace
=
self
::
calculateFreeSpace
(
$trashbinSize
);
$size
=
0
;
$query
=
\OC_DB
::
prepare
(
'SELECT `location`,`type`,`id`,`timestamp` FROM `*PREFIX*files_trash` WHERE `user`=?'
);
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment