nextcloud / server

☁️ Nextcloud server, a safe home for all your data
https://nextcloud.com
GNU Affero General Public License v3.0
27.38k stars 4.07k forks source link

Add "no free space checking" in external storages configuration #18552

Open Hexasoft opened 4 years ago

Hexasoft commented 4 years ago

Is your feature request related to a problem? Please describe.

When creating an external storage that points to an area with no free space, users get the "Your storage is full , files can not be updated or synced anymore !" message. The problem is that this message makes no sense when the target area is read-only (user can't add/modify files, even with free space). The same problem applies when "read-only" is selected in external storage configuration.

Describe the solution you'd like

Describe alternatives you've considered

At this time I patched lib/private/Files/Storage/Local.php so that free_space() returns not empty for not writable path, in order to prevent disturbing messages to users.

Additional context

The problem arise with a backup external storage: an incremental backup system is used on files, and it allows to navigate back in time via a FUSE mountpoint. This mountpoint is readonly, with 0 free space. The external storage is configured with "read-only" checked and "allow sharing" unchecked. Each time a user go inside this storage ("/…/backups/$user" → "Backup") the "full" message appears. Note: target directory is automounted.

Regards.

PS: my initial post on help.nextcloud.com → https://help.nextcloud.com/t/prevent-storage-full-on-external-storage/66578 (and suggestion to open an issue here)

gordmul commented 4 years ago

Could you please paste the exact code you have in your “Local.php”? I’m having this same problem and would like to use this workaround.

Hexasoft commented 4 years ago

From lib/private/Files/Storage/Local.php in the method public function free_space($path) I added the lines: if (!$this->isUpdatable($sourcePath)) { $space = 999999999999; } just after $space = @disk_free_space($sourcePath);

It is not very clean. It pretends that space is "enough" in case storage is not updatable. It should be more precise: in case of read-only "read-only storage" should be shown as message. In case of non-writable directory a "non-writable storage" should be shown.

But, in my case, this basic patch prevents users to complain.

gordmul commented 4 years ago

This is exactly what I needed. Tried it and it's working great. Thank you so much!

I needed this because I wanted to add an extra layer of security by making my external shares read-only in FreeNAS Jail's mount point and not just in Nextcloud settings.

Hexasoft commented 4 years ago

You're welcome. But beware that it is just a hack to prevent the message (and mind to re-apply after upgrades).

gordmul commented 4 years ago

Yes of course. But the nagging message was the only problem here so, as far as I'm concerned, it's solved. It would be better if the message could be turned off in the GUI but for now this is perfect.

szaimen commented 3 years ago

Is this Issue still valid in NC21.0.2? If not, please close this issue. Thanks! :)

0livd commented 3 years ago

@szaimen I confirm that this is still present in 21.0.3, I applied the patch proposed by @Hexasoft for now.

szaimen commented 3 years ago

cc @icewind1991

alanswanson commented 3 years ago

With a very large disk using even 999999999999 will still cause warnings. I use the following work around instead;

if (!$this->isUpdatable($sourcePath)) { $space = @disk_total_space($sourcePath);

pwolny commented 1 year ago

I have encountered this issue in Nextcloud 24.0.0. my workaround was to change the line in lib/private/Files/Storage/Local.php in function free_space($path): $space = function_exists('disk_free_space') ? disk_free_space($sourcePath) : false;
to: $space = (function_exists('disk_free_space') && ($this->isUpdatable($sourcePath)) ) ? disk_free_space($sourcePath) : false;