Commit Graph

106 Commits (1ef465f80425f3dadd47c05ae2198153723d3eec)

Author SHA1 Message Date
Carl Schwan 9522dde7a2
feat: Add Folder::getOrCreateFolder api
Allow to remove some boilerplate and also this new function is type
safe.

Signed-off-by: Carl Schwan <carl.schwan@nextcloud.com>
2025-11-24 11:10:52 +07:00
Côme Chilliet 9277a17a3c
fix: Flag folder objects that got deleted to recreate them if needed
AppData caches folder objects, and several places get them to delete
 them, so afterwards if the folder gets reused in the same session an
 error happens. This is the case in unit tests with user avatars.

Signed-off-by: Côme Chilliet <come.chilliet@nextcloud.com>
2025-09-26 15:11:36 +07:00
Ferdinand Thiessen 5981b7eb51
chore: apply new CSFixer rules
Signed-off-by: Ferdinand Thiessen <opensource@fthiessen.de>

# Conflicts:
#	apps/settings/lib/SetupChecks/PhpOpcacheSetup.php
2025-07-01 16:26:50 +07:00
skjnldsv e41e8de0e2 fix(dav): file drop nickname
Signed-off-by: skjnldsv <skjnldsv@protonmail.com>
2025-06-05 09:09:17 +07:00
Robin Appelman 99364adc1c
fix: improve handling of newFolder race condition handling
Signed-off-by: Robin Appelman <robin@icewind.nl>
2025-05-08 15:19:40 +07:00
Daniel Kesselberg fbaa4cc5e0 fix: catch NotPermittedException in Folder.nodeExists
Signed-off-by: Daniel Kesselberg <mail@danielkesselberg.de>
2024-09-30 19:00:36 +07:00
Daniel Kesselberg 3db20c8b00 docs: Folder.get throws a NotPermittedException exception
Signed-off-by: Daniel Kesselberg <mail@danielkesselberg.de>
2024-09-30 19:00:36 +07:00
provokateurin dc13f9cc1e
fix(Files): Handle getOwner() returning false
Signed-off-by: provokateurin <kate@provokateurin.de>
2024-09-17 10:10:50 +07:00
Daniel Kesselberg af6de04e9e
style: update codestyle for coding-standard 1.2.3
Signed-off-by: Daniel Kesselberg <mail@danielkesselberg.de>
2024-08-25 19:34:58 +07:00
Christopher Ng 572361f498 fix(files): Fix incorrect keys by reindexing
Signed-off-by: Christopher Ng <chrng8@gmail.com>
2024-08-01 09:14:44 +07:00
Ferdinand Thiessen cf935e33ae
fix: `OCP\Files\Node\Folder::search` was not setting the owner
The owner was not set on the file info causing e.g. webdav searches to never return the known owner.

Signed-off-by: Ferdinand Thiessen <opensource@fthiessen.de>
2024-07-11 15:46:44 +07:00
Robin Appelman ffced73a71 fix: also use optimized getFirstNodeyIdInPath for Folder::getFirstNodeById
Signed-off-by: Robin Appelman <robin@icewind.nl>
2024-06-20 18:51:27 +07:00
Git'Fellow 77979b1475 Try create folder first and check if it exists after
Co-authored-by: Benjamin Gaussorgues <benjamin.gaussorgues@nextcloud.com>
Signed-off-by: Git'Fellow <12234510+solracsf@users.noreply.github.com>
2024-05-30 14:27:44 +07:00
Git'Fellow 5c4e4c5590 fix(files): Try to create dir only if it not exists
Signed-off-by: Git'Fellow <12234510+solracsf@users.noreply.github.com>
2024-05-30 14:27:44 +07:00
Andy Scherzinger dae7c159f7
chore: Add SPDX header
Signed-off-by: Andy Scherzinger <info@andy-scherzinger.de>
2024-05-24 13:11:22 +07:00
Marcel Klehr 00894e2420 feat: first pass at TaskProcessing API
Signed-off-by: Marcel Klehr <mklehr@gmx.net>
2024-05-14 11:38:39 +07:00
Côme Chilliet ec5133b739 fix: Apply new coding standard to all files
Signed-off-by: Côme Chilliet <come.chilliet@nextcloud.com>
2024-04-02 14:16:21 +07:00
Robin Appelman e7a7b4a401 perf: switch places that always use the first getById result to getFirstNodeById
Signed-off-by: Robin Appelman <robin@icewind.nl>
2024-03-04 13:57:31 +07:00
Robin Appelman 4d110c1dd6 feat: add interface to get only a single node by id instead of all nodes for the id
this should be enough in most(?) cases and makes efficient implementation and caching easier

Signed-off-by: Robin Appelman <robin@icewind.nl>
2024-03-04 12:26:30 +07:00
Marcel Klehr 71a06b6bf8 fix(Folder): Allow filename to be '0'
Signed-off-by: Marcel Klehr <mklehr@gmx.net>
2023-10-22 12:22:30 +07:00
Christoph Wurst 14719110b9 chore: Replace \OC::$server->query with \OCP\Server::get in /lib
Signed-off-by: Christoph Wurst <christoph@winzerhof-wurst.at>
2023-07-06 15:21:22 +07:00
Julius Härtl eddb64f8c3
Merge pull request #37969 from nextcloud/poc/noid/systemtags-perf-tag-endpoint 2023-06-28 07:53:35 +07:00
Arthur Schiwon a0f9556f7c
fix: cominbation of small fixes
- possible null return
- parameter name mismatch in implementation
- incomplete unit test

Signed-off-by: Arthur Schiwon <blizzz@arthur-schiwon.de>
2023-06-21 20:28:01 +07:00
Arthur Schiwon b0d1cf5730
fix: change if with conditionless else to switch; and a parameter value
Signed-off-by: Arthur Schiwon <blizzz@arthur-schiwon.de>
2023-06-21 18:19:08 +07:00
Arthur Schiwon 58f7fd2370
use efficient tag retrieval on DAV report request
- uses DAV search approach against valid files joined by systemtag selector
- reduced table join for tag/systemtag search
- supports pagination
- no changes to the output formats or similar

Example request body:

<?xml version="1.0"?>
<oc:filter-files xmlns:d="DAV:" xmlns:oc="http://owncloud.org/ns" xmlns:nc="http://nextcloud.org/ns" xmlns:ocs="http://open-collaboration-services.org/ns">
  <d:prop>
    <d:getcontentlength/>
    <d:getcontenttype/>
    <d:getetag/>
    <d:getlastmodified/>
    <d:resourcetype/>
    <nc:face-detections/>
    <nc:file-metadata-size/>
    <nc:has-preview/>
    <nc:realpath/>
    <oc:favorite/>
    <oc:fileid/>
    <oc:permissions/>
    <nc:nbItems/>
  </d:prop>
  <oc:filter-rules>
    <oc:systemtag>32</oc:systemtag>
  </oc:filter-rules>
  <d:limit>
    <d:nresults>50</d:nresults>
    <nc:firstresult>0</nc:firstresult>
  </d:limit>
</oc:filter-files>

Signed-off-by: Arthur Schiwon <blizzz@arthur-schiwon.de>
2023-06-21 18:19:08 +07:00
Arthur Schiwon 088a0eea29
ci: pro forma check of existence of internal method
createNode() is protected and used by Folder, but being an internal-only
method it shall not be exposed in the Folder or IRootFolder interface.

Signed-off-by: Arthur Schiwon <blizzz@arthur-schiwon.de>
2023-06-21 16:53:20 +07:00
Arthur Schiwon 71e41ffeeb
refactor: declare getMount() and getMountsIn() at IRootFolder
Signed-off-by: Arthur Schiwon <blizzz@arthur-schiwon.de>
2023-06-21 16:53:20 +07:00
Arthur Schiwon f6ac874dbf
chore: ugly type juggling
Signed-off-by: Arthur Schiwon <blizzz@arthur-schiwon.de>
2023-06-21 16:53:20 +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
Arthur Schiwon dbfd2f936a
refactor: remove SystemTag logic from Folder into QuerySearchHelper
- adds OC\SystemTag\SystemTagsInFilesDetector where the search logic is
  moved to

Signed-off-by: Arthur Schiwon <blizzz@arthur-schiwon.de>
2023-05-09 23:51:52 +07:00
Arthur Schiwon 2489a2d63a
feat: specify media type via url path: systemtags-current/$mediaType
- only the media part of the mime type can be search, but not the full
  mime type. It can be added, should it become necessary.
- thus fixes previously hardcoded selector for image/ types
- also fixes a return type hint
- adds a return type hint

Signed-off-by: Arthur Schiwon <blizzz@arthur-schiwon.de>
2023-05-09 23:51:51 +07:00
Arthur Schiwon 6bff6a5667
PoC: SystemTags endpoint to return tags used by a user with meta data
Target case is photos app: when visiting the tags category, all systemtags
of the whole cloud are retrieved. In subequent steps the next tag is
requested until the browser view is filled with tag tiles (i.e. previews
are requested just as well).

With this approach, we incorpoate the dav search and look for user related
tags that are used by them, and already returns the statistics (number of
files tagged with the respective tag) as well as a file id for the purpose
to load the preview. This defaults to the file with the highest id.

Call:
curl -s -u 'user:password' \
  'https://my.nc.srv/remote.php/dav/systemtags-current' \
  -X PROPFIND -H 'Accept: text/plain' \
  -H 'Accept-Language: en-US,en;q=0.5'  -H 'Depth: 1' \
  -H 'Content-Type: text/plain;charset=UTF-8' \
  --data @/home/doe/request-systemtag-props.xml

With request-systemtag-props.xml:
<?xml version="1.0" encoding="UTF-8"?>
<d:propfind xmlns:d="DAV:">
        <d:prop xmlns:oc="http://owncloud.org/ns" xmlns:nc="http://nextcloud.org/ns">
                <oc:id/>
                <oc:display-name/>
                <oc:user-visible/>
                <oc:user-assignable/>
                <oc:can-assign/>
                <nc:files-assigned/>
                <nc:reference-fileid/>
        </d:prop>
</d:propfind>

Example output:
  …
  <d:response>
    <d:href>/master/remote.php/dav/systemtags/84</d:href>
    <d:propstat>
      <d:prop>
        <oc:id>84</oc:id>
        <oc:display-name>Computer</oc:display-name>
        <oc:user-visible>true</oc:user-visible>
        <oc:user-assignable>true</oc:user-assignable>
        <oc:can-assign>true</oc:can-assign>
        <nc:files-assigned>42</nc:files-assigned>
        <nc:reference-fileid>924022</nc:reference-fileid>
      </d:prop>
      <d:status>HTTP/1.1 200 OK</d:status>
    </d:propstat>
  </d:response>
  <d:response>
    <d:href>/remote.php/dav/systemtags/97</d:href>
    <d:propstat>
      <d:prop>
        <oc:id>97</oc:id>
        <oc:display-name>Bear</oc:display-name>
        <oc:user-visible>true</oc:user-visible>
        <oc:user-assignable>true</oc:user-assignable>
        <oc:can-assign>true</oc:can-assign>
        <nc:files-assigned>1</nc:files-assigned>
        <nc:reference-fileid>923422</nc:reference-fileid>
      </d:prop>
      <d:status>HTTP/1.1 200 OK</d:status>
    </d:propstat>
  </d:response>
  …

Signed-off-by: Arthur Schiwon <blizzz@arthur-schiwon.de>
2023-05-09 23:51:48 +07:00
Côme Chilliet 9c3e06c046
Merge pull request #33061 from ibpl/master-IB#1121253
Paths added to messages and message cleanup
2023-03-14 17:28:22 +07:00
Robin Appelman 5bcf37b7ff only fetch the data for mounts inside a folder when needed
for most operations we don't actually care about any mounts inside a folder, only for metadata that needs to propagate across storage boundaries (size, etag, mtime) do we need all the submount info.

By only loading this data when needed we can save a bunch of storage setup in a number of cases

Signed-off-by: Robin Appelman <robin@icewind.nl>
2023-02-09 11:39:00 +07:00
Côme Chilliet a78595a45f
Make sure that path is normalized and then checked,
and not the other way around

Signed-off-by: Côme Chilliet <come.chilliet@nextcloud.com>
2022-11-10 15:03:15 +07:00
Pawel Boguslawski 4a46c747e9 Merge master 2022-11-04 13:34:21 +07:00
Carl Schwan 67551f379f
Filter out old files when trying to get recent files
Only do so when asking for less than 100 files and having an offset
equal to 0.

Signed-off-by: Carl Schwan <carl@carlschwan.eu>
2022-09-05 12:53:32 +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
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
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
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
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
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 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 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