[Bug]: External WebDAV storage — MKCOL returns HTTP 409, folder cache corruption and missing directory in Files

未关闭
#66,480 1 条评论 0 个 reaction 已指派 0 人 在 GitHub 查看

维护者通常 1 天内回复

还没有人认领这个 Issue。

评估

难度
5/5
预计耗时
一周以上
新手友好度
25/100
Issue 类型
缺陷
描述清晰度
基本清楚
活跃度
活跃
技术栈
docker, php, postgresql

调研方向

Start by comparing the reported MKCOL request and responses with the external WebDAV storage behavior, then investigate how the storage backend updates oc_filecache during directory operations and scans. The report does not identify source files or tests, and the two symptoms have no confirmed shared cause. Done means reproducing and isolating the cache inconsistency and/or documenting a fix for the unresolved MKCOL interoperability issue with tests.

由索引模型根据 Issue 内容生成。

描述

1. to develop 33-feedback bug feature: external storage
⚠️ This issue respects the following points: ⚠️
  • This is not a troubleshooting question, general support matter, or webserver/proxy problem, but likely a bug (if unsure, ask the Community Help Forum).
  • This issue is not already reported on Github OR solved at the Community Help Forum (I've searched!).
  • I'm using a maintained major version of Nextcloud Server and tested against the latest patch level. (Supported major versions and current patch levels).
  • I agree to follow Nextcloud's Code of Conduct.
  • I've tried my best to provide clear reproduction steps that someone unfamiliar with this bug could use to reproduce it.
Bug description

[Bug]: External WebDAV storage — MKCOL returns HTTP 409, folder cache corruption and missing directory in Files

Description

I am experiencing multiple issues with an external WebDAV storage mounted in Nextcloud 33.0.10.1.

The external storage is provided by an Nginx WebDAV server and contains a large collection of personal files, photos and videos.

Two issues have been observed:

  1. Creating a folder from Nextcloud Files can fail with HTTP 409 when Nextcloud sends a MKCOL request without a trailing slash.
  2. An existing directory (media) disappeared from the Nextcloud Files interface despite being present on the underlying WebDAV server. Investigation revealed an inconsistent entry in PostgreSQL's oc_filecache table.

The second issue was successfully repaired using a shallow scan of the external storage root, without changing the affected directory's fileid.

It is not yet established whether these two issues share the same root cause.

Environment

Component Configuration
Nextcloud 33.0.10.1
Deployment Nextcloud All-in-One (Docker)
Host Windows 10 Pro / Docker Desktop / WSL2 Debian 12
Database PostgreSQL
External storage backend WebDAV
WebDAV server Nginx (sfuhrm/docker-nginx-webdav:master)
Physical storage Windows drive mounted into the WebDAV container
External mount /Stockage externe
WebDAV remote root /rage/
Nextcloud user admin
Android clients Nextcloud Android Client and Photos for Nextcloud

The WebDAV server and Nextcloud are connected over the local network.

The external storage contains approximately 38,500 cached entries, including over 31,700 entries beneath the media/ directory.

Issue 1 — MKCOL without trailing slash returns HTTP 409

Steps to reproduce
  1. Configure an external WebDAV storage in Nextcloud.
  2. Open the external storage in the Nextcloud Files web interface.
  3. Attempt to create a new directory.
  4. Observe that directory creation fails.

Nextcloud sends a MKCOL request similar to:

MKCOL /rage/documents/RCEngineering/Nouveau%20dossier HTTP/1.1

The Nginx WebDAV server returns:

HTTP/1.1 409 Conflict
Direct WebDAV testing

Authenticated curl tests against the WebDAV server confirmed that the server behaves differently depending on the trailing slash.

Without trailing slash:

MKCOL /rage/documents/RCEngineering/Nouveau%20dossier

Result:

HTTP/1.1 409 Conflict

With trailing slash:

MKCOL /rage/documents/RCEngineering/Nouveau%20dossier/

Result:

HTTP/1.1 201 Created

Nginx reports:

MKCOL can create a collection only

This appears to be a WebDAV interoperability issue between Nextcloud's folder-creation request and this particular Nginx WebDAV implementation.

I am not claiming that the WebDAV specification universally requires trailing slashes for MKCOL.

Additional observation

Following some failed operations, the external storage temporarily became unavailable or disappeared from the Nextcloud Files interface, before becoming accessible again.

The precise relationship between the HTTP 409 response and the temporary mount unavailability has not been established.

Issue 2 — Existing WebDAV directory disappears from Nextcloud Files

Symptoms

The remote WebDAV directory /rage/ contains three top-level directories:

/rage/
├── backup/
├── documents/
└── media/

However, the Nextcloud Files web interface displayed only:

Stockage externe/
├── backup/
└── documents/

The media directory was missing.

The directory contains a large photo and video collection, and was previously accessible.

Verification of the underlying WebDAV server

An authenticated PROPFIND request was executed directly against Nginx:

curl -i --basic -u webdav \
  -X PROPFIND \
  -H 'Depth: 1' \
  'http://192.168.1.50:8099/rage/'

The server returned:

HTTP/1.1 207 Multi-Status

The XML response contained successful entries for:

/rage/
/rage/backup/
/rage/documents/
/rage/media/

Each resource was reported with HTTP 200 OK within the multistatus response.

Therefore, the missing directory was not caused by Nginx failing to enumerate /rage/media/ during this test.

PostgreSQL investigation

The affected external storage was identified in oc_storages:

numeric_id = 28
id = webdav::[email protected]:8099//rage/

The relevant cache entries were inspected with a read-only SQL query:

SELECT
    f.fileid,
    f.path,
    f.parent,
    m.mimetype,
    f.permissions,
    f.size
FROM oc_filecache f
LEFT JOIN oc_mimetypes m ON m.id = f.mimetype
WHERE f.storage = 28
  AND f.path IN ('', 'backup', 'documents', 'media')
ORDER BY f.path;
Cache state before repair
Path File ID Parent MIME type Permissions
Root 113062 -1 httpd/unix-directory 31
backup 113063 113062 httpd/unix-directory 31
documents 113064 113062 httpd/unix-directory 31
media 113065 113065 (INVALID) application/octet-stream (INVALID) 27

Two inconsistencies were identified for media:

  1. Its parent pointed to its own fileid (113065), forming a circular parent relationship.
  2. Its MIME type was application/octet-stream instead of httpd/unix-directory.

The expected parent was 113062, corresponding to the external storage root.

The media entry also had a cached size of 346164335630 bytes, while the storage root had a cached size of only 26366981385 bytes.

Investigation of child entries

A further read-only query returned:

total_entries               = 38532
media_children              = 31735
children_with_media_parent  = 3764

The children_with_media_parent count includes the media entry itself, due to its circular parent reference.

Many files and subdirectories beneath media/ were already indexed, including JPEG images, MP4 videos and nested directories.

A query searching for other self-referencing entries or non-directory entries with children returned only the media entry.

This suggests that the observed inconsistency was localized rather than widespread within the examined storage.

Repair using the official Nextcloud CLI

A non-recursive scan of the external storage root was performed:

sudo docker exec --user www-data nextcloud-aio-nextcloud \
  php occ files:scan \
  --path="/admin/files/Stockage externe" \
  --shallow \
  -v

Output:

Starting scan for user 1 out of 1 (admin)
Folder /admin/files/Stockage externe/

Folders:       1
Files:         0
New:           0
Updated:       1
Removed:       0
Errors:        0
Elapsed time:  00:00:00
Cache state after repair
Path File ID Parent MIME type Permissions
Root 113062 -1 httpd/unix-directory 31
backup 113063 113062 httpd/unix-directory 31
documents 113064 113062 httpd/unix-directory 31
media 113065 113062 (FIXED) httpd/unix-directory (FIXED) 31

The scan corrected the directory's parent, MIME type and permissions.

Importantly, the directory retained its original fileid (113065).

After the scan, the cached size of the root and media became -1, indicating an unknown or uncalculated size.

UI result

After refreshing the Nextcloud Files web interface, all three directories were visible again:

Stockage externe/
├── backup/
├── documents/
└── media/

The missing-directory symptom was therefore resolved without manually editing PostgreSQL and without performing a full recursive scan of the media collection.

Additional context — Concurrent Android client activity

Before the directory disappeared, multiple Android applications had accessed the same photo collection through Nextcloud HTTPS:

  • Nextcloud Android Client
  • Photos for Nextcloud

Observed or recalled activity included:

  • Automatic photo uploads
  • Automatic photo browsing and reading
  • Deletion of approximately one or two photos
  • Concurrent access to the media directory

It is not known which Android application performed the deletions.

Both applications connected through Nextcloud, not directly to the underlying Nginx WebDAV server.

This activity occurred before the cache inconsistency was discovered, but no direct causal relationship has been demonstrated.

A possible concurrency or cache-update issue is worth investigating, particularly when operations on an external WebDAV storage overlap. Other explanations, including incorrect WebDAV metadata interpretation or cache invalidation behavior, remain possible.

Expected behavior

  1. Nextcloud should handle directory creation with compatible WebDAV servers, or report an appropriate interoperability error.
  2. Concurrent clients should not cause existing external WebDAV directories to acquire circular parent references or incorrect MIME types in oc_filecache.
  3. Existing directories returned by the external WebDAV server should remain visible in Nextcloud Files.
  4. Cache refresh operations should maintain consistent parent-child relationships and directory metadata.

Actual behavior

  1. MKCOL without a trailing slash returns HTTP 409 on the tested Nginx backend.
  2. An existing directory was recorded as application/octet-stream with its own fileid as parent.
  3. The directory disappeared from Nextcloud Files despite being available through direct WebDAV PROPFIND.
  4. A shallow scan of the external storage root repaired the cache entry and restored its visibility.

Questions for maintainers

  1. Could a failed WebDAV operation or concurrent cache refresh produce a self-referencing parent in oc_filecache?
  2. Is there a known issue in the external WebDAV storage backend concerning directory MIME type detection or cache invalidation?
  3. Could concurrent Android WebDAV operations trigger inconsistent cache metadata for an external storage directory?
  4. Should Nextcloud normalize trailing slashes for MKCOL when interacting with WebDAV backends that require them?
  5. Is there an existing integrity check that could detect or automatically repair circular parent references in oc_filecache?

Workaround

For the missing-directory issue, the following command successfully restored the affected directory:

php occ files:scan \
  --path="/admin/files/Stockage externe" \
  --shallow

This is a recovery procedure, not a confirmed fix for the underlying cause.

The MKCOL interoperability issue remains unresolved.

Related issues

Potentially related reports:

These are references for comparison, not confirmed duplicates.

Additional notes

I can provide sanitized SQL results, WebDAV request/response traces, Nextcloud logs and screenshots if required.

The issue has not yet been reproduced under controlled conditions. The concurrent Android activity is contextual information, not proof of the root cause.

Steps to reproduce

See above

Expected behavior

See above

Nextcloud Server version

33

Operating system

None

PHP engine version

No response

Web server

No response

Database engine version

No response

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

No response

Are you using the Nextcloud Server Encryption module?

No response

What user-backends are you using?
  • Default user-backend (database)
  • LDAP/ Active Directory
  • SSO - SAML
  • Other
Configuration report

List of activated Apps

Nextcloud Signing status

Nextcloud Logs

Additional info

No response

主要语言
PHP
星标
37.5k
派生
5.4k
平均合并
1 天 13 小时
30 天内合并 PR
639

环境准备

在 Codespaces 中打开

在浏览器里用你自己的 GitHub 账号启动这个项目的开发容器。

从这里开始

  1. 先读完整个 Issue,再读项目的贡献指南。
  2. 在 Issue 下留言说明你要接手 —— 这能避免两个人做同样的事。
  3. Fork 仓库,在一个分支上完成修改。
  4. 提交 Pull Request,并在描述里引用这个 Issue 编号。

nextcloud/server 的其他 Issue

查看 nextcloud/server 的全部 Issue

相似的 Issue

更多 PHP Issue

把新 issue 发到你的邮箱

精选适合新手参与的 GitHub issue 摘要。