Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Bug]: OCP\Files\NotFoundException on file move #1139

Closed
6 of 9 tasks
powerflo opened this issue Oct 17, 2023 · 1 comment
Closed
6 of 9 tasks

[Bug]: OCP\Files\NotFoundException on file move #1139

powerflo opened this issue Oct 17, 2023 · 1 comment

Comments

@powerflo
Copy link
Contributor

⚠️ This issue respects the following points: ⚠️

Bug description

When moving any file, an OCP\Files\NotFoundException error occurs in the error log:

{
    "reqId": "rkdGUWO4hUSUsY1RacxF",
    "level": 3,
    "time": "2023-10-17T14:49:13+00:00",
    "remoteAddr": "2003:c2:bf1f:cc00:998b:fc81:ff50:be38",
    "user": "florian",
    "app": "no app in context",
    "method": "MOVE",
    "url": "/remote.php/dav/files/florian/New%20text%20file2.md",
    "message": "",
    "userAgent": "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/117.0.0.0 Safari/537.36",
    "version": "27.1.2.1",
    "exception": {
        "Exception": "OCP\\Files\\NotFoundException",
        "Message": "",
        "Code": 0,
        "Trace": [
            {
                "file": "/var/www/html/custom_apps/maps/lib/Service/PhotofilesService.php",
                "line": 172,
                "function": "getId",
                "class": "OC\\Files\\Node\\NonExistingFile",
                "type": "->",
                "args": []
            },
            {
                "file": "/var/www/html/custom_apps/maps/lib/Hooks/FileHooks.php",
                "line": 93,
                "function": "deleteByFile",
                "class": "OCA\\Maps\\Service\\PhotofilesService",
                "type": "->",
                "args": [
                    "*** sensitive parameters replaced ***"
                ]
            },
            {
                "function": "OCA\\Maps\\Hooks\\{closure}",
                "class": "OCA\\Maps\\Hooks\\FileHooks",
                "type": "->",
                "args": [
                    "*** sensitive parameters replaced ***"
                ]
            },
            {
                "file": "/var/www/html/lib/private/Hooks/EmitterTrait.php",
                "line": 105,
                "function": "call_user_func_array",
                "args": [
                    [
                        "Closure"
                    ],
                    [
                        "*** sensitive parameters replaced ***",
                        "*** sensitive parameters replaced ***"
                    ]
                ]
            },
            {
                "file": "/var/www/html/lib/private/Hooks/PublicEmitter.php",
                "line": 40,
                "function": "emit",
                "class": "OC\\Hooks\\BasicEmitter",
                "type": "->",
                "args": [
                    "\\OC\\Files",
                    "postRename",
                    [
                        "*** sensitive parameters replaced ***",
                        "*** sensitive parameters replaced ***"
                    ]
                ]
            },
            {
                "file": "/var/www/html/lib/private/Files/Node/Root.php",
                "line": 144,
                "function": "emit",
                "class": "OC\\Hooks\\PublicEmitter",
                "type": "->",
                "args": [
                    "\\OC\\Files",
                    "postRename",
                    [
                        "*** sensitive parameters replaced ***",
                        "*** sensitive parameters replaced ***"
                    ]
                ]
            },
            {
                "function": "emit",
                "class": "OC\\Files\\Node\\Root",
                "type": "->",
                "args": [
                    "\\OC\\Files",
                    "postRename",
                    [
                        "*** sensitive parameters replaced ***",
                        "*** sensitive parameters replaced ***"
                    ]
                ]
            },
            {
                "file": "/var/www/html/lib/private/Files/Node/LazyFolder.php",
                "line": 74,
                "function": "call_user_func_array",
                "args": [
                    [
                        [
                            "OC\\Files\\Node\\Root"
                        ],
                        "emit"
                    ],
                    [
                        "\\OC\\Files",
                        "postRename",
                        [
                            "*** sensitive parameters replaced ***",
                            "*** sensitive parameters replaced ***"
                        ]
                    ]
                ]
            },
            {
                "file": "/var/www/html/lib/private/Files/Node/LazyFolder.php",
                "line": 102,
                "function": "__call",
                "class": "OC\\Files\\Node\\LazyFolder",
                "type": "->",
                "args": [
                    "emit",
                    [
                        "\\OC\\Files",
                        "postRename",
                        [
                            "*** sensitive parameters replaced ***",
                            "*** sensitive parameters replaced ***"
                        ]
                    ]
                ]
            },
            {
                "file": "/var/www/html/lib/private/Files/Node/HookConnector.php",
                "line": 193,
                "function": "emit",
                "class": "OC\\Files\\Node\\LazyFolder",
                "type": "->",
                "args": [
                    "\\OC\\Files",
                    "postRename",
                    [
                        "*** sensitive parameters replaced ***",
                        "*** sensitive parameters replaced ***"
                    ]
                ]
            },
            {
                "file": "/var/www/html/lib/private/legacy/OC_Hook.php",
                "line": 105,
                "function": "postRename",
                "class": "OC\\Files\\Node\\HookConnector",
                "type": "->",
                "args": [
                    [
                        "/New text file2.md",
                        "/Documents/New text file2.md"
                    ]
                ]
            },
            {
                "file": "/var/www/html/lib/private/Files/View.php",
                "line": 842,
                "function": "emit",
                "class": "OC_Hook",
                "type": "::",
                "args": [
                    "OC_Filesystem",
                    "post_rename",
                    [
                        "/New text file2.md",
                        "/Documents/New text file2.md"
                    ]
                ]
            },
            {
                "file": "/var/www/html/apps/dav/lib/Connector/Sabre/Directory.php",
                "line": 452,
                "function": "rename",
                "class": "OC\\Files\\View",
                "type": "->",
                "args": [
                    "/New text file2.md",
                    "/Documents/New text file2.md"
                ]
            },
            {
                "file": "/var/www/html/3rdparty/sabre/dav/lib/DAV/Tree.php",
                "line": 160,
                "function": "moveInto",
                "class": "OCA\\DAV\\Connector\\Sabre\\Directory",
                "type": "->",
                "args": [
                    "New text file2.md",
                    "files/florian/New text file2.md",
                    [
                        "OCA\\DAV\\Connector\\Sabre\\File"
                    ]
                ]
            },
            {
                "file": "/var/www/html/3rdparty/sabre/dav/lib/DAV/CorePlugin.php",
                "line": 612,
                "function": "move",
                "class": "Sabre\\DAV\\Tree",
                "type": "->",
                "args": [
                    "files/florian/New text file2.md",
                    "files/florian/Documents/New text file2.md"
                ]
            },
            {
                "file": "/var/www/html/3rdparty/sabre/event/lib/WildcardEmitterTrait.php",
                "line": 89,
                "function": "httpMove",
                "class": "Sabre\\DAV\\CorePlugin",
                "type": "->",
                "args": [
                    [
                        "Sabre\\HTTP\\Request"
                    ],
                    [
                        "Sabre\\HTTP\\Response"
                    ]
                ]
            },
            {
                "file": "/var/www/html/3rdparty/sabre/dav/lib/DAV/Server.php",
                "line": 472,
                "function": "emit",
                "class": "Sabre\\DAV\\Server",
                "type": "->",
                "args": [
                    "method:MOVE",
                    [
                        [
                            "Sabre\\HTTP\\Request"
                        ],
                        [
                            "Sabre\\HTTP\\Response"
                        ]
                    ]
                ]
            },
            {
                "file": "/var/www/html/3rdparty/sabre/dav/lib/DAV/Server.php",
                "line": 253,
                "function": "invokeMethod",
                "class": "Sabre\\DAV\\Server",
                "type": "->",
                "args": [
                    [
                        "Sabre\\HTTP\\Request"
                    ],
                    [
                        "Sabre\\HTTP\\Response"
                    ]
                ]
            },
            {
                "file": "/var/www/html/3rdparty/sabre/dav/lib/DAV/Server.php",
                "line": 321,
                "function": "start",
                "class": "Sabre\\DAV\\Server",
                "type": "->",
                "args": []
            },
            {
                "file": "/var/www/html/apps/dav/lib/Server.php",
                "line": 365,
                "function": "exec",
                "class": "Sabre\\DAV\\Server",
                "type": "->",
                "args": []
            },
            {
                "file": "/var/www/html/apps/dav/appinfo/v2/remote.php",
                "line": 35,
                "function": "exec",
                "class": "OCA\\DAV\\Server",
                "type": "->",
                "args": []
            },
            {
                "file": "/var/www/html/remote.php",
                "line": 172,
                "args": [
                    "/var/www/html/apps/dav/appinfo/v2/remote.php"
                ],
                "function": "require_once"
            }
        ],
        "File": "/var/www/html/lib/private/Files/Node/NonExistingFile.php",
        "Line": 52,
        "CustomMessage": "--"
    },
    "id": "652e9ee9dc953"
}

Steps to reproduce

  1. Install the maps app
  2. Click any file menu, and "Move or copy"
  3. Select Move

Expected behavior

No error in the logs

Installation method

Official Docker image

Operating system

Other

PHP engine version

None

Web server

None

Database engine version

None

Is this bug present after an update or on a fresh install of the server?

None

Is this bug present after an update or on a fresh install of the app?

None

Are you using the Nextcloud Server Encryption module?

None

What user-backends are you using?

  • Default user-backend (database)
  • LDAP/ Active Directory
  • SSO - SAML
  • Other

Configuration report

No response

List of activated Apps

Enabled:
  - activity: 2.19.0
  - bruteforcesettings: 2.7.0
  - calendar: 4.5.2
  - circles: 27.0.1
  - cloud_federation_api: 1.10.0
  - comments: 1.17.0
  - contacts: 5.4.2
  - contactsinteraction: 1.8.0
  - dav: 1.27.0
  - federatedfilesharing: 1.17.0
  - federation: 1.17.0
  - files: 1.22.0
  - files_fulltextsearch: 27.0.1
  - files_pdfviewer: 2.8.0
  - files_reminders: 1.0.0
  - files_rightclick: 1.6.0
  - files_sharing: 1.19.0
  - files_trashbin: 1.17.0
  - files_versions: 1.20.0
  - firstrunwizard: 2.16.0
  - fulltextsearch: 27.0.2
  - fulltextsearch_elasticsearch: 27.0.4
  - logreader: 2.12.0
  - lookup_server_connector: 1.15.0
  - maps: 1.1.1
  - nextcloud-aio: 0.4.0
  - nextcloud_announcements: 1.16.0
  - notes: 4.8.1
  - notifications: 2.15.0
  - notify_push: 0.6.3
  - oauth2: 1.15.1
  - password_policy: 1.17.0
  - photos: 2.3.0
  - privacy: 1.11.0
  - provisioning_api: 1.17.0
  - recommendations: 1.6.0
  - related_resources: 1.2.0
  - richdocuments: 8.2.1
  - serverinfo: 1.17.0
  - settings: 1.9.0
  - sharebymail: 1.17.0
  - support: 1.10.0
  - survey_client: 1.15.0
  - suspicious_login: 5.0.0
  - systemtags: 1.17.0
  - text: 3.8.0
  - theming: 2.2.0
  - twofactor_backupcodes: 1.16.0
  - twofactor_nextcloud_notification: 3.7.0
  - twofactor_totp: 9.0.0
  - user_status: 1.7.0
  - viewer: 2.1.0
  - webapppassword: 23.6.0
  - workflowengine: 2.9.0
Disabled:
  - admin_audit: 1.17.0
  - dashboard: 7.7.0 (installed 7.4.0)
  - encryption: 2.15.0
  - files_external: 1.19.0 (installed 1.17.0)
  - user_ldap: 1.17.0
  - weather_status: 1.7.0 (installed 1.5.0)

Nextcloud Signing status

No response

Nextcloud Logs

No response

Browser Console

No response

Additional info

No response

@powerflo
Copy link
Contributor Author

I've tried to look into it and the relevant code seems to be the postRename hook in FileHooks.php. This line
$this->photofilesService->deleteByFile($source);
and then the deleteByFile function calls the $source->getId() which throws Files\NotFoundException.

The postRename hook was last modified by #1003
This PR changed the line
$this->photofilesService->deleteByFile($target);
to
$this->photofilesService->deleteByFile($source);

I'm not sure why this was changed this way and I would expect that moving a file doesn't change the file id.
So I think the line before the change is correct:
$this->photofilesService->deleteByFile($target);

@tacruc tacruc closed this as completed in bb28497 Oct 18, 2023
tacruc added a commit that referenced this issue Oct 18, 2023
Change postRename hook to fix #1139
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

1 participant