Commit Graph

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

Author SHA1 Message Date
Hamid Dehnavi ea06cf2f39 Convert isset ternary to null coalescing operator
Signed-off-by: Hamid Dehnavi <hamid.dev.pro@gmail.com>
2023-09-28 17:44:19 +07:00
Robin Appelman 5bf34979fe add wrapper to ensure we don't get an mtime that is lower than we know it is
Signed-off-by: Robin Appelman <robin@icewind.nl>
2023-09-19 13:58:15 +07:00
Julius Härtl 88a96e4db7 fix: Only store unencrypted_size if path should be encrypted
Signed-off-by: Julius Härtl <jus@bitgrid.net>
2023-09-06 07:25:28 +07:00
Robin Appelman e4f85226c5
extend fix-key-location to handle cases from broken cross-storage moves
Signed-off-by: Robin Appelman <robin@icewind.nl>
2023-08-31 19:46:47 +07:00
Robin Appelman b6c3507aa0 only determine quota_include_external_storage once for quota wrapper
Signed-off-by: Robin Appelman <robin@icewind.nl>
2023-08-18 14:25:28 +07:00
Richard Steinmetz c4eccbb304
fix(sse): don't update uncached files
Signed-off-by: Richard Steinmetz <richard@steinmetz.cloud>
2023-07-04 12:42:29 +07:00
Faraz Samapoor e7cc7653b8 Refactors "strpos" calls in lib/private to improve code readability.
Signed-off-by: Faraz Samapoor <fsamapoor@gmail.com>
2023-05-15 15:17:19 +07:00
Côme Chilliet 546d94c3ec
Fix file_get_content signatures to make it clear it can return false
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>
2023-04-27 09:56:05 +07:00
Robin Appelman 4953296b9e
Merge pull request #36857 from nextcloud/scan-repair-unencrypted-size
fix unencrypted_size for folders when scanning the filesystem with encryption enabled
2023-04-24 15:24:50 +07:00
Vincent Petry 9f05eff3ef
Merge pull request #34607 from nextcloud/encryption-size-not-found
fix encryption wrapper filesize for non existing files
2023-04-06 18:04:44 +07:00
Robin Appelman 649bed5154
fix unencrypted_size for files when scanning
Signed-off-by: Robin Appelman <robin@icewind.nl>
2023-04-04 16:48:11 +07:00
Robin Appelman 15a6920b07
fix encryption wrapper filesize for non existing files
Signed-off-by: Robin Appelman <robin@icewind.nl>
2023-04-04 16:21:17 +07:00
Côme Chilliet ea05544213
Fix return type of methods returning false on error
Signed-off-by: Côme Chilliet <come.chilliet@nextcloud.com>
2023-04-03 10:52:34 +07:00
Côme Chilliet da618c457a
Fix quota typing for 32bits after forward port from 25
Signed-off-by: Côme Chilliet <91878298+come-nc@users.noreply.github.com>
2023-04-01 14:20:25 +07:00
Côme Chilliet 1740311283
Adapt types of subclasses
Signed-off-by: Côme Chilliet <come.chilliet@nextcloud.com>
2023-04-01 14:20:24 +07:00
Côme Chilliet ed863fb47c
Make it clear that file sizes may be float on 32bits
Signed-off-by: Côme Chilliet <come.chilliet@nextcloud.com>
2023-04-01 14:20:24 +07:00
Vincent Petry c6b683342e
Remove quota value type for 32-bit systems
Signed-off-by: Vincent Petry <vincent@nextcloud.com>
2023-04-01 14:20:20 +07:00
Côme Chilliet 308fcf4526
Respect OCP interface in private classes
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>
2023-02-07 11:23:35 +07:00
Côme Chilliet d9dbed9105
Fix psalm errors related to filesizes
Signed-off-by: Côme Chilliet <come.chilliet@nextcloud.com>
2023-02-07 11:23:29 +07:00
Côme Chilliet ff776a90b1
Strong type filesize related methods to ease 32bits problem findings
Signed-off-by: Côme Chilliet <come.chilliet@nextcloud.com>
2023-02-07 11:23:28 +07:00
Richard Steinmetz f0a3b77d0f fix(encryption): don't throw on missing file
Signed-off-by: Richard Steinmetz <richard@steinmetz.cloud>
2023-01-30 10:07:01 +07:00
Côme Chilliet f5c361cf44
composer run cs:fix
Signed-off-by: Côme Chilliet <come.chilliet@nextcloud.com>
2023-01-20 11:45:08 +07:00
Côme Chilliet a7740c0ae6
Suppress last psalm error until upstream fix is released and included
Signed-off-by: Côme Chilliet <come.chilliet@nextcloud.com>
2023-01-02 15:17:38 +07:00
Côme Chilliet a372564850
Fix psalm spotted errors with new requirements
Signed-off-by: Côme Chilliet <come.chilliet@nextcloud.com>
2023-01-02 15:02:28 +07:00
Robin Appelman e3a0e64698
clear is-encrypted cache when trying to fix encrypted version
Signed-off-by: Robin Appelman <robin@icewind.nl>
2022-12-01 14:36:27 +07:00
Robin Appelman e9b87c73fa
fix reading newly written encrypted files before their cache entry is written
Signed-off-by: Robin Appelman <robin@icewind.nl>
2022-11-30 14:54:56 +07:00
Carl Schwan a5ea677370 Rename file1 and file2 to source and target in Storage abstraction
Signed-off-by: Carl Schwan <carl@carlschwan.eu>
2022-10-18 17:21:47 +07:00
Git'Fellow 5300f0d693
Switch logical operators (and|or)
Signed-off-by: Git'Fellow <12234510+solracsf@users.noreply.github.com>
2022-09-12 09:35:12 +07:00
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
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
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
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 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
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
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
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
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 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
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
John Molakvoæ e673ec0b87
Merge branch 'master' into imountpoint-ocp-storage 2021-10-22 11:47:37 +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
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
John Molakvoæ (skjnldsv) 215aef3cbd
Update php licenses
Signed-off-by: John Molakvoæ (skjnldsv) <skjnldsv@protonmail.com>
2021-06-04 22:02:41 +07:00
Lukas Reschke 4b4971ab52
Merge pull request #24966 from nextcloud/jknockaert-patch-1
avoid fread on directories and unencrypted files
2021-04-06 13:45:10 +07:00