Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

'tempdirectory' in config.php is ignored. #19682

Closed
thisaccountname opened this issue Feb 27, 2020 · 19 comments · Fixed by #35974
Closed

'tempdirectory' in config.php is ignored. #19682

thisaccountname opened this issue Feb 27, 2020 · 19 comments · Fixed by #35974
Labels
0. Needs triage Pending check for reproducibility or if it fits our roadmap bug

Comments

@thisaccountname
Copy link

thisaccountname commented Feb 27, 2020

Steps to reproduce

  1. Fresh installation of NC
  2. Change data directory successfully, config.php looks like:
 'datadirectory' => '/mnt/my8TBeZ/nextcloud/data',
  'tempdirectory' => '/mnt/my8TBeZ/nextcloud/data/tmp',
  1. Upload decently sized file, monitor disk usage during upload.

Expected behaviour

'tempdirectory' is used and only my external drive's disk space decreases.

Actual behaviour

Large (~150MB) chunks are continually written to SD card before being transferred to external.

Server configuration

Operating system:
Raspbian
Web server:
Apache
Database:
MySQL/MariaDB
PHP version:
7.3
Nextcloud version: (see Nextcloud admin page)
18.0.1.3
Updated from an older Nextcloud/ownCloud or fresh install:
Fresh Install
Where did you install Nextcloud from:
NC Github

Things I've done

Added upload_tmp_dir = /mnt/my8TBeZ/nextcloud/data/tmp to my .user.ini file.
Added upload_tmp_dir = /mnt/my8TBeZ/nextcloud/data/tmp to my php.ini file.

Ensured proper ownership on mount location, running both

sudo chmod 0770 /mnt/my8TBeZ/nextcloud/
sudo chown -R www-data:www-data /mnt/my8TBeZ/nextcloud/

I can read and write files just fine. The process in which they get there is the part I can't change.

Apparently I wasn't alone in this, I am hoping this thread won't be ignored as much as @berho's was

@thisaccountname thisaccountname added 0. Needs triage Pending check for reproducibility or if it fits our roadmap bug labels Feb 27, 2020
@kesselb
Copy link
Contributor

kesselb commented Feb 27, 2020

Don't put the temp directory inside the data directory.

@thisaccountname
Copy link
Author

Don't put the temp directory inside the data directory.

Changes made, server restarted.

Same behavior.

@kesselb
Copy link
Contributor

kesselb commented Feb 27, 2020

Yes. Just a general note not to do that.

@kesselb
Copy link
Contributor

kesselb commented Mar 2, 2020

I don't see any issue with Nextcloud. tempdirectory is not relevant for uploads. Chunks are always uploaded to the datadirectory. PHP also has a directive for temporary files. Change that directive to a location on your external disk.

@kesselb kesselb closed this as completed Mar 2, 2020
@thisaccountname
Copy link
Author

thisaccountname commented Mar 2, 2020

Chunks are always uploaded to the datadirectory.

Then why, after setting my data directory to my external drive, does this behavior persist?

PHP also has a directive for temporary files. Change that directive to a location on your external disk.

As mentioned in my post, I did.

I don't see any issue with Nextcloud.

Here's another user from 2018 with the same issue getting a similar response.

@kesselb
Copy link
Contributor

kesselb commented Mar 2, 2020

As mentioned in my post, I did.

You don't. upload_tmp_dir is the wrong directive.

@thisaccountname
Copy link
Author

You don't. upload_tmp_dir is the wrong directive.

Why didn't you mention that 4 days ago?

Both upload_tmp_dir and sys_temp_dir are defined. Are either of these supposed to be fixing this issue?

@suslikas
Copy link

suslikas commented Jul 2, 2020

Same for version 18.0.4.2. Php-fpm 7.3+nginx. From this case

./lib/private/TempManager.php

    if ($temp = $this->config->getSystemValue('tempdirectory', null)) {
      $directories[] = $temp;
    }
    if ($temp = \OC::$server->getIniWrapper()->get('upload_tmp_dir')) {
      $directories[] = $temp;
    }
    if ($temp = getenv('TMP')) {
      $directories[] = $temp;
    }
    if ($temp = getenv('TEMP')) {
      $directories[] = $temp;
    }
    if ($temp = getenv('TMPDIR')) {
      $directories[] = $temp;
    }
    if ($temp = sys_get_temp_dir()) {
      $directories[] = $temp;
    }

Work only TMPDIR when configured in php-fpm pool as

env[TMPDIR] = /path/tmp

@suslikas
Copy link

suslikas commented Jul 7, 2020

@kesselb can you reopen issue? Problem not related with tmp directory path.

@kesselb
Copy link
Contributor

kesselb commented Jul 7, 2020

What problem are you talking about?

@suslikas
Copy link

suslikas commented Jul 7, 2020

tempdirectory parameter in config.php is ignored. During file upload via webdav all php temporary files stored in /tmp

'tempdirectory' => '/data/tmp',

@kesselb
Copy link
Contributor

kesselb commented Jul 7, 2020

I don't see any issue with Nextcloud. tempdirectory is not relevant for uploads. Chunks are always uploaded to the datadirectory. PHP also has a directive for temporary files. Change that directive to a location on your external disk.

Uploads are processed by PHP before handed to Nextcloud. We are unable to change the location PHP uses to store temporary files used for uploads.

image

https://www.php.net/manual/en/ini.core.php#ini.upload-tmp-dir

image

https://www.php.net/manual/en/configuration.changes.modes.php

@suslikas
Copy link

suslikas commented Jul 7, 2020

My questions not about how to change php upload directory. tempdirectory directive for other nextcloud temporary files, not php upload? Then make sense update documentation, because is not clear.

/**
 * Override where Nextcloud stores temporary files. Useful in situations where
 * the system temporary directory is on a limited space ramdisk or is otherwise
 * restricted, or if external storages which do not support streaming are in
 * use.
 *
 * The Web server user must have write access to this directory.
 */
'tempdirectory' => '/tmp/nextcloudtemp',

Thank you. Now it's clear.

@thisaccountname
Copy link
Author

@suslikas this was a while ago but the only way I was able to get around this behavior was to put my RPi filesystem on an external USB drive.

I followed this guide:

https://www.raspberrypi.org/forums/viewtopic.php?t=44177

I also ended up moving away from Nextcloud, but from the short amount of testing I did this solved my problem. Pain in the butt but overall better performance regardless.

Good luck!

@petrosy
Copy link

petrosy commented Nov 9, 2020

I have the same issue which I solved as follows.
I created my new TMP folder and then setup a symbolic link to the original default

I first deleted the original /var/snap/nextcloud/common/nextcloud/tmp
then linked my new folder
ln -sf /media/usbc/nextcloud/tmp/ /var/snap/nextcloud/common/nextcloud/
folder is owned by ROOT

@sebastiansterk
Copy link
Member

Issue still persists in Nextcloud 24. tempdirectory is still being ignored. :-/

haeho7 added a commit to haeho7/docker-images that referenced this issue Dec 20, 2022
@CaptainSifff
Copy link
Contributor

As stated above setting the php environment variables does the trick. A clarification in the docs for this setting would still be nice....

@kesselb
Copy link
Contributor

kesselb commented Jan 3, 2023

@CaptainSifff mind to send a pull request?

@CaptainSifff
Copy link
Contributor

like so? #35974

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
0. Needs triage Pending check for reproducibility or if it fits our roadmap bug
Projects
None yet
Development

Successfully merging a pull request may close this issue.

6 participants