summaryrefslogtreecommitdiffstats
path: root/lib/private/Files/Storage/Wrapper
Commit message (Collapse)AuthorAgeFilesLines
* fix: use proper jailed patch in watcherRobin Appelman2024-04-091-4/+3
| | | | Signed-off-by: Robin Appelman <robin@icewind.nl>
* fix: log error when default getWrapperStorage would return nullRobin Appelman2024-03-221-0/+9
| | | | Signed-off-by: Robin Appelman <robin@icewind.nl>
* fix: add some recrusive detection/preventionRobin Appelman2024-03-191-0/+11
| | | | Signed-off-by: Robin Appelman <robin@icewind.nl>
* optimize cache jail creationRobin Appelman2023-11-071-4/+1
| | | | Signed-off-by: Robin Appelman <robin@icewind.nl>
* add wrapper to ensure we don't get an mtime that is lower than we know it isRobin Appelman2023-10-101-0/+142
| | | | Signed-off-by: Robin Appelman <robin@icewind.nl>
* fix: Only store unencrypted_size if path should be encryptedJulius Härtl2023-09-121-1/+1
| | | | Signed-off-by: Julius Härtl <jus@bitgrid.net>
* only determine quota_include_external_storage once for quota wrapperRobin Appelman2023-09-071-2/+3
| | | | Signed-off-by: Robin Appelman <robin@icewind.nl>
* fix(sse): don't update uncached filesRichard Steinmetz2023-07-041-13/+21
| | | | Signed-off-by: Richard Steinmetz <richard@steinmetz.cloud>
* Fix file_get_content signatures to make it clear it can return falseCôme Chilliet2023-04-274-4/+4
| | | | | | | In File::getContent, which must return a string, throw an Exception instead of returning false. Signed-off-by: Côme Chilliet <come.chilliet@nextcloud.com>
* Merge pull request #36857 from nextcloud/scan-repair-unencrypted-sizeRobin Appelman2023-04-241-1/+4
|\ | | | | fix unencrypted_size for folders when scanning the filesystem with encryption enabled
| * fix unencrypted_size for files when scanningRobin Appelman2023-04-041-1/+4
| | | | | | | | Signed-off-by: Robin Appelman <robin@icewind.nl>
* | Merge pull request #34607 from nextcloud/encryption-size-not-foundVincent Petry2023-04-061-1/+3
|\ \ | | | | | | fix encryption wrapper filesize for non existing files
| * | fix encryption wrapper filesize for non existing filesRobin Appelman2023-04-041-1/+3
| |/ | | | | | | Signed-off-by: Robin Appelman <robin@icewind.nl>
* / Fix return type of methods returning false on errorCôme Chilliet2023-04-034-10/+10
|/ | | | Signed-off-by: Côme Chilliet <come.chilliet@nextcloud.com>
* Fix quota typing for 32bits after forward port from 25Côme Chilliet2023-04-011-2/+2
| | | Signed-off-by: Côme Chilliet <91878298+come-nc@users.noreply.github.com>
* Adapt types of subclassesCôme Chilliet2023-04-012-4/+4
| | | | Signed-off-by: Côme Chilliet <come.chilliet@nextcloud.com>
* Make it clear that file sizes may be float on 32bitsCôme Chilliet2023-04-012-9/+11
| | | | Signed-off-by: Côme Chilliet <come.chilliet@nextcloud.com>
* Remove quota value type for 32-bit systemsVincent Petry2023-04-011-2/+2
| | | | Signed-off-by: Vincent Petry <vincent@nextcloud.com>
* Respect OCP interface in private classesCôme Chilliet2023-02-075-5/+5
| | | | | | | Because the parameter type was moved to phpdoc it needs to be removed from implementations Signed-off-by: Côme Chilliet <come.chilliet@nextcloud.com>
* Fix psalm errors related to filesizesCôme Chilliet2023-02-072-1/+4
| | | | Signed-off-by: Côme Chilliet <come.chilliet@nextcloud.com>
* Strong type filesize related methods to ease 32bits problem findingsCôme Chilliet2023-02-075-17/+5
| | | | Signed-off-by: Côme Chilliet <come.chilliet@nextcloud.com>
* fix(encryption): don't throw on missing fileRichard Steinmetz2023-01-301-4/+1
| | | | Signed-off-by: Richard Steinmetz <richard@steinmetz.cloud>
* composer run cs:fixCôme Chilliet2023-01-202-4/+0
| | | | Signed-off-by: Côme Chilliet <come.chilliet@nextcloud.com>
* Suppress last psalm error until upstream fix is released and includedCôme Chilliet2023-01-021-0/+1
| | | | Signed-off-by: Côme Chilliet <come.chilliet@nextcloud.com>
* Fix psalm spotted errors with new requirementsCôme Chilliet2023-01-021-1/+1
| | | | Signed-off-by: Côme Chilliet <come.chilliet@nextcloud.com>
* clear is-encrypted cache when trying to fix encrypted versionRobin Appelman2022-12-011-0/+4
| | | | Signed-off-by: Robin Appelman <robin@icewind.nl>
* fix reading newly written encrypted files before their cache entry is writtenRobin Appelman2022-11-301-4/+12
| | | | Signed-off-by: Robin Appelman <robin@icewind.nl>
* Rename file1 and file2 to source and target in Storage abstractionCarl Schwan2022-10-186-56/+55
| | | | Signed-off-by: Carl Schwan <carl@carlschwan.eu>
* Switch logical operators (and|or)Git'Fellow2022-09-121-18/+12
| | | Signed-off-by: Git'Fellow <12234510+solracsf@users.noreply.github.com>
* get quota for user only when neededRobin Appelman2022-09-011-20/+51
| | | | | | 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>
* Move CappedMemoryCache to OCPCarl Schwan2022-07-141-1/+1
| | | | | | | | 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>
* store unencrypted size in the unencrypted_size columnRobin Appelman2022-06-021-40/+58
| | | | Signed-off-by: Robin Appelman <robin@icewind.nl>
* Fixing psalm errorsCôme Chilliet2022-03-241-9/+9
| | | | | | Encryption constructor is problematic and should still be fixed later. Signed-off-by: Côme Chilliet <come.chilliet@nextcloud.com>
* Migrate from ILogger to LoggerInterface in lib/privateCôme Chilliet2022-03-241-26/+14
| | | | Signed-off-by: Côme Chilliet <come.chilliet@nextcloud.com>
* Merge pull request #30631 from nextcloud/fix/update_encrypted_versionVincent Petry2022-01-141-1/+10
|\ | | | | updateEncryptedVersion: cleanup on target if cache already got renamed
| * updateEncryptedVersion: cleanup on target if cache already got renamedJonas Meurer2022-01-121-1/+10
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | 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>
* | Fix psalm issuesCarl Schwan2022-01-131-6/+6
| | | | | | | | Signed-off-by: Carl Schwan <carl@carlschwan.eu>
* | Add helper method in WrapperCarl Schwan2022-01-131-1/+20
|/ | | | Signed-off-by: Carl Schwan <carl@carlschwan.eu>
* Fix fail when keys/files folder already existsVincent Petry2022-01-101-1/+5
| | | | | | | | | 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>
* Check resource before closing in encryption wrapperVincent Petry2021-12-091-2/+6
| | | | | | | | | | | 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>
* Normalize directory entries in Encoding wrapperVincent Petry2021-11-172-3/+66
| | | | | | | | | | | | 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>
* Update lib/private/Files/Storage/Wrapper/Availability.php add void Vincent Petry2021-11-051-1/+1
| | | | | Signed-off-by: Vincent Petry <vincent@nextcloud.com> Co-authored-by: Carl Schwan <carl@carlschwan.eu>
* Return false in hasUpdated when storage is not availableVincent Petry2021-11-051-4/+10
| | | | | | | | | | 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>
* Add type hint to fread_block $blockSize param & apply cs:fix.alanmeeson2021-10-231-2/+2
| | | | Signed-off-by: alanmeeson <alan@carefullycalculated.co.uk>
* Fix truncation of files upon read when using object store and encryption.Alan Meeson2021-10-231-2/+30
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | 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>
* Merge pull request #27440 from nextcloud/is-file-handleJohn Molakvoæ2021-10-231-4/+4
|\
| * Handle files with is_file instead of file_existsacsfer2021-08-151-4/+4
| | | | | | Should fix things like `fread(): read of 8192 bytes failed with errno=21 Is a directory`
* | Merge branch 'master' into imountpoint-ocp-storageJohn Molakvoæ2021-10-227-21/+16
|\ \
| * | explicitly close source stream on encryption storageDaniel Kesselberg2021-09-211-2/+3
| |/ | | | | | | Signed-off-by: Daniel Kesselberg <mail@danielkesselberg.de>
| * Update php licensesJohn Molakvoæ (skjnldsv)2021-06-047-8/+3
| | | | | | | | Signed-off-by: John Molakvoæ (skjnldsv) <skjnldsv@protonmail.com>