Commit Graph

1406 Commits (feat/database/query-result-fetch-associative-fetch-num)

Author SHA1 Message Date
Robin Appelman bd91c56539
get quota for user only when needed
always apply the wrapper but have the wrapper get the quota lazily only when an operation where quota is applied is performed

Signed-off-by: Robin Appelman <robin@icewind.nl>
2022-09-01 19:32:24 +07:00
Robin Appelman a9575a7029
handle cases where the hash context gets cleaned up before the hash wrapper
Signed-off-by: Robin Appelman <robin@icewind.nl>
2022-08-31 15:05:10 +07:00
Robin Appelman e9ba58ca61
remove leading slash for search results at mountpoint root
Signed-off-by: Robin Appelman <robin@icewind.nl>
2022-08-29 17:33:43 +07: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 +07:00
Julius Härtl 83b1415906
Only pass parent if paths match
As the user folder might be initialized by the root from two levels
down the hierarchy, passing this as a parent only works if the path matches

Signed-off-by: Julius Härtl <jus@bitgrid.net>
2022-08-24 22:20:32 +07:00
Julius Härtl b2d6435737
Avoid extra query for the parent node if we can pass it along
Signed-off-by: Julius Härtl <jus@bitgrid.net>
2022-08-24 22:20:32 +07:00
Robin Appelman b6f8b8da60 directly build the search filter for shared storage instead of setting up the source cache
Signed-off-by: Robin Appelman <robin@icewind.nl>
2022-08-17 11:58:57 +07:00
Vincent Petry 312b719acf
Merge pull request #32943 from nextcloud/unencrypted-size-revert-interface-changes
Revert interface changes from "store unencrypted size in the unencrypted_size column"
2022-08-17 11:36:16 +07:00
Vincent Petry 11d5a1d3df
Merge pull request #33550 from nextcloud/jail-search-post
optimize search post-processing for jail wrapper
2022-08-17 10:55:41 +07:00
Vincent Petry 2360d880fa
Merge pull request #33540 from nextcloud/mount-provider-migration
fix updating cached mounts that didn't have their mount provider set previously
2022-08-17 10:41:31 +07:00
Vincent Petry 082432e01c
Merge pull request #33551 from nextcloud/scanner-dont-update-same-size
don't update the folder size if we know it hasn't changed
2022-08-17 09:21:30 +07:00
Julius Härtl 999dced07c
Merge pull request #33559 from yeyulantu/bugfix-search-cache 2022-08-16 23:54:59 +07:00
Robin Appelman 457822c144 don't update the folder size if we know it hasn't changed
Signed-off-by: Robin Appelman <robin@icewind.nl>
2022-08-16 13:56:51 +07:00
Robin Appelman de63f6363f fix updating size when folder is empty
Signed-off-by: Robin Appelman <robin@icewind.nl>
2022-08-16 13:54:26 +07:00
Robin Appelman 1374cbee3e store unencrypted size in the unencrypted_size column
Signed-off-by: Robin Appelman <robin@icewind.nl>
2022-08-16 13:54:26 +07:00
Robin Appelman 10767d7779 fix updating cached mounts that didn't have their mount provider set previously
Signed-off-by: Robin Appelman <robin@icewind.nl>
2022-08-16 13:47:41 +07:00
Robin Appelman 9d6c2ce301 optimize search post-processing for jail wrapper
don't both asking the wrapped cache if we know it's not in our jail anyway

Signed-off-by: Robin Appelman <robin@icewind.nl>
2022-08-16 13:36:52 +07:00
Robin Appelman 5e375d9092 Revert "store unencrypted size in the unencrypted_size column"
This reverts commit 8238582e59.

Signed-off-by: Robin Appelman <robin@icewind.nl>
2022-08-16 12:07:14 +07:00
David fe3f4afd77
fixed the cache searchBuilder negative map
Signed-off-by: David <37280718+yeyulantu@users.noreply.github.com>
2022-08-16 17:59:02 +07:00
Carl Schwan 51b9847fad
Merge branch 'master' into display-name-cache-public
Signed-off-by: Carl Schwan <carl@carlschwan.eu>
2022-08-15 15:28:30 +07:00
Jasper Weyne 44f6c931e7
Merge branch 'master' into patch-2 2022-08-11 08:54:08 +07:00
Côme Chilliet 7ae6791737
Document all getIncomplete implementations as returning string|false
Signed-off-by: Côme Chilliet <come.chilliet@nextcloud.com>
2022-08-02 14:23:14 +07:00
Côme Chilliet cb271b759e
Fix dynamic property creations in test files
This fixes warnings in PHP 8.2

Signed-off-by: Côme Chilliet <come.chilliet@nextcloud.com>
2022-08-01 15:07:53 +07:00
Paweł Bogusławski a850424b1b Update Folder.php
Signed-off-by: Pawel Boguslawski <pawel.boguslawski@ib.pl>
2022-07-29 13:34:00 +07:00
Paweł Bogusławski 097b78594a Update Folder.php
Signed-off-by: Pawel Boguslawski <pawel.boguslawski@ib.pl>
2022-07-29 13:34:00 +07:00
Paweł Bogusławski 04baf69fea Update lib/private/Files/Node/Folder.php
Co-authored-by: Vincent Petry <vincent@nextcloud.com>
Signed-off-by: Pawel Boguslawski <pawel.boguslawski@ib.pl>
2022-07-29 13:34:00 +07:00
Pawel Boguslawski 9eb1a92fa4 Paths added to messages and message cleanup
This mod adds path to error messages. Without it it's difficult for example
to find what path causes permission problems.

Related: https://help.nextcloud.com/t/ocp-files-notpermittedexception-could-not-create-folder/133818
Related: https://help.nextcloud.com/t/could-not-create-folder-false-error/65962/
Author-Change-Id: IB#1121253
Signed-off-by: Pawel Boguslawski <pawel.boguslawski@ib.pl>
2022-07-29 13:34:00 +07:00
Côme Chilliet 472f4cad47
Merge pull request #33380 from luzpaz/fix/lib-private-typos
Fix typos in lib/private subdirectory
2022-07-28 09:17:48 +07:00
luz paz 368f83095d Fix typos in lib/private subdirectory
Found via `codespell -q 3 -S l10n -L jus ./lib/private`

Signed-off-by: luz paz <luzpaz@github.com>
2022-07-27 08:52:17 +07:00
Robin Appelman 61fdd91dcf
don't set `null` as a bundle path
Signed-off-by: Robin Appelman <robin@icewind.nl>
2022-07-27 12:58:07 +07:00
Robin Appelman 13eef55a92
always triger setup of builtin storage wrappers
Signed-off-by: Robin Appelman <robin@icewind.nl>
2022-07-21 16:36:32 +07:00
Carl Schwan 6c3c7a5e4d
Merge pull request #32981 from nextcloud/typing/carl/simplefs
Add typing to SimpleFS
2022-07-18 12:34:11 +07:00
Carl Schwan f6b37e6912
Merge pull request #33064 from nextcloud/feat/capped-memorycache-ocp
Move CappedMemoryCache to OCP
2022-07-18 10:32:11 +07:00
Daniel 52dc51cde3
Merge pull request #32963 from nextcloud/s3-crt-bundle-download
also use nextcloud certificate bundle when downloading from s3
2022-07-18 09:51:19 +07:00
Carl Schwan 19a36b58a6 Add typing to SimpleFS
- Fix putContent sometimes return a bool and sometimes nothing

Signed-off-by: Carl Schwan <carl@carlschwan.eu>
2022-07-14 17:20:51 +07:00
Carl Schwan d5c23dbb9f Move CappedMemoryCache to OCP
This is an helpful helper that should be used in more place than just
server and this is already the case with groupfodlers, deck, user_oidc
and more using it, so let's make it public

Signed-off-by: Carl Schwan <carl@carlschwan.eu>
2022-07-14 15:54:31 +07:00
Jonas 74e9ef0fb1
Fix listening for circle events in SetupManager
So far, SetupManager listened for deprecated events that are no longer
triggered. Instead, use the circle events that actually get triggered
when adding or removing a circle or circle member. Also, these events
get triggered on each instance of a globalscale setup.

Fixes: #33210

Signed-off-by: Jonas <jonas@freesources.org>
2022-07-12 13:28:21 +07:00
Robin Appelman f1486890d7
only use nextcloud bundle when explicitly enabled
Signed-off-by: Robin Appelman <robin@icewind.nl>
2022-07-05 16:06:55 +07:00
Robin Appelman bffa67c48b
also use nextcloud certificate bundle when downloading from s3
Signed-off-by: Robin Appelman <robin@icewind.nl>
2022-07-05 15:57:54 +07:00
Jonas 7d07e06bfe Check whether entry is of type ICacheEntry in Cache->remove()
In some scenarios (file not in cache, but partial data of it in the
object), Cache->get() might return an array, which leads to errors like
"Call to a member function getId() on array".

So check whether the returned entry is of type ICacheEntry before doing
operations on it in Cache->remove().

Fixes: #33023

Signed-off-by: Jonas <jonas@freesources.org>
2022-06-29 10:47:07 +07:00
Carl Schwan 46a49dee8a
Merge pull request #32994 from nextcloud/fix/extended-query-search
Search without join on filecache_extended
2022-06-29 11:58:20 +07:00
Carl Schwan a1bc770043
Merge pull request #32982 from nextcloud/fix/metadata-extraction
Fix metadata extraction
2022-06-28 15:34:38 +07:00
Côme Chilliet 64bff27c99
Merge pull request #32960 from nextcloud/fix/avoid-using-undeclared-properties
Fix PHP 8.2 warnings about undeclared properties
2022-06-28 12:05:16 +07:00
Carl Schwan f326b54e53 Search without join on filecache_extended
Signed-off-by: Carl Schwan <carl@carlschwan.eu>
2022-06-23 16:23:52 +07:00
Carl Schwan 940b5e8f0a Fix metadata extraction
The metadata extraction only happens when the size is not equal to 0,
but due to a regression in FileInfo the size is always zero.

This fix the regression.

Signed-off-by: Carl Schwan <carl@carlschwan.eu>
2022-06-22 17:27:09 +07:00
blizzz 2e10378052
Merge pull request #31475 from nextcloud/kofemann-patch-1
files: close open directory file descriptor on error path
2022-06-21 18:44:05 +07:00
Côme Chilliet 1bd5222224
Fix PHP 8.2 warnings about undeclared properties
Signed-off-by: Côme Chilliet <come.chilliet@nextcloud.com>
2022-06-21 16:17:52 +07:00
Vincent Petry 8809de1eef
Merge pull request #31966 from nextcloud/unencrypted-size
store unencrypted size in the unencrypted_size column
2022-06-13 11:55:37 +07:00
Vincent Petry bea755f153
Merge pull request #32723 from MartinBrugnara/master
Expose umask override value as config parameter: localstorage.umask
2022-06-10 11:23:31 +07:00
Vincent Petry 56b1453945
Merge pull request #32768 from nextcloud/fs-setup-onetime-earlier
perform onetime setup earlier to ensure wrappers are registered on time
2022-06-10 11:21:54 +07:00
Robin Appelman 5c768f980e
fix mounts mounted at the users home
this fixes external storages with '/' as mountpoint

Signed-off-by: Robin Appelman <robin@icewind.nl>
2022-06-09 19:21:56 +07:00
Robin Appelman a937ab03dd
perform onetime setup earlier to ensure wrappers are registered on time
this fixes an issue with wrappers like encryption not always being applied to mountpoint that create the storage object directly (such as external storage)

Signed-off-by: Robin Appelman <robin@icewind.nl>
2022-06-08 18:49:54 +07:00
Robin Appelman 499995b37a
handle stream wrappers in SeekableHttpStream
Signed-off-by: Robin Appelman <robin@icewind.nl>
2022-06-08 17:52:27 +07:00
Jasper Weyne 0633a1d9f5
Disable ~/.aws/config access by S3ConnectionTrait
This commit sets the 'use_aws_shared_config_files' option to false, in order to disable configuration loading from ~/.aws/config by the AWS SDK, specifically the S3Client. It is a continuation of #27040, as that PR only changed the behaviour of the CredentialsProvider; this change affects the ConfigurationProvider as well.

Signed-off-by: Jasper Weyne <jasperweyne@gmail.com>
2022-06-07 13:39:14 +07: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 +07:00
Robin Appelman 8238582e59
store unencrypted size in the unencrypted_size column
Signed-off-by: Robin Appelman <robin@icewind.nl>
2022-06-02 16:07:00 +07:00
Julius Härtl 0f0e74a78c Cleanup temporary files after finishing the write to object storage
Signed-off-by: Julius Härtl <jus@bitgrid.net>
2022-06-02 12:57:18 +07:00
Daniel Kesselberg f399fd41ec
Fix docblock for return type
Signed-off-by: Daniel Kesselberg <mail@danielkesselberg.de>
2022-05-27 20:05:46 +07:00
Simon L 18dd460720
Merge pull request #26813 from nextcloud/feature/files-search-tags
Files: Extend search to also cover tags
2022-05-18 10:58:02 +07:00
Robin Appelman 6d6662ec68
expose displayname cache trough a public interface
Signed-off-by: Robin Appelman <robin@icewind.nl>
2022-05-18 03:47:34 +07:00
Marcel Klehr f755ee0868 Files: Extend search to also cover tags
fixes #326

Signed-off-by: Marcel Klehr <mklehr@gmx.net>
2022-05-17 21:05:09 +07:00
John Molakvoæ fe33e9c08c
Merge pull request #32250 from nextcloud/cleanup/cappedmemorycache 2022-05-13 08:27:28 +07:00
Carl Schwan ec6b83cc18 Add stricter psalm type for CappedMemoryCache
Signed-off-by: Carl Schwan <carl@carlschwan.eu>
2022-05-12 15:06:18 +07:00
Carl Schwan a392cd70fb Make it possible to get the appdata folder using the public API
Signed-off-by: Carl Schwan <carl@carlschwan.eu>
2022-05-11 23:28:37 +07:00
Vincent Petry fe24091ffb
Merge pull request #32110 from plumbeo/binary-encoding-4
Save encrypted files in binary format
2022-05-05 18:04:06 +07:00
Vincent Petry 4147e1233a
Merge pull request #32152 from nextcloud/bugfix/32151/allow-compatibility-wrapper-local-ext-storage
Allow compatibility wrapper on local external storage
2022-05-05 08:18:52 +07:00
plumbeo 1258caeab7 Save encrypted files in binary format
Default to the more space-efficient binary encoding for newly encrypted files
instead of the traditional base64 encoding, eliminating the 33% overhead.

The new option 'encryption.use_legacy_encoding' allows to force the legacy
encoding format if needed. Files encoded in the old format remain readable.

Based on https://github.com/owncloud/encryption/pull/224 and
https://github.com/owncloud/core/pull/38249 by karakayasemi.

Signed-off-by: plumbeo <plumbeo@users.noreply.github.com>
2022-05-04 17:38:25 +07:00
Côme Chilliet 459202d54c
Merge pull request #31752 from nextcloud/fix/remove-still-more-ilogger
Move away from deprecated ILogger
2022-05-02 10:15:10 +07:00
Carl Schwan dbdb9f6f11
Merge pull request #32034 from nextcloud/bugfix/noid/satisfy-binary-operation-order
Make the binary operation order explicit
2022-04-27 11:53:18 +07:00
Côme Chilliet 2b07031d3e
composer run cs:fix
Signed-off-by: Côme Chilliet <come.chilliet@nextcloud.com>
2022-04-26 16:52:53 +07: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 +07:00
Côme Chilliet 069477e608
Migrate more classes of lib/private to LoggerInterface
Signed-off-by: Côme Chilliet <come.chilliet@nextcloud.com>
2022-04-26 16:52:52 +07:00
Vincent Petry 23403ef693
Allow compatibility wrapper on local external storage
The check was likely in place to prevent adding the wrapper on the root
and home storage, which is not possible anyway since the encoding option cannot
be set on that mount.

Signed-off-by: Vincent Petry <vincent@nextcloud.com>
2022-04-26 09:27:29 +07:00
Vincent Petry 6935baa568
Merge pull request #32084 from nextcloud/root-setup-groupfolders
only need to setup root for groupfolders
2022-04-25 19:35:59 +07:00
Robin Appelman f7413b9afc
Merge pull request #32074 from nextcloud/mysql-search-ignore-index-2
tell mysql to ignore the sort index for search queries
2022-04-25 11:23:51 +07:00
Vincent Petry ff385dc679
Merge pull request #32082 from nextcloud/directory-content-lazy-owner
use a lazy user for the file owner when listing a directory
2022-04-25 11:44:44 +07:00
Vincent Petry e693781c21
Merge pull request #32079 from nextcloud/directory-listing-optimize-add-submount
optimize adding submount info to directory content
2022-04-25 11:44:26 +07:00
Robin Appelman b36dfd8f11 Only need to setup root for groupfolders
Signed-off-by: Robin Appelman <robin@icewind.nl>
2022-04-22 17:47:08 +07:00
Julius Härtl fb59875071
Merge pull request #32040 from nextcloud/full-setup-only-new
only register mounts that are new from providers that are new during a full setup
2022-04-22 17:03:09 +07:00
Robin Appelman 7a6c724a81 Use a lazy user for the file owner when listing a directory
Only getUID and getDisplayName are called on the file owner objects anyway
and we can get this information often without DB request

Signed-off-by: Robin Appelman <robin@icewind.nl>
2022-04-22 17:02:37 +07:00
Robin Appelman 9f0ba3adc2
optimize adding submount info to directory content
no need to loop when we can do a hashtable lookup

Signed-off-by: Robin Appelman <robin@icewind.nl>
2022-04-22 15:50:14 +07:00
Robin Appelman a4e120c203
tell mysql to ignore the sort index for search queries
Signed-off-by: Robin Appelman <robin@icewind.nl>
2022-04-22 13:42:33 +07:00
Robin Appelman bbf283f818
cache fullSetupRequired locally
no need to hit redis every time

Signed-off-by: Robin Appelman <robin@icewind.nl>
2022-04-21 16:00:28 +07:00
Robin Appelman 561a2071e4
only register mounts that are new from providers that are new during a full setup
this fixes cases where during the (partial) setup of a shared mount a full setup is triggered

Signed-off-by: Robin Appelman <robin@icewind.nl>
2022-04-21 12:53:50 +07:00
Joas Schilling 49e62149d8
Make the binary operation order explicit
Signed-off-by: Joas Schilling <coding@schilljs.com>
2022-04-21 10:47:26 +07:00
Robin Appelman caebdc2a55
Merge pull request #32024 from nextcloud/local-metadata-forbidden
ignore forbidden files while scanning local storage
2022-04-20 12:34:23 +07: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 +07:00
Arthur Schiwon 1ec4563c2e
log stacktrace for 'Backends provided no user object'
Signed-off-by: Arthur Schiwon <blizzz@arthur-schiwon.de>
2022-04-20 12:15:39 +07:00
Carl Schwan 7817845538 Add a metadata service to store file metadata
Signed-off-by: Carl Schwan <carl@carlschwan.eu>
2022-04-13 14:06:29 +07:00
Robin Appelman b65d214f15
perform a setup if we can't find any mounts containing a file
Signed-off-by: Robin Appelman <robin@icewind.nl>
2022-04-11 19:15:58 +07:00
Vincent Petry 1b819b8649
Merge pull request #31901 from nextcloud/fs-setup-tweaks
Filesystem setup tweaks
2022-04-08 17:47:36 +07:00
Vincent Petry 0d7d28e530
Merge pull request #31676 from nextcloud/enh/ocp-owner-lock
Add public API for owner based file locking
2022-04-08 17:43:26 +07:00
Robin Appelman 499749dbc1
more preset metadata for LazyUserFolder
Signed-off-by: Robin Appelman <robin@icewind.nl>
2022-04-08 15:09:40 +07:00
Robin Appelman 54e52e9b5e
always do full setup for home folder with submounts
Signed-off-by: Robin Appelman <robin@icewind.nl>
2022-04-08 15:05:43 +07:00
Robin Appelman bdc86e9486
add missing return
Signed-off-by: Robin Appelman <robin@icewind.nl>
2022-04-08 15:04:35 +07:00
Robin Appelman 9834350ac3
Merge pull request #31713 from nextcloud/fed-performance
Federated share performance improvements
2022-04-07 18:53:36 +07:00
Julius Härtl 9b408d556d
Adapt LockScope to LockContext rename
Signed-off-by: Julius Härtl <jus@bitgrid.net>
2022-04-07 11:52:16 +07:00
Robin Appelman 5e69f98c16
sh
Signed-off-by: Robin Appelman <robin@icewind.nl>
2022-04-06 18:08:13 +07:00
Robin Appelman 151c800397
allow reusing known folder info when getting directory contents
Signed-off-by: Robin Appelman <robin@icewind.nl>
2022-04-06 14:40:34 +07:00
Robin Appelman 9b1abd6fac
save filesystem node in dav node
Signed-off-by: Robin Appelman <robin@icewind.nl>
2022-04-06 14:40:31 +07:00
Robin Appelman 791dc509d3
only setup home mount when getting home folder
Signed-off-by: Robin Appelman <robin@icewind.nl>
2022-04-06 13:13:32 +07:00
Côme Chilliet fff26ad006
Merge pull request #31754 from nextcloud/fix/view-inconsistent-if-conditions
Fix incorrect if conditions in View
2022-04-05 18:06:42 +07:00
Vincent Petry 0cdf03b733
Merge pull request #31773 from nextcloud/share-limited-owner-setup
Perform a limited filesystem setup when getting share source
2022-04-05 17:05:57 +07:00
Côme Chilliet 140624d551
composer run cs:fix
Signed-off-by: Côme Chilliet <come.chilliet@nextcloud.com>
2022-04-05 16:47:13 +07:00
Côme Chilliet d36a1a7bf6 Exit early if $storage is falsy in View::getDirectoryContent
Signed-off-by: Côme Chilliet <come.chilliet@nextcloud.com>
2022-04-05 13:58:49 +07:00
Côme Chilliet 916fbe81c6 Fix incorrect if conditions in View
($something->getPermissions() && Constants::PERMISSION_READ) does not
  make sense as PERMISSION_READ contant is 1 this will always evaluate to
  true.
getPersmissions is returning an int which is a bitwise combination as
  documented in the interface, so it should be used with bit operators.

Signed-off-by: Côme Chilliet <come.chilliet@nextcloud.com>
2022-04-05 13:58:49 +07:00
John Molakvoæ 47cc5a9405
Merge pull request #29510 from nextcloud/backport/27378/master 2022-04-04 22:15:01 +07:00
Joas Schilling a44671d396
Merge pull request #31816 from nextcloud/bugfix/noid/deduplicate-storage-id-before-reusing
Deduplicate storage ids in list before reusing
2022-04-04 19:00:22 +07:00
Robin Appelman cc5e26bb14
Merge pull request #31776 from nextcloud/storage-id-cache-bi-directional
cache storage id mapping both ways
2022-04-04 14:50:23 +07:00
Robin Appelman f9a5fb99fd
use the same cached propfind for free space for dav storage
Signed-off-by: Robin Appelman <robin@icewind.nl>
2022-04-04 16:48:31 +07:00
Robin Appelman 5e2dd29aaf
only request free space once for external shares
Signed-off-by: Robin Appelman <robin@icewind.nl>
2022-04-04 16:48:27 +07:00
Robin Appelman 89d3cd1447
don't overwrite the etag from storage backends that already provide "good" etags
Signed-off-by: Robin Appelman <robin@icewind.nl>
2022-04-04 16:48:18 +07:00
Robin Appelman d84f9fa9bb
rename cached fileinfo on rename
Signed-off-by: Robin Appelman <robin@icewind.nl>
2022-04-04 15:40:28 +07:00
Robin Appelman 754603a04e
dont needlessly resolve path when getting internalPath/storage from Node
Signed-off-by: Robin Appelman <robin@icewind.nl>
2022-04-04 15:40:24 +07:00
Robin Appelman 8b12c75ca2
don't do a full setup for `findByStorageId`
Signed-off-by: Robin Appelman <robin@icewind.nl>
2022-04-04 15:40:20 +07:00
Robin Appelman 44a8ebdc1f
optimize getById on LazyUserFolder to not require a full fs setup
Signed-off-by: Robin Appelman <robin@icewind.nl>
2022-04-04 15:40:16 +07:00
Robin Appelman 700444e218
split out some path manipulation logic
Signed-off-by: Robin Appelman <robin@icewind.nl>
2022-04-04 15:40:12 +07:00
Robin Appelman 99ac46d8f5
allow getting mounts by providers
Signed-off-by: Robin Appelman <robin@icewind.nl>
2022-04-04 14:57:56 +07:00
Julius Härtl 40f1ad60c2
Add public API for owner based locking
Signed-off-by: Julius Härtl <jus@bitgrid.net>
2022-04-04 09:02:56 +07:00
Joas Schilling d3b9d49c22
Deduplicate storage ids in list before reusing
Signed-off-by: Joas Schilling <coding@schilljs.com>
2022-04-04 07:07:48 +07:00
Robin Appelman ac657b0f06
cache storage id mapping both ways
Signed-off-by: Robin Appelman <robin@icewind.nl>
2022-03-31 14:35:42 +07:00
Robin Appelman ff666e648a Add dav plugin to trigger recalculating of checksums
Signed-off-by: Robin Appelman <robin@icewind.nl>
2022-03-31 07:44:13 +07:00
Louis 7d2cb35988
Merge pull request #31632 from Maaxxs/fix-undefined-index-dav
Fixes the undefined index error with the DAV property getlastmodified
2022-03-29 13:53:15 +07:00
Côme Chilliet 765999f454
Merge pull request #31609 from nextcloud/fix/migrate-away-from-ilogger
Migrate from ILogger to LoggerInterface in lib/private
2022-03-29 09:39:38 +07:00
Max Kunzelmann 2952c7d01f Use the null coalescing operator to set the value of `size`.
Signed-off-by: Max Kunzelmann <maxdev@posteo.de>
2022-03-28 22:26:45 +07:00
Vincent Petry 1bc86a95c4
Make phpcs happy in MountProviderCollection
Signed-off-by: Vincent Petry <vincent@nextcloud.com>
2022-03-24 20:26:42 +07:00
Robin Appelman 881e107543
Apply suggestions from code review
Co-authored-by: Louis <6653109+artonge@users.noreply.github.com>
Co-authored-by: Côme Chilliet <91878298+come-nc@users.noreply.github.com>

Signed-off-by: Robin Appelman <robin@icewind.nl>
2022-03-24 17:41:37 +07:00
Robin Appelman 1179873f33
add comment for getMountForPath loop
Signed-off-by: Robin Appelman <robin@icewind.nl>
2022-03-24 17:36:59 +07:00
Robin Appelman b7a7425fbd
make mount cache duration configurable
Signed-off-by: Robin Appelman <robin@icewind.nl>
2022-03-24 17:36:53 +07:00
Robin Appelman 63ad99ba4a
fix method name
Signed-off-by: Robin Appelman <robin@icewind.nl>
2022-03-24 17:04:01 +07:00
Robin Appelman f7c942a943
caching of userfolder
Signed-off-by: Robin Appelman <robin@icewind.nl>
2022-03-24 17:03:58 +07:00
Robin Appelman 70c37c2717
fmt
Signed-off-by: Robin Appelman <robin@icewind.nl>
2022-03-24 17:03:55 +07:00
Robin Appelman 89919b0e24
invalidate mount cache on circles change
Signed-off-by: Robin Appelman <robin@icewind.nl>
2022-03-24 17:03:52 +07:00
Robin Appelman 15c9a3114a
perform full setup if a cached mount doesn't have a provider set
Signed-off-by: Robin Appelman <robin@icewind.nl>
2022-03-24 17:03:16 +07:00
Robin Appelman d342c764f2
don't double setup provider when calling `setupForUser` after `setupForPath`
Signed-off-by: Robin Appelman <robin@icewind.nl>
2022-03-24 17:03:13 +07:00
Robin Appelman 6b085b6fd1
add logic to perform a full filesystem setup when needed
Signed-off-by: Robin Appelman <robin@icewind.nl>
2022-03-24 17:03:10 +07:00
Robin Appelman 506d29c095
update cached mounts when only specific providers have been setup
Signed-off-by: Robin Appelman <robin@icewind.nl>
2022-03-24 17:01:55 +07:00
Robin Appelman 79f6742410
improve lazy UserFolder
Signed-off-by: Robin Appelman <robin@icewind.nl>
2022-03-24 17:01:49 +07:00
Robin Appelman 19c64cf8b6
setup only relevant mounts when possible
Signed-off-by: Robin Appelman <robin@icewind.nl>
2022-03-24 17:01:46 +07:00
Robin Appelman 55d943fd4b
fixed when accessing static filesystem calls before setup
Signed-off-by: Robin Appelman <robin@icewind.nl>
2022-03-24 17:01:42 +07:00
Robin Appelman 469a684d45
allow getting mounts by provider
Signed-off-by: Robin Appelman <robin@icewind.nl>
2022-03-24 17:01:38 +07:00
Robin Appelman 04052a9594
allow getting cached mounts by path from the mount cache
Signed-off-by: Robin Appelman <robin@icewind.nl>
2022-03-24 17:01:12 +07:00
Robin Appelman 3fc5c97282
return a lazy folder from Root::getUserFolder
Signed-off-by: Robin Appelman <robin@icewind.nl>
2022-03-24 17:01:08 +07:00
Robin Appelman 46d0eef8da
allow setting some metadata in the lazyfolder without having to get the real folder
Signed-off-by: Robin Appelman <robin@icewind.nl>
2022-03-24 17:01:01 +07:00
Côme Chilliet e8c1f75064
Fixing psalm errors
Encryption constructor is problematic and should still be fixed later.

Signed-off-by: Côme Chilliet <come.chilliet@nextcloud.com>
2022-03-24 16:21:26 +07:00
Côme Chilliet ea23523c70
Adapt more code to migration to LoggerInterface
Signed-off-by: Côme Chilliet <come.chilliet@nextcloud.com>
2022-03-24 16:21:25 +07:00
Côme Chilliet 6be7aa112f
Migrate from ILogger to LoggerInterface in lib/private
Signed-off-by: Côme Chilliet <come.chilliet@nextcloud.com>
2022-03-24 16:21:25 +07:00
Max Kunzelmann 3a135f0c5f Set `mtime` to null instead of false if `getlastmodified` does not exist.
Signed-off-by: Max Kunzelmann <maxdev@posteo.de>
2022-03-23 15:02:01 +07:00
Max Kunzelmann e0a5fe649a Fix typo.
Signed-off-by: Max Kunzelmann <maxdev@posteo.de>
2022-03-20 11:07:36 +07:00
Max Kunzelmann ee888875bb Fixes the undefined index error with the DAV property getlastmodified
Signed-off-by: Max Kunzelmann <maxdev@posteo.de>
2022-03-20 00:38:07 +07:00
Robin Appelman 6fae598390
Merge pull request #31608 from nextcloud/scanner-performance2
some file scanner performance improvements
2022-03-17 22:06:45 +07:00
Robin Appelman 84f464550a
some file scanner performance improvements
Signed-off-by: Robin Appelman <robin@icewind.nl>
2022-03-17 22:21:16 +07:00
Robin Appelman 577b1fa856
setup for current user when finding mounts in the root
Signed-off-by: Robin Appelman <robin@icewind.nl>
2022-03-17 14:56:49 +07:00
Robin Appelman 1156214a26
don't try to get custom certs for s3 primary storage
Signed-off-by: Robin Appelman <robin@icewind.nl>
2022-03-15 15:50:08 +07:00
Robin Appelman 194a21f374
use the nextcloud certificate bundle for s3
Signed-off-by: Robin Appelman <robin@icewind.nl>
2022-03-14 18:09:48 +07:00
Robin Appelman e8872f01ae
Merge pull request #31431 from nextcloud/fs-setup-manager
Unify/cleanup filesystem setup
2022-03-08 14:50:25 +07:00
Pytal 232af474a8
Merge pull request #31418 from nextcloud/enh/simple-file-extension 2022-03-07 11:38:23 +07:00
Tiramisu Mokka 8190441335
files: close open directory file descriptor on error path 2022-03-07 10:19:58 +07:00
Robin Appelman 917c74e214
type fixes
Signed-off-by: Robin Appelman <robin@icewind.nl>
2022-03-04 16:30:16 +07:00
Robin Appelman 07a7dcb824
move user mountpoint setup to setupmanager
Signed-off-by: Robin Appelman <robin@icewind.nl>
2022-03-04 16:30:12 +07:00
Robin Appelman d81713e5c1
simplify setup of circular SetupManager<->Manager
Signed-off-by: Robin Appelman <robin@icewind.nl>
2022-03-04 16:30:09 +07:00
Robin Appelman 6c1d051ecd
add template annotations to CappedMemoryCache
Signed-off-by: Robin Appelman <robin@icewind.nl>
2022-03-04 16:30:06 +07:00
Robin Appelman 22875bf367
move logic to decide what to setup to setupmanager
Signed-off-by: Robin Appelman <robin@icewind.nl>
2022-03-04 16:30:03 +07:00
Robin Appelman 1c468129af
adjust tests to new fs setup
Signed-off-by: Robin Appelman <robin@icewind.nl>
2022-03-04 16:29:59 +07:00
Robin Appelman 5c0fe93498
move teardown logic to SetupManager
Signed-off-by: Robin Appelman <robin@icewind.nl>
2022-03-04 16:29:50 +07:00
Robin Appelman 15ff65c12f
start moving filesystem setup logic to it's own place
Signed-off-by: Robin Appelman <robin@icewind.nl>
2022-03-04 16:29:47 +07:00
Robin Appelman 7630d7a934
more type hints for ICachedMountInfo and IMountManager
Signed-off-by: Robin Appelman <robin@icewind.nl>
2022-03-04 16:28:11 +07:00
Robin Appelman 8b22a463e9
Merge pull request #31266 from nextcloud/root-setup-mountprovider
move root mount setup to mountproviders
2022-03-04 13:44:05 +07:00
Christopher Ng 0571391b10 Extend simple file with extension getter
Signed-off-by: Christopher Ng <chrng8@gmail.com>
2022-03-04 06:11:53 +07:00
Joas Schilling 88f4e972c5
Don't set up full filesystem to check for certificates
Signed-off-by: Joas Schilling <coding@schilljs.com>
2022-02-26 00:40:12 +07:00
Robin Appelman b0ce876f41
return dummy availability if storage is not found in cache
Signed-off-by: Robin Appelman <robin@icewind.nl>
2022-02-25 15:25:13 +07:00
Robin Appelman 8b7c8447a0
move root mount setup to mountproviders
Signed-off-by: Robin Appelman <robin@icewind.nl>
2022-02-24 17:21:42 +07:00
Robin Appelman cfb7923e08
store mountprovider for each mount in the mounts table
this enabled more fine grained filesystem setup

Signed-off-by: Robin Appelman <robin@icewind.nl>
2022-02-23 18:02:33 +07:00
Louis Chemineau bc2c02f451 Wrap S3 multipart upload exception
Signed-off-by: Louis Chemineau <louis@chmn.me>
2022-02-16 14:56:14 +07:00
Louis Chemineau 0b768c17d2 Wrap S3 multipart upload exception
Signed-off-by: Louis Chemineau <louis@chmn.me>
2022-02-15 17:35:12 +07:00
Vincent Petry 787716613f
Merge pull request #31035 from paierlep/fix/occ_scan_no_files_error
Removes misleading error message in occ files:scan for new users.
2022-02-10 18:07:21 +07:00
Robin Appelman 2673775f6e
fix fs cache test user setup
Signed-off-by: Robin Appelman <robin@icewind.nl>
2022-02-09 16:01:28 +07:00
Robin Appelman 1ab58eff0f
pass user object during fs init
Signed-off-by: Robin Appelman <robin@icewind.nl>
2022-02-09 16:01:24 +07:00
Robin Appelman 0217949715
only setup part of the filesystem for appdata requests
Signed-off-by: Robin Appelman <robin@icewind.nl>
2022-02-09 16:01:21 +07:00
Christian Paier 9476ce70ed Removes misleading error message in occ files:scan for new users.
Previously the occ files:scan command printed an error message for any
new users without any files/folders in the data directory.
With this change only users with any file/folder is scanned.

This fixes #25433.

Signed-off-by: Christian Paier <hallo+git@cpaier.com>
2022-02-05 23:54:56 +07:00
MichaIng ba1338e680 Return 404 when AJAX tries to list dir content but file given
Due to a code mistake, the expected 404 return when AJAX tries to list a directory content with a non-directory file path given, does not happen. It instead fails with another exception.

This commit restores the original intention to return 404 in the first place when passing a non-directory path with the "dir" parameter.

Signed-off-by: MichaIng <micha@dietpi.com>
2022-01-26 16:11:50 +07:00
Côme Chilliet 5cca86ce19
Remove redundant if clause
Signed-off-by: Côme Chilliet <come.chilliet@nextcloud.com>
2022-01-25 16:53:35 +07:00
Côme Chilliet 35dcda36a3
Fix OC\Files\Storage\DAV::hasUpdated when cache is not set
Fixes the test OCA\Files_External\Tests\Storage\WebdavTest::testStat on
 PHP>=7.4

Signed-off-by: Côme Chilliet <come.chilliet@nextcloud.com>
2022-01-25 16:53:19 +07:00
Vincent Petry 4903cb8db4
Merge pull request #29866 from nextcloud/isset-size
Check if size value is set
2022-01-17 10:59:52 +07:00
Vincent Petry cfafd79706
Merge pull request #30631 from nextcloud/fix/update_encrypted_version
updateEncryptedVersion: cleanup on target if cache already got renamed
2022-01-14 09:45:08 +07:00
Carl Schwan cbf9064b8e
Fix psalm issues
Signed-off-by: Carl Schwan <carl@carlschwan.eu>
2022-01-13 12:30:27 +07:00
Carl Schwan 695165260f
Add helper method in Wrapper
Signed-off-by: Carl Schwan <carl@carlschwan.eu>
2022-01-13 10:39:36 +07:00
Carl Schwan 89d109a4d9
Merge pull request #30508 from nextcloud/fix/psaml-bin
Fix psalm not running
2022-01-13 09:51:04 +07:00
Carl Schwan 6312c0df69
Check style update
Signed-off-by: Carl Schwan <carl@carlschwan.eu>
2022-01-13 00:19:07 +07:00
Carl Schwan aeecb72e96
Fix a few psalm issues and moved back to psalm/phar 4.18
Signed-off-by: Carl Schwan <carl@carlschwan.eu>
2022-01-12 20:03:06 +07:00
Jonas Meurer a2f4c62c19
updateEncryptedVersion: cleanup on target if cache already got renamed
When moving a file to trash with encryption enabled, the cache gets
moved before the actual file. According to @icewind1991 this is in order
to not break object storage.

When moving a file from an unencrypted storage (e.g. a collectives
storage) to the encrypted trashbin storage, this causes errors, see

This commit fixes it by doing `updateEncryptedVersion()` on the target
cache entry *if* the source cache entry doesn't exist anymore, but the
corresponding target cache entry does exist already.

Fixes: #26544

Signed-off-by: Jonas Meurer <jonas@freesources.org>
2022-01-12 15:47:08 +07:00
Vincent Petry be590df588
Fix fail when keys/files folder already exists
Fixes an issue with transfer ownership in move mode where the folder
"files_encryption/keys/files" already exists.

Instead of failing, its existence is checked before calling mkdir.

Signed-off-by: Vincent Petry <vincent@nextcloud.com>
2022-01-10 11:15:22 +07:00
Julius Härtl 2aac757805
Make max size for single put uploads configurable
Signed-off-by: Julius Härtl <jus@bitgrid.net>
2021-12-29 13:30:22 +07:00
Julius Härtl 6f986519fe
Merge pull request #28610 from nextcloud/enh/preview-cleanup-query 2021-12-28 13:20:02 +07:00
Julius Härtl e475dfe16c
Fix php-cs for S3ConnectionTrait.php
Signed-off-by: Julius Härtl <jus@bitgrid.net>
2021-12-21 21:35:46 +07:00
Julius Härtl 1acfbd0b06
Merge pull request #27493 from cuppett/cuppett/simplify-aws-credential-provider 2021-12-21 11:58:52 +07:00
Pytal c019e33b99
Merge pull request #30160 from nextcloud/bugfix/noid/encryption-wrapper-fclose-check 2021-12-09 15:59:51 +07:00
Vincent Petry 6f81e60bce
Check resource before closing in encryption wrapper
In case of error there is no guarantee that $source or $target is set or
is a resource when handling an error.

Without this fix, there's a risk that fclose will fail and the actual
exception will not be thrown, making it impossible to find out about the
root cause.

Signed-off-by: Vincent Petry <vincent@nextcloud.com>
2021-12-09 11:28:10 +07:00
acsfer 074a9a5e88
Switch logical operators
Unless there is a good reason to keep actual ones 👀
2021-12-03 16:05:19 +07:00
Robin Appelman f5fe887b4b
background scan the source storage when a background scan on a storage jail is triggered
Signed-off-by: Robin Appelman <robin@icewind.nl>
2021-12-02 17:34:58 +07:00
Joas Schilling 65d79bb592
Check for invalid characters before trimming
Signed-off-by: Joas Schilling <coding@schilljs.com>
2021-11-25 08:48:26 +07:00
acsfer 97e1855ed5
Typo 2021-11-24 11:55:06 +07:00
acsfer 0a0fd33773
Check if size value is set
Using `isset()` as it does not return true for array keys that correspond to a `null` value, while `array_key_exists()` does.
Fix #29865
2021-11-23 21:33:28 +07:00
Côme Chilliet 66bdda568a
Fix Guzzle function calls
Since 1.7.0 and 2.0 these functions are turned into static methods.
See https://github.com/guzzle/psr7#upgrading-from-function-api

Signed-off-by: Côme Chilliet <come.chilliet@nextcloud.com>
2021-11-23 09:28:57 +07:00
Côme Chilliet 113756db30
Fix ArrayAccess and JsonSerializable return types
First round of modifications for PHP 8.1

Signed-off-by: Côme Chilliet <come.chilliet@nextcloud.com>
2021-11-23 09:28:56 +07:00
Stephen Cuppett 4a6a2c2b48 Simplify S3ConnectionTrait to defaultProvider plus option
When we initially added the EC2 and ECS IAM role support in #24700,
we had to use a workaround by explicitly ordering the various providers
due to an inconsistency in the AWS SDK for PHP. We submitted a PR there
to get that squared away. Now, we've consumed that version upstream
for the SDK and can update our code here to be the most concise version
as well as position ourselves to pick up new methods as those become
available and prevalent in AWS (for acquiring credentials).

See also: https://github.com/nextcloud/server/pull/24700#issuecomment-747650892
See also: https://github.com/aws/aws-sdk-php/pull/2172

Signed-off-by: Stephen Cuppett <steve@cuppett.com>
2021-11-22 07:04:48 +07:00
Vincent Petry c42a890126
Merge pull request #29622 from nextcloud/feat/objectstore_multibucket-shift
Implement multibucket shift for ObjectStore
2021-11-19 17:26:44 +07:00
Vincent Petry 289624b79e
Merge pull request #29758 from nextcloud/disk_free_space-fix-php8
Check for `disk_free_space`
2021-11-19 17:14:08 +07: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 +07:00
Vincent Petry c92a0e4152
Normalize directory entries in Encoding wrapper
Directory entry file names are now normalized in getMetaData(),
getDirectoryContents() and opendir().

This makes the scanner work properly as it assumes pre-normalized names.

In case the names were not normalized, the scanner will now skip the
entries and display a warning when applicable.

Signed-off-by: Vincent Petry <vincent@nextcloud.com>
2021-11-17 09:43:25 +07:00
Vincent Petry 67ebe75d0e
Move storage encoding compatibility warning logic
The encoding check for file names is now happening the Scanner, and an
event will be emitted only if the storage doesn't contain the encoding
compatibility wrapper.

The event is listened to by the occ scan command to be able to display a
warning in case of file name mismatches when they have NFD encoding.

Signed-off-by: Vincent Petry <vincent@nextcloud.com>
2021-11-17 09:24:13 +07:00
Vincent Petry 39fe43b914
Normalize file name before existence check in scanner
The scanner would not find a NFD-encoded file name in an
existing file list that is normalized.

This normalizes the file name before scanning.

Fixes issues where scanning repeatedly would make NFD files flicker in
and out of existence in the file cache.

Signed-off-by: Vincent Petry <vincent@nextcloud.com>
2021-11-17 09:24:13 +07:00
John Molakvoæ 6ab2feaa54
Implement multibucket shift for ObjectStore
Signed-off-by: John Molakvoæ <skjnldsv@protonmail.com>
2021-11-11 15:09:28 +07:00
Vincent Petry 93fb33d863
Update lib/private/Files/Storage/Wrapper/Availability.php add void
Signed-off-by: Vincent Petry <vincent@nextcloud.com>

Co-authored-by: Carl Schwan <carl@carlschwan.eu>
2021-11-05 10:28:41 +07:00
Vincent Petry db29fd29ee
Return false in hasUpdated when storage is not available
Technically, saying that a storage has no updates when it's not
available is correct.

This makes it possible to retrieve the cache entry for the mount point
and also to list and remove unavailable federated shares.

Signed-off-by: Vincent Petry <vincent@nextcloud.com>
2021-11-05 09:48:52 +07:00
John Molakvoæ d6152bf98d
Fix psalm
Signed-off-by: John Molakvoæ <skjnldsv@protonmail.com>
2021-11-04 10:24:13 +07:00
John Molakvoæ 44c06a9641
Merge pull request #29502 from nextcloud/revert-27378-dav-recalc-checksum 2021-11-01 13:50:52 +07:00
Robin Appelman 118c647f61
properly handle cases where cache wrappers block access
`CacheWrapper::formatCacheEntry` can return false for files that should be filtered out

Signed-off-by: Robin Appelman <robin@icewind.nl>
2021-11-01 11:48:01 +07:00
John Molakvoæ 63d3931e80
Merge pull request #29281 from vijfhoek/master 2021-11-01 11:29:37 +07:00
John Molakvoæ d6a26b2536
Revert "add dav plugin to trigger recalculating of checksums" 2021-11-01 11:26:17 +07:00
John Molakvoæ e1bf5c1cd3
Merge pull request #27378 from nextcloud/dav-recalc-checksum 2021-11-01 11:25:21 +07:00
Carl Schwan df4e6bab69
Merge pull request #29115 from nextcloud/work/carl/correct-permissions-when-copying
Fix permissions when copying from ObjectStorage
2021-10-28 14:38:20 +07:00
Carl Schwan bfa60aaf27
Fix permissions when copying from ObjectStorage
Make sure that when a user copy a file from a directory they don't have
all permissions to a directory where they have more permissions, the
permissions are correctly set to the one from the parent taget folder.

This was caused by the ObjectStoreStorage::copyFromStorage using
the jailed storage and cache entry instead of the unjailed one like other
storages (the local one).
Steps to reproduce

+ Use object storage
+ Create a groupfolder with one group having full permission and another one
  who can just read files.
+ With an user who is in the second group, copy a file from the groupfolder to
  the home folder of this user.
+ The file in the home folder of the user will be read only and can't be deleted
  even though it is in their home folder and they are the owner. In oc_filecache,
  the permissions stored for this file are 1 (READ)

Signed-off-by: Carl Schwan <carl@carlschwan.eu>
2021-10-28 13:29:50 +07:00
alanmeeson 16f70e8647 Add type hint to fread_block $blockSize param & apply cs:fix.
Signed-off-by: alanmeeson <alan@carefullycalculated.co.uk>
2021-10-23 15:11:23 +07:00
Alan Meeson 44c332a46e Fix truncation of files upon read when using object store and encryption.
When using and object store as primary storage and using the default
encryption module at the same time,  any encrypted file would be truncated
when read, and a text error message added to the end.

This was caused by a combination of the reliance of the read functions on
on knowing the unencrypted file size,  and a bug in the function which
calculated the unencrypted file size for a given file.

In order to calculate the unencrypted file size,  the function would first
skip the header block, then use fseek to skip to the last encrypted block
in the file.  Because there was a corresponence between the encrypted and
unencrypted blocks, this would also be the last encrypted block.  It would
then read the final block and decrypt it to get the unencrypted length of
the last block.  With that, the number of blocks, and the unencrypted block
size, it could calculate the unencrypted file size.

The trouble was that when using an object store, an fread call doesn't
always get you the number of bytes you asked for, even if they are
available.  To resolve this I adapted the stream_read_block function from
lib/private/Files/Streams/Encryption.php to work here.  This function
wraps the fread call in a loop and repeats until it has the entire set of
bytes that were requested,  or there are no more to get.

This fixes the imediate bug, and should (with luck) allow people to get
their encrypted files out of Nextcloud now.  (The problem was purely on
the decryption side).  In the future it would be nice to do some
refactoring here.

I have tested this with image files ranging from 1kb to 10mb using
Nextcloud version 22.1.0 (the nextcloud:22.1-apache docker image), with
sqlite and a Linode object store as the primary storage.

Signed-off-by: Alan Meeson <alan@carefullycalculated.co.uk>
2021-10-23 15:11:23 +07:00
John Molakvoæ f4e4a85fcf
Merge pull request #27440 from nextcloud/is-file-handle 2021-10-23 11:18:52 +07:00
Julius Härtl 6b099ecfe5
Merge pull request #25392 from nextcloud/imountpoint-ocp-storage 2021-10-22 20:14:22 +07:00
John Molakvoæ 2be0eda47c
Merge pull request #29220 from nextcloud/s3-external-list 2021-10-22 12:06:05 +07:00
John Molakvoæ e673ec0b87
Merge branch 'master' into imountpoint-ocp-storage 2021-10-22 11:47:37 +07:00
John Molakvoæ 0a35937662
Merge pull request #26347 from J0WI/clean-path-regex 2021-10-22 11:42:30 +07: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 +07:00
John Molakvoæ a1c8b6e9eb
Merge pull request #28768 from nextcloud/check-file-exists 2021-10-18 09:54:22 +07:00
Sijmen Schoon 34600c78bb
Move query outside the loop and reduce chunk size to 1000
This involved changing CacheQueryBuilder\whereParentIn to take a
parameter name, renaming the function accordingly.

Signed-off-by: Sijmen Schoon <me@sijmenschoon.nl>
2021-10-17 20:57:28 +07:00
Sijmen Schoon c959bf2b42
Limit parameter count per query in Cache.removeChildren
Signed-off-by: Sijmen Schoon <me@sijmenschoon.nl>
2021-10-17 19:10:58 +07:00
Robin Appelman 55346b5d6c
more reliable return value for Watcher::checkUpdate
Signed-off-by: Robin Appelman <robin@icewind.nl>
2021-10-15 16:03:18 +07:00
Robin Appelman 09ffac5e6d
s3 external storage listing rework
Signed-off-by: Robin Appelman <robin@icewind.nl>
2021-10-15 15:35:02 +07:00
John Molakvoæ 739b67031b
Merge pull request #27194 from nextcloud/new-ftp 2021-10-14 10:29:24 +07:00
Daniel 9187e986e1
Merge pull request #28907 from nextcloud/bug/noid/close-stream-local
explicitly close source stream on local / encryption storage
2021-10-08 10:02:01 +07:00
Robin Appelman b3766fc99b
make param names consistent with interface for copy directory polyfill
Signed-off-by: Robin Appelman <robin@icewind.nl>
2021-10-07 17:19:44 +07:00
Vincent Petry f518710c52
Merge pull request #28608 from nextcloud/path-prefix-filter
generate a better optimized query for path prefix search filters
2021-10-07 17:16:39 +07:00
acsfer 98eac0fc05
Simplify :) 2021-10-04 17:21:37 +07:00
acsfer 8a8df49bc0
Replace `file_exists()` method by `is_file()` 2021-10-04 17:20:17 +07:00
acsfer 3a25183b66 Get `filesize()` if `file_exists()`
Should make sense.
2021-10-01 21:02:38 +07:00
Daniel Kesselberg be3f4edf1f
explicitly close source stream on encryption storage
Signed-off-by: Daniel Kesselberg <mail@danielkesselberg.de>
2021-09-21 17:42:22 +07: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 +07:00
Pauli Järvinen a335592f14 Support seeking also from the end of file on S3 storage
The PR https://github.com/nextcloud/server/pull/20033 added support
for `fseek` for  the S3 storage backend. However, the seek mode SEEK_END
was left out that time. This PR fills this gap.

Signed-off-by: Pauli Järvinen <pauli.jarvinen@gmail.com>
2021-09-11 17:43:50 +07:00
Julius Härtl 0670118470
Use storage filter when fetching previews to cleanup
Signed-off-by: Julius Härtl <jus@bitgrid.net>
2021-08-26 22:03:05 +07:00
Robin Appelman 7351059326
generate a better optimized query for path prefix search filters
Signed-off-by: Robin Appelman <robin@icewind.nl>
2021-08-26 19:07:52 +07:00
Vincent Petry 9c6bbfac45
Unregister enc stream wrapper for any exception
This prevents side effects in tests by properly cleaning up
even with expected exceptions.

Signed-off-by: Vincent Petry <vincent@nextcloud.com>
2021-08-26 10:52:23 +07:00
Vincent Petry e32d293346
Merge pull request #28476 from nextcloud/search-jail-insensitive
use case insensitive like when limiting search to jail
2021-08-24 08:59:35 +07:00
Robin Appelman c688703117
use getGetUnjailedRoot to determine if jailed search needs the path filter
Signed-off-by: Robin Appelman <robin@icewind.nl>
2021-08-23 16:27:53 +07:00
Robin Appelman fd5e11a81a
Add dav plugin to trigger recalculating of checksums
Signed-off-by: Robin Appelman <robin@icewind.nl>
2021-08-23 15:38:58 +07:00
Bernd Rederlechner 3866f388b1
Refactor writeObject to only use MultipartUpload when required
Signed-off-by: Bernd Rederlechner <Bernd.Rederlechner@t-systems.com>

Co-authored-by: Julius Härtl <jus@bitgrid.net>
2021-08-20 17:02:25 +07:00
Robin Appelman c48f9ffcdd
use case insensitive like when limiting search to jail
Signed-off-by: Robin Appelman <robin@icewind.nl>
2021-08-17 13:51:45 +07:00
acsfer 9324a74bba Handle files with is_file instead of file_exists
Should fix things like `fread(): read of 8192 bytes failed with errno=21 Is a directory`
2021-08-15 11:55:00 +07:00
Julius Härtl bc3c46362a Make sure that a empty directory can still be deleted when copied from another storage
Signed-off-by: Julius Härtl <jus@bitgrid.net>
2021-08-13 16:34:48 +07:00
Lukas Reschke 8193a0d1cf
Merge pull request #27923 from nextcloud/remove-flysystem-storage-class
Remove Flysystem storage class
2021-08-10 13:18:46 +07:00
John Molakvoæ 67e6468b9e
Merge pull request #28220 from nextcloud/get-by-id-multiple-mounts-single-storage 2021-08-09 19:27:23 +07:00
Carl Schwan 28970563a2
Remove some mentions of ownCloud from our api documentation
Signed-off-by: Carl Schwan <carl@carlschwan.eu>
2021-07-29 15:56:30 +07:00
Julius Härtl db7ffb0bf9
Merge pull request #28175 from nextcloud/jail-search-root 2021-07-29 09:27:53 +07:00
Robin Appelman 5c2e7c7d28
fix Folder->getById() when a single storage is mounted multiple times
Signed-off-by: Robin Appelman <robin@icewind.nl>
2021-07-28 17:21:04 +07:00
Robin Appelman 97aadbe46c
dont apply jail search filter is on the root
the extra '/' breaks things and the filter wouldn't do anything anyway except making the databases job harder

Signed-off-by: Robin Appelman <robin@icewind.nl>
2021-07-26 17:44:52 +07:00
Julius Härtl 3e67637a4a
Merge pull request #26463 from Worteks/fix-s3proxy 2021-07-14 23:32:05 +07:00
Lukas Reschke 28359571de Remove Flysystem storage class
This seems unused as per https://github.com/nextcloud/server/issues/27768
and may allow us to get rid of one more dependency.

Signed-off-by: Lukas Reschke <lukas@statuscode.ch>
2021-07-12 13:21:06 +07:00
Robin Appelman 9884344230
dont include folder being search in in the results
Signed-off-by: Robin Appelman <robin@icewind.nl>
2021-07-02 16:32:25 +07:00
blizzz 7589d5a176
Merge pull request #27533 from Rid/master
Fix scanner mistaking socket files for directories
2021-07-01 17:36:06 +07:00
blizzz 62675eb5c2
Merge pull request #27586 from nextcloud/bugfi/noid/objectstore-checksum
Reset checksum when writing files to object store
2021-07-01 17:30:54 +07:00
Maxime Besson 388a458cd5 fix(proxy): use accessor
Signed-off-by: Maxime Besson <maxime.besson@worteks.com>
2021-06-30 09:25:04 +07:00
Pytal 9ed379da22
Merge pull request #27635 from nextcloud/fix/datetime-constants
Fix usage of DateTime constants
2021-06-23 09:56:28 +07:00
Christoph Wurst 6d5cfe0c66
Move DateTime::RFC2822 to DateTimeInterface::2822
Signed-off-by: Christoph Wurst <christoph@winzerhof-wurst.at>
2021-06-23 15:30:43 +07:00
Lukas Reschke a70fd1bad1
Merge pull request #26344 from J0WI/fs-early-root
Return early if path is root
2021-06-23 15:21:56 +07:00
Julius Härtl 21db463bc9
Reset checksum when writing files to object store
Signed-off-by: Julius Härtl <jus@bitgrid.net>
2021-06-21 12:04:49 +07:00
Robin Appelman 8520717b4f
handle case where storage can't be created in getStorageRootId
Signed-off-by: Robin Appelman <robin@icewind.nl>
2021-06-17 14:32:38 +07:00
Rid 0469acfb20 Fix scanner mistaking socket files for directories
Signed-off-by: Rid <rid@cylo.io>
2021-06-17 11:44:44 +07:00
Robin Appelman 362cb2a11f
inject SearchBuilder
Signed-off-by: Robin Appelman <robin@icewind.nl>
2021-06-14 16:23:08 +07:00
Robin Appelman 66e10718c6
split of query building bits from searchhelper
Signed-off-by: Robin Appelman <robin@icewind.nl>
2021-06-14 16:11:40 +07:00
Robin Appelman f938daa6e4
update tests and fix some edge cases around new search
Signed-off-by: Robin Appelman <robin@icewind.nl>
2021-06-14 16:11:36 +07:00
Robin Appelman 27e50b24aa
some cleanup and documentation
Signed-off-by: Robin Appelman <robin@icewind.nl>
2021-06-14 16:11:32 +07:00
Robin Appelman 5d1d53c42e
perform file search in a single query
Signed-off-by: Robin Appelman <robin@icewind.nl>
2021-06-14 16:11:29 +07:00
Robin Appelman 9774fb1573
use searchoperation for storage filter instead of db expression
Signed-off-by: Robin Appelman <robin@icewind.nl>
2021-06-14 16:11:25 +07:00
Robin Appelman e198dc1b20
rework search api to allow searching on multiple caches at once
Signed-off-by: Robin Appelman <robin@icewind.nl>
2021-06-14 16:11:22 +07:00
Robin Appelman 581cbdc20c
[3rdparty] streams-0.7.4
Signed-off-by: Robin Appelman <robin@icewind.nl>
Signed-off-by: Christoph Wurst <christoph@winzerhof-wurst.at>
2021-06-10 07:58:32 +07:00
Morris Jobke 2ae60b42ab
Merge pull request #26494 from rigrig/fix-php8-deprecations
Fix some php 8 warnings
2021-06-07 23:30:59 +07:00
John Molakvoæ (skjnldsv) 215aef3cbd
Update php licenses
Signed-off-by: John Molakvoæ (skjnldsv) <skjnldsv@protonmail.com>
2021-06-04 22:02:41 +07:00
John Molakvoæ d0cf20cc51
Merge pull request #26792 from nextcloud/user-delete-cleanup-files
better cleanup of user files on user deletion
2021-06-02 17:02:00 +07:00
Richard de Boer 7990f95558 Check whether output buffering is active before turning it off
Before we just turned it off and @suppressed the error if ob was not active.
In PHP 8 this error is no longer suppressed, so try to not cause it at all.

Signed-off-by: Richard de Boer <git@tubul.net>
2021-05-29 14:14:52 +07:00
Richard de Boer f23d057ad9 Fix functions taking optional parameters before required ones
PHP 8 shows deprecation warnings about this, see #25806
Removes the "default" values, as they actually are required parameters anyway.

Signed-off-by: Richard de Boer <git@tubul.net>
2021-05-29 14:14:52 +07:00
Vincent Petry 0815be1ca8
Merge pull request #27062 from nextcloud/search-limit-offset-jail
properly use limit and offset for search in Jail wrapper
2021-05-25 15:47:09 +07:00
Morris Jobke 333665b43d
Merge pull request #27040 from nextcloud/FlorentCoppint-master
Avoid reading ~/.aws/config when using S3 provider
2021-05-25 10:19:22 +07:00
Robin Appelman 7ee528fc5a
properly use limit and offset for search in Jail wrapper
Signed-off-by: Robin Appelman <robin@icewind.nl>
2021-05-21 15:37:38 +07:00
Morris Jobke b1ad3faf14
Merge pull request #25679 from nextcloud/drop/ocp-user
Drop \OCP\User
2021-05-21 15:05:38 +07:00
Christoph Wurst 8196420063
Drop \OCP\User
Inlines and remaining usages and drops the deprecated public API.

Signed-off-by: Christoph Wurst <christoph@winzerhof-wurst.at>
2021-05-21 15:00:34 +07:00
Julius Härtl b900d64fd4
Merge pull request #26832 from nextcloud/object-close-stream-non-count
explicitly close source stream on object store upload even if count…
2021-05-21 11:30:43 +07:00
Florent d4444f2472
Avoid reading ~/.aws/config when using S3 provider
When using S3 storage, we sometimes have open_basedir errors due to aws-sdk-php trying to read ~/.aws/config which is out of open_basedir restrictions.
Christoph Wurst already added csm=false config in #21406 but it wasn't enough, we also need to set use_arn_region=false, added in this commit.

Signed-off-by: Florent <florent@coppint.com>
2021-05-20 12:21:15 +07:00
Robin Appelman ed2396b045
better cleanup of filecache when deleting an external storage
this way it can delete the cache entries even with per-user credentials

Signed-off-by: Robin Appelman <robin@icewind.nl>
2021-05-19 17:08:20 +07:00
Roeland Jago Douma aa785d266d
Merge pull request #26963 from nextcloud/bugfix/noid/empty-template-error
Fix log error when creating files from an empty template
2021-05-19 08:46:18 +07:00
Julius Härtl b8d0249b0e Fix log error when creating files from an empty template
Signed-off-by: Julius Härtl <jus@bitgrid.net>
2021-05-18 10:24:14 +07:00
Julius Härtl 35b910cf8e
Merge pull request #26322 from nextcloud/recent-search
Use file search for recent files and optimize getting share types
2021-05-18 09:44:08 +07:00
Julius Härtl 1e2cf820c8
Filter mounts for file id before trying to get user information
Signed-off-by: Julius Härtl <jus@bitgrid.net>
2021-04-30 07:55:38 +07:00
Robin Appelman ef6f2e68f0
explicitly close source stream on object store upload even if count wrapper isn't needed
Signed-off-by: Robin Appelman <robin@icewind.nl>
2021-04-29 17:01:19 +07:00