Commit Graph

67 Commits

Author SHA1 Message Date
Robin Appelman cb51564356 trigger a rescan when trying to fopen a file that exists in cache but not on disk
Signed-off-by: Robin Appelman <robin@icewind.nl>
2022-09-29 11:17:16 +02:00
Tigran Mkrtchyan f41209a061 config: add a switch to control truncate before update
To avoid extra truncate on non WORM file systems, add a new config
option `localstorage.unlink_on_truncate`, which defaults to false.

The OC\Files\Storage\Local is update to respect that option.

Signed-off-by: Tigran Mkrtchyan <tigran.mkrtchyan@desy.de>
2022-09-16 11:10:32 +02:00
Tigran Mkrtchyan 8fc4cf67f1 files: remove destination file before copying new content (WORM)
Signed-off-by: Tigran Mkrtchyan <tigran.mkrtchyan@desy.de>
2022-09-16 10:57:17 +02:00
Tigran Mkrtchyan b6065a236f files: make OC\Files\Storage\Local WORM friendly
Some filesystems run as a Write-Once-Read-Many storages. This
makes them impossible to use with NexeCloud, as the file system
layers uses `truncate` syscall (through file_put_contents function).

As Nextcloud is never updates existing files, removing the old entry
and creatint a new one on update will allow NextCoud to update on such
file systems.

Update Local#fopen and Local#file_put_contents to remote existing
file before truncating.

Signed-off-by: Tigran Mkrtchyan <tigran.mkrtchyan@desy.de>
2022-08-25 11:11:49 +02:00
Martin Brugnara 7409569994
Expose umask override value as config parameter: localstorage.umask
Commit 451c06d introduced override for umask value.
This is needed to avoid broken env configuration or dirty workers
to mess with the permissions when creating new files.

Most Nextcloud, that does not integrate with external software
would work fine with an hard-coded value (451c06d set it at 022).

Advanced install may require more flexibility, as such this commit
exposes the "umask override value" as configuration parameter:
`localstorage.umask`

It defaults to 0022 both in code and in config/config.sample.php .

Signed-off-by: Martin Brugnara <martin@0x6d62.eu>
2022-06-05 19:19:31 +02:00
Côme Chilliet 23f7a37c03
Remove ILogger usages in lib/private/Files/Storage
Signed-off-by: Côme Chilliet <come.chilliet@nextcloud.com>
2022-04-26 16:52:53 +02:00
Robin Appelman 468d6a9cf1
ignore forbidden files while scanning local storage
Signed-off-by: Robin Appelman <robin@icewind.nl>
2022-04-20 13:01:16 +02:00
Robin Appelman 84f464550a
some file scanner performance improvements
Signed-off-by: Robin Appelman <robin@icewind.nl>
2022-03-17 22:21:16 +01:00
acsfer 152e2bfdaa
Check for `disk_free_space`
Check for `disk_free_space` before calling it.
Fix https://github.com/nextcloud/server/issues/29748
2021-11-18 11:46:13 +01:00
Carl Schwan 9408f8ae69
Fix security issues when copying groupfolder with advanced ACL
Using advanced ACL, it is possible that an user has access to a
directory but not to a subdirectory, so the copying use
Common::copyFromStorage instead of Local::copyFromStorage.

Fix https://github.com/nextcloud/groupfolders/issues/1692

Signed-off-by: Carl Schwan <carl@carlschwan.eu>
2021-10-21 17:11:52 +02:00
John Molakvoæ a1c8b6e9eb
Merge pull request #28768 from nextcloud/check-file-exists 2021-10-18 09:54:22 +02:00
acsfer 98eac0fc05
Simplify :) 2021-10-04 17:21:37 +02:00
acsfer 8a8df49bc0
Replace `file_exists()` method by `is_file()` 2021-10-04 17:20:17 +02:00
acsfer 3a25183b66 Get `filesize()` if `file_exists()`
Should make sense.
2021-10-01 21:02:38 +00:00
Daniel Kesselberg e60a829b42
explicitly close source stream on local storage
Signed-off-by: Daniel Kesselberg <mail@danielkesselberg.de>
2021-09-21 17:41:59 +02:00
Rid 0469acfb20 Fix scanner mistaking socket files for directories
Signed-off-by: Rid <rid@cylo.io>
2021-06-17 11:44:44 +01:00
John Molakvoæ (skjnldsv) 215aef3cbd
Update php licenses
Signed-off-by: John Molakvoæ (skjnldsv) <skjnldsv@protonmail.com>
2021-06-04 22:02:41 +02:00
Roeland Jago Douma f3738eeff7
Merge pull request #25280 from nextcloud/explicit-file-permissions
Set umask before operations that create local files
2021-03-30 21:55:50 +02:00
Robin Appelman aee4caed07
show better error messages when a file with a forbidden path is encountered
Signed-off-by: Robin Appelman <robin@icewind.nl>
2021-03-24 17:13:09 +01:00
Robin Appelman e5dc1a8085
Set umask before operations that create local files
this solves issues where "other php stuff" is messing with the umask

Signed-off-by: Robin Appelman <robin@icewind.nl>
2021-03-23 14:52:31 +01:00
Robin Appelman d182043e83
explicitly set permissions on newly created folders
this works around any `umask` that might be set and limiting the folder permissions

Signed-off-by: Robin Appelman <robin@icewind.nl>
2021-01-20 17:15:57 +01:00
Johannes Leuker ac88bcbd5f Add 'allow Symlinks' as an option to config.php
Signed-off-by: Johannes Leuker <j.leuker@hosting.de>
2021-01-12 10:38:39 +01:00
Julius Härtl 5094e29ebd
Merge pull request #24594 from kofemann/dcache 2020-12-22 09:26:07 +01:00
Christoph Wurst d89a75be0b
Update all license headers for Nextcloud 21
Signed-off-by: Christoph Wurst <christoph@winzerhof-wurst.at>
2020-12-16 18:48:22 +01:00
Tigran Mkrtchyan f3513f3fe4 files: Local#writeStream should use it's own file_put_contents
The OC\Files\Storage\Local#writeStream use system provided file_put_contents.
However, it overrides file_put_contents, thus expects that the default behaviour
can be different.

Use Local#file_put_contents in writeStream to benefit from class specific functionality.

Signed-off-by: Tigran Mkrtchyan <tigran.mkrtchyan@desy.de>
2020-12-07 18:11:40 +01:00
aler9 ac0c7a8fe0 Fix file size computation on 32bit platforms
Signed-off-by: aler9 <46489434+aler9@users.noreply.github.com>
2020-12-02 12:05:14 +01:00
Christoph Wurst 2a054e6c04
Update the license headers for Nextcloud 20
Signed-off-by: Christoph Wurst <christoph@winzerhof-wurst.at>
2020-08-24 14:54:25 +02:00
Morris Jobke ae9ecd521f
Merge pull request #21677 from J0WI/clearstatcache-on-rmdir
Do clearstatcache() on rmdir
2020-08-05 23:03:06 +02:00
Robin Appelman ad7798f9c9
use exceptions for error signaling in writeStream
this remove the ambiguity when writing zero length files

Signed-off-by: Robin Appelman <robin@icewind.nl>
2020-07-23 15:24:52 +02:00
J0WI 356bc50420 Only clear the realpath cache
Signed-off-by: J0WI <J0WI@users.noreply.github.com>
2020-07-03 22:47:13 +02:00
J0WI ea08a01999 clearstatcache() on rmdir
Signed-off-by: J0WI <J0WI@users.noreply.github.com>
2020-07-03 22:42:27 +02:00
Roeland Jago Douma 6b26744787
Clear the statscache before fetching the metadata
Else if a lot of writes happen. It might happen that an old stat result
is used. Resulting in a wrong file size for the file. For example the
text app when a lot of people edit at the same time.

Signed-off-by: Roeland Jago Douma <roeland@famdouma.nl>
2020-05-22 09:21:53 +02:00
Christoph Wurst cb057829f7
Update license headers for 19
Signed-off-by: Christoph Wurst <christoph@winzerhof-wurst.at>
2020-04-29 11:57:22 +02:00
Robin Appelman 9735b5d61f
Add method to storage backends to get directory content with metadata
Currently you need to use `opendir` and then call `getMetadata` for
every file, which adds overhead because most storage backends already
get the metadata when doing the `opendir`.

While storagebackends can (and do) use caching to relief this problem,
this adds cache invalidation dificulties and only a limited number of
items are generally cached (to prevent memory usage exploding when
scanning large storages)

With this new methods storage backends can use the child metadata they
got from listing the folder to return metadata without having to keep
seperate caches.

Signed-off-by: Robin Appelman <robin@icewind.nl>
2020-04-20 15:45:04 +02:00
Christoph Wurst caff1023ea
Format control structures, classes, methods and function
To continue this formatting madness, here's a tiny patch that adds
unified formatting for control structures like if and loops as well as
classes, their methods and anonymous functions. This basically forces
the constructs to start on the same line. This is not exactly what PSR2
wants, but I think we can have a few exceptions with "our" style. The
starting of braces on the same line is pracrically standard for our
code.

This also removes and empty lines from method/function bodies at the
beginning and end.

Signed-off-by: Christoph Wurst <christoph@winzerhof-wurst.at>
2020-04-10 14:19:56 +02:00
Christoph Wurst 14c996d982
Use elseif instead of else if
Signed-off-by: Christoph Wurst <christoph@winzerhof-wurst.at>
2020-04-10 10:35:09 +02:00
Robin Appelman 5439469b68
optimize getMetaData for local storage
Signed-off-by: Robin Appelman <robin@icewind.nl>
2020-04-01 14:14:48 +02:00
Christoph Wurst 1a9330cd69
Update the license headers for Nextcloud 19
Signed-off-by: Christoph Wurst <christoph@winzerhof-wurst.at>
2020-03-31 14:52:54 +02:00
Christoph Wurst b80ebc9674
Use the short array syntax, everywhere
Signed-off-by: Christoph Wurst <christoph@winzerhof-wurst.at>
2020-03-26 16:34:56 +01:00
Christoph Wurst 5bf3d1bb38
Update license headers
Signed-off-by: Christoph Wurst <christoph@winzerhof-wurst.at>
2019-12-05 15:38:45 +01:00
Roeland Jago Douma 0568b01267
Improve etag handling
Check if values exist before using them

Signed-off-by: Roeland Jago Douma <roeland@famdouma.nl>
2019-11-27 13:34:42 +01:00
Roeland Jago Douma 1cc8a2f5d2
Supress warnings touch can generate
We already catch the result value. Having the warning being logged
explicitly doesn't help and polutes the log.

Signed-off-by: Roeland Jago Douma <roeland@famdouma.nl>
2019-07-26 17:26:59 +02:00
Robin Appelman f39605dabc
verify that paths are valid for recursive local move
Signed-off-by: Robin Appelman <robin@icewind.nl>
2019-06-27 11:10:08 +02:00
Robin Appelman 93de63777e
extend storage api to allow directly writing a stream to storage
this removes the need for temporary storages with some external storage backends.
The new method is added to a separate interface to maintain compatibility with
storage backends implementing the storage interface directly (without inheriting common)

Currently the interface is implemented for objectstorage based storages and local storage
and used by webdav uploads

Signed-off-by: Robin Appelman <robin@icewind.nl>
2018-10-31 21:10:44 +01:00
Arthur Schiwon 38a90130ce
move log constants to ILogger
Signed-off-by: Arthur Schiwon <blizzz@arthur-schiwon.de>
2018-04-26 10:45:52 +02:00
Morris Jobke bcba1a97ad
Use fallback path if data dir is not available for Storage/Local.php
Found while testing strict types for PHP7+.

Signed-off-by: Morris Jobke <hey@morrisjobke.de>
Signed-off-by: Robin Appelman <robin@icewind.nl>
2018-01-18 16:38:01 +01:00
Morris Jobke 01040daf02
Fix call to clearstatcache to actually use the file path
* found while adding the strict_typing for PHP 7+ migration
* first argument is a boolean - second one is the path
* see http://php.net/manual/en/function.clearstatcache.php

Signed-off-by: Morris Jobke <hey@morrisjobke.de>
2018-01-12 13:59:58 +01:00
Morris Jobke 0eebff152a
Update license headers
Signed-off-by: Morris Jobke <hey@morrisjobke.de>
2017-11-06 16:56:19 +01:00
Joas Schilling 94f3fc63bc
Use ::class and fix missing doc
Signed-off-by: Joas Schilling <coding@schilljs.com>
2017-10-28 11:49:36 +02:00
Roeland Jago Douma ace7b69aa7
Fix copy from jailed storage
If we have a jailed storage we must also fix the internal path on copy.
Else we pass in the wrong path.

Signed-off-by: Roeland Jago Douma <roeland@famdouma.nl>
2017-08-09 11:56:31 +02:00