[FIX] Folder size always 2GB

Ask all your questions regarding OC 6.x Please read the Support Forum Rules
Forum rules
ownCloud 6.x reached end of life and is officially unsupported. For details see Wiki page.

Please upgrade your ownCloud.
MiguelDomingues
Beginner
Posts: 13
Joined: Thu Dec 19, 2013 3:45 pm
ownCloud version: 6.0.0a
Webserver: Apache
Database: MySQL
OS: Linux
PHP version: 5.3.3

[FIX] Folder size always 2GB

Postby MiguelDomingues » Thu Dec 19, 2013 4:47 pm

Hi,

I've come across the 2GB quota problem, and I have searched for a solution and did not found one.
NOTE: This has nothing to do with uploading files bigger than 2 GB!!!
This problem is when a folder always displays 2 GB size, and the quota used is always 2 GB.

My current setup:
Sever: My Book Live (powerpc-32bits) running debian squeeze
Apache: 2.2.9
PHP: 5.3.3
MySQL: 5.1.49-3
Owncloud: 6.0.0a

PROBLEM:
After uploading several files (the biggest with 300 MB) to a folder where the sum of all file sizes is higher than 2 GB is reported in the web interface as:
You have used 2 GB of the available 100 GB

And the folder size is always 2GB but inside the folder there is more than 2 GB of files.
In the sync client (mac at least) the quota usage is also 2 GB.

MY FINDINGS:
Across the forum I've found some solutions but none has fixed the problem... mostly they say that is a 32bit system problem...
PHP in a 32bit system has support for longs so it seemed odd to me... in the owncloud source I've found several casts to int (e.g. (int)$data['size']), in a 32 bit system this will overflow around the 2 GB integer.
The problem is related to the intval(...) function, see: http://php.net/intval#refsect1-function.intval-returnvalues

SOLUTION:
My solution is to modify 3 files in the source, instead of using a cast operation (int) or the intval function, force a type conversion.
I've searched for more similar problems in the entire code but only found 3 files that may cause the problem.
Maybe some expert/developer may help on this.
You may need to delete and reupload your files... for just refreshing the web interface was enough.
EDIT: See the solution provided by Kaizen: viewtopic.php?f=26&t=18676#p49848 Just add some file to the folder and it will recalculate the correct folder sizes.

1. Edit /path/to/owncloud/lib/private/files/cache/cache.php
Change line 145 from:

Code: Select all

$data['size'] = (int)$data['size'];

to:

Code: Select all

$data['size'] = 0+$data['size'];


Change line 149 from:

Code: Select all

$data['unencrypted_size'] = (int)$data['unencrypted_size'];

to

Code: Select all

$data['unencrypted_size'] = 0+$data['unencrypted_size'];


Change line 425 from:

Code: Select all

if ((int)$row['size'] === -1) {

to:

Code: Select all

if (0+$row['size'] === -1) {


Change lines 519-520 from:

Code: Select all

$sum = (int)$sum;
$min = (int)$min;

to:

Code: Select all

[code]$sum = 0+$sum;
$min = 0+$min;[/code]


2. Edit /path/to/owncloud/lib/private/files/cache/homecache.php
Change line 32 from:

Code: Select all

$totalSize = (int)$sum;

to:

Code: Select all

$totalSize = 0+$sum;


3. Edit /path/to/owncloud/apps/files_sharing/lib/cache.php
Change line 100 from

Code: Select all

$data['size'] = (int)$data['size'];

to:

Code: Select all

$data['size'] = 0+$data['size'];



UPDATE: Downloading large files was not working!!! You need to edit another file.
3. Edit /path/to/owncloud/lib/private/connector/sabre/server.php
Change line 172 from

Code: Select all

$newProperties[200][$prop] = (int)$node->getSize();

to:

Code: Select all

$newProperties[200][$prop] = 0+$node->getSize();
Last edited by MiguelDomingues on Tue Dec 31, 2013 2:10 am, edited 2 times in total.

RealRancor
ownCloud master
Posts: 17381
Joined: Sat May 26, 2012 3:00 pm
ownCloud version: 9.0.2
Webserver: nginx
Database: MySQL
OS: Linux
PHP version: 7.0.x

Re: [FIX] Folder size always 2GB

Postby RealRancor » Thu Dec 19, 2013 4:55 pm

Hi,

as the developers are not checking this forums you probably want to report this directly to them at the bugtracker:

https://github.com/owncloud/core/issues
*gone*

MiguelDomingues
Beginner
Posts: 13
Joined: Thu Dec 19, 2013 3:45 pm
ownCloud version: 6.0.0a
Webserver: Apache
Database: MySQL
OS: Linux
PHP version: 5.3.3

Re: [FIX] Folder size always 2GB

Postby MiguelDomingues » Thu Dec 19, 2013 4:57 pm

Ok. I'll do it later.
First I'd like to know if this worked for someone else or i was lucky :lol:

Kaizen
Newbie
Posts: 3
Joined: Thu Dec 19, 2013 7:28 pm
ownCloud version: 6.0.0
Webserver: Apache
Database: MySQL
OS: Linux

Re: [FIX] Folder size always 2GB

Postby Kaizen » Thu Dec 19, 2013 7:55 pm

Hello,

I'm facing the same issue. I followed you FIX instructions but it doesn't seems to change anything for me. I'm in 6.0.0

Cheers

MiguelDomingues
Beginner
Posts: 13
Joined: Thu Dec 19, 2013 3:45 pm
ownCloud version: 6.0.0a
Webserver: Apache
Database: MySQL
OS: Linux
PHP version: 5.3.3

Re: [FIX] Folder size always 2GB

Postby MiguelDomingues » Thu Dec 19, 2013 8:02 pm

After editing all 3 files, try the following:
- Remove the share from the sync client, and quit the sync client.
- Open the web interface and delete enough files from the folder until it reaches a size below 2 GB. At this point the folder will show the correct size.
- Open the sync client and add the share again to that folder. Let it upload all files again.

For me it worked :\
My sync client is still uploading but my quota in the web interface and sync client show the correct usage.
Also all folders show the correct size.
You may also try to update to 6.0.0a but i guess it would not fix it. Note that if you update your owncloud, the fix should go away and you have to modify the files again.

Best.

EDIT: Some screenshots
Image
Image

Kaizen
Newbie
Posts: 3
Joined: Thu Dec 19, 2013 7:28 pm
ownCloud version: 6.0.0
Webserver: Apache
Database: MySQL
OS: Linux

Re: [FIX] Folder size always 2GB

Postby Kaizen » Thu Dec 19, 2013 9:00 pm

I put some new big files in my OC6. Size calculation is now working over 2gb for those newly uploaded ones and only those.
Isn't there a way to force the size calculation globaly so i don't have to upload dozens of gb again?

BTW i have another OC6 running in a server where PHP is working with 64b int. With this instance file size is calculated accurately.

Cheers

MiguelDomingues
Beginner
Posts: 13
Joined: Thu Dec 19, 2013 3:45 pm
ownCloud version: 6.0.0a
Webserver: Apache
Database: MySQL
OS: Linux
PHP version: 5.3.3

Re: [FIX] Folder size always 2GB

Postby MiguelDomingues » Thu Dec 19, 2013 9:12 pm

In a 64bit system there is no problem, this fix is not even needed.
This only occurs in a 32bit system because of the (int) operation.

I don't know if there is a way to force an update...
Try adding a file to one of those folders, maybe that will force a recalculation of the size.
I doubt it but give it a try... I think the size is only calculated once during the upload.

Another option is to move the files, if I remember correctly there is an app for that.

RealRancor
ownCloud master
Posts: 17381
Joined: Sat May 26, 2012 3:00 pm
ownCloud version: 9.0.2
Webserver: nginx
Database: MySQL
OS: Linux
PHP version: 7.0.x

Re: [FIX] Folder size always 2GB

Postby RealRancor » Thu Dec 19, 2013 9:13 pm

Hi,

just remembered there is some work done at the moment in this pull request to fix such issues at 32bit systems:

https://github.com/owncloud/core/pull/5365
*gone*

Kaizen
Newbie
Posts: 3
Joined: Thu Dec 19, 2013 7:28 pm
ownCloud version: 6.0.0
Webserver: Apache
Database: MySQL
OS: Linux

Re: [FIX] Folder size always 2GB

Postby Kaizen » Thu Dec 19, 2013 9:40 pm

Folder size are re calculated when any change is made in it. I just created some empty text files with the web interface. It's working fine. Thank you for the tip!

About the 64b int size, i'm working on a 64b system with a 64b version of PHP but int are 32b. Do you know how i could change this?

MiguelDomingues
Beginner
Posts: 13
Joined: Thu Dec 19, 2013 3:45 pm
ownCloud version: 6.0.0a
Webserver: Apache
Database: MySQL
OS: Linux
PHP version: 5.3.3

Re: [FIX] Folder size always 2GB

Postby MiguelDomingues » Thu Dec 19, 2013 9:50 pm

As far as I know in php with 64b there is no notion of long, integers are 64b, this is done automatically.
I think there is no way to change it... if there is a way, it should be in php.ini

Check: http://php.net/intval#refsect1-function ... turnvalues
The maximum value depends on the system. 32 bit systems have a maximum signed integer range of -2147483648 to 2147483647. So for example on such a system, intval('1000000000000') will return 2147483647. The maximum signed integer value for 64 bit systems is 9223372036854775807.


1 bit for signal and 63 bits for the number give 9223372036854775807


  • Similar Topics
    Replies
    Views
    Last post

Return to “ownCloud Community Edition 6.x”

Who is online

Users browsing this forum: No registered users and 0 guests