desktop icon indicating copy to clipboard operation
desktop copied to clipboard

[Bug]: Sync Error: Local folders not removed after server-side deletion (Group Folders) on long paths & "Zombie" folder re-uploads

Open limatus opened this issue 9 months ago • 23 comments

⚠️ Before submitting, please verify the following: ⚠️

Bug description

We are experiencing a persistent synchronization issue across our organization, affecting approximately 50 workstations. When a folder is deleted on the server side (specifically within Group Folders), the Desktop Client fails to remove the corresponding local folder.

Crucially, this issue appears to specifically influence files and folders with very long paths.

We have observed a specific behaviour pattern:

  1. Partial Deletion: When a folder containing documents is deleted on the server, the Desktop Client successfully deletes the files inside locally, but fails to delete the folder structure itself.
  2. “Zombie” Re-upload: Often, the client subsequently re-uploads these now-empty folders back to the cloud.
  3. Sync Loop: Other clients see the re-uploaded empty folder, download it, and the organization ends up with empty “ghost” folders that persist despite attempts to delete them.
  4. Local manual deletion of the folders does work and resolves the issue.

The client eventually enters a sync loop and displays the following error message: “Temporary error while removing a local object that was removed from the server” (Original German error: “Vorübergehender Fehler beim Entfernen eines vom Server entfernten lokalen Objekts”).

Steps to reproduce

  1. Create a deep folder structure (resulting in a long path) containing files within a Group Folder on the Nextcloud server.
  2. Wait for the folder and files to sync to the local Desktop Client.
  3. Delete the folder on the server (via Web UI).
  4. The Desktop Client attempts to sync the change.

Observation A: The local files inside the folder are deleted, but the folder itself remains on the local disk.

Observation B: The client reports a “Temporary error” and starts the sync process again (scans though everything, takes a very long time).

Observation C: In subsequent sync runs, the client may re-upload the empty folder to the server, restoring the folder structure that was just deleted.

Expected behavior

The local folder and all its contents should be deleted immediately after it is removed from the server, regardless of the path length. No re-upload of deleted content should occur.

Which files are affected by this bug

folders

Operating system

Windows

Which version of the operating system you are running.

Windows 11

Package

Official Windows MSI

Nextcloud Server version

32.0.3

Nextcloud Desktop Client version

3.17. - 4.0.6

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

Fresh desktop client install

Are you using the Nextcloud Server Encryption module?

Encryption is Disabled

Are you using an external user-backend?

  • [x] Default internal user-backend
  • [ ] LDAP/ Active Directory
  • [ ] SSO - SAML
  • [ ] Other

Nextcloud Server logs

2026-02-02 14:20:44:890 [ info nextcloud.sync.discovery C:\Users\User\AppData\Local\Temp\windows-36446\client-building\desktop\src\libsync\discovery.cpp:79 ]:	STARTING "04_Dept/Education/Projects/1) Project_World_Global/16) Archive/Archive_Module_Folder/D_Archive/Migration, Aid, Racism/PT Help-OLD/Archive/03_Project_Components_Detail/05_Process_Aid_Projects" OCC::ProcessDirectoryJob::ParentNotChanged "04_Dept/Education/Projects/1) Project_World_Global/16) Archive/Archive_Module_Folder/D_Archive/Migration, Aid, Racism/PT Help-OLD/Archive/03_Project_Components_Detail/05_Process_Aid_Projects" OCC::ProcessDirectoryJob::NormalQuery
2026-02-02 14:20:44:890 [ info nextcloud.sync.discovery C:\Users\User\AppData\Local\Temp\windows-36446\client-building\desktop\src\libsync\discovery.cpp:79 ]:	STARTING "04_Dept/Education/Projects/1) Project_World_Global/16) Archive/Archive_Module_Folder/D_Archive/Migration, Aid, Racism/PT Help-OLD/Archive/03_Project_Components_Detail/02_Why_Help_Millennium_Goals/Refugeechair War&Flight" OCC::ProcessDirectoryJob::ParentNotChanged "04_Dept/Education/Projects/1) Project_World_Global/16) Archive/Archive_Module_Folder/D_Archive/Migration, Aid, Racism/PT Help-OLD/Archive/03_Project_Components_Detail/02_Why_Help_Millennium_Goals/Refugeechair War&Flight" OCC::ProcessDirectoryJob::NormalQuery
...
2026-02-02 14:20:45:034 [ info nextcloud.sync.discovery C:\Users\User\AppData\Local\Temp\windows-36446\client-building\desktop\src\libsync\discovery.cpp:1888 ]:	Processing "04_Dept/Education/Projects/1) Project_World_Global/1) PT/MODULE/Flight & Migration" | (db/local/remote) | valid: true/true/false | mtime: 1769504176/1769504176/0 | size: 0/4096/0 | etag: "69787db028429"//"" | checksum: ""//"" | perm: "GDNVCKRm"//"" | fileid: "536160326ocsozzlajw5d"//"" | inode: 232108/232108/ | type: CSyncEnums::ItemTypeDirectory/CSyncEnums::ItemTypeVirtualDirectory/CSyncEnums::ItemTypeFile | e2ee: false/false | e2eeMangledName: ""/"" | file lock: not locked// | file lock type: ""//"" | live photo: false//false | metadata missing: /false/
2026-02-02 14:20:45:034 [ info nextcloud.sync.discovery C:\Users\User\AppData\Local\Temp\windows-36446\client-building\desktop\src\libsync\discovery.cpp:1889 ]:	discovered "04_Dept/Education/Projects/1) Project_World_Global/1) PT/MODULE/Flight & Migration" CSyncEnums::CSYNC_INSTRUCTION_REMOVE OCC::SyncFileItem::Down CSyncEnums::ItemTypeDirectory
...
2026-02-02 14:20:45:519 [ info nextcloud.sync.propagator C:\Users\User\AppData\Local\Temp\windows-36446\client-building\desktop\src\libsync\owncloudpropagator.h:213 ]:	Starting CSyncEnums::CSYNC_INSTRUCTION_REMOVE propagation of "04_Dept/Education/Projects/1) Project_World_Global/1) PT/MODULE/Flight & Migration" by OCC::PropagateLocalRemove(0x2db01d2fd20)
2026-02-02 14:20:45:519 [ info nextcloud.sync.propagator.localremove C:\Users\User\AppData\Local\Temp\windows-36446\client-building\desktop\src\libsync\propagatorjobs.cpp:105 ]:	Start propagate local remove job
2026-02-02 14:20:45:519 [ info nextcloud.log.permanent C:\Users\User\AppData\Local\Temp\windows-36446\client-building\desktop\src\libsync\propagatorjobs.cpp:106 ]:	delete "04_Dept/Education/Projects/1) Project_World_Global/1) PT/MODULE/Flight & Migration" "Processing \"04_Dept/Education/Projects/1) Project_World_Global/1) PT/MODULE/Flight & Migration\" | (db/local/remote) | valid: true/true/false | mtime: 1769504176/1769504176/0 | size: 0/4096/0 | etag: \"69787db028429\"//\"\" | checksum: \"\"//\"\" | perm: \"GDNVCKRm\"//\"\" | fileid: \"536160326ocsozzlajw5d\"//\"\" | inode: 232108/232108/ | type: CSyncEnums::ItemTypeDirectory/CSyncEnums::ItemTypeVirtualDirectory/CSyncEnums::ItemTypeFile | e2ee: false/false | e2eeMangledName: \"\"/\"\" | file lock: not locked// | file lock type: \"\"//\"\" | live photo: false//false | metadata missing: /false/"
2026-02-02 14:20:45:519 [ info nextcloud.sync.propagator.localremove C:\Users\User\AppData\Local\Temp\windows-36446\client-building\desktop\src\libsync\propagatorjobs.cpp:114 ]:	Going to delete: "C:/Users/username/NC/Nextcloud/04_Dept/Education/Projects/1) Project_World_Global/1) PT/MODULE/Flight & Migration"
2026-02-02 14:20:45:519 [ info nextcloud.sync.propagator.localremove C:\Users\User\AppData\Local\Temp\windows-36446\client-building\desktop\src\libsync\propagatorjobs.cpp:57 ]:	delete "C:/Users/username/NC/Nextcloud/04_Dept/Education/Projects/1) Project_World_Global/1) PT/MODULE/Flight & Migration"
2026-02-02 14:20:45:523 [ warning nextcloud.sync.filesystem C:\Users\User\AppData\Local\Temp\windows-36446\client-building\desktop\src\libsync\filesystem.cpp:316 ]:	File is already deleted "C:/Users/username/NC/Nextcloud/04_Dept/Education/Projects/1) Project_World_Global/1) PT/MODULE/Flight & Migration/3_Methods_Flight&Migration&Racism/Method_Collections/Information_Office_Country_racism/1 How does it happen/2 The danger of a single story"
2026-02-02 14:20:45:523 [ warning nextcloud.sync.filesystem C:\Users\User\AppData\Local\Temp\windows-36446\client-building\desktop\src\libsync\filesystem.cpp:322 ]:	remove: Das Verzeichnis ist nicht leer.: "C:/Users/username/NC/Nextcloud/04_Dept/Education/Projects/1) Project_World_Global/1) PT/MODULE/Flight & Migration/3_Methods_Flight&Migration&Racism/Method_Collections/Information_Office_Country_racism/1 How does it happen" "C:/Users/username/NC/Nextcloud/04_Dept/Education/Projects/1) Project_World_Global/1) PT/MODULE/Flight & Migration/3_Methods_Flight&Migration&Racism/Method_Collections/Information_Office_Country_racism/1 How does it happen"
2026-02-02 14:20:45:523 [ warning nextcloud.sync.filesystem C:\Users\User\AppData\Local\Temp\windows-36446\client-building\desktop\src\libsync\filesystem.cpp:343 ]:	Error removing folder "C:\\Users\\username\\NC\\Nextcloud\\04_Dept\\Education\\Projects\\1) Project_World_Global\\1) PT\\MODULE\\Flight & Migration\\3_Methods_Flight&Migration&Racism\\Method_Collections\\Information_Office_Country_racism\\1 How does it happen" "remove: Das Verzeichnis ist nicht leer.: \"C:/Users/username/NC/Nextcloud/04_Dept/Education/Projects/1) Project_World_Global/1) PT/MODULE/Flight & Migration/3_Methods_Flight&Migration&Racism/Method_Collections/Information_Office_Country_racism/1 How does it happen\""
2026-02-02 14:20:45:523 [ warning nextcloud.sync.propagator C:\Users\User\AppData\Local\Temp\windows-36446\client-building\desktop\src\libsync\owncloudpropagator.cpp:280 ]:	Could not complete propagation of "04_Dept/Education/Projects/1) Project_World_Global/1) PT/MODULE/Flight & Migration" by OCC::PropagateLocalRemove(0x2db01d2fd20) with status OCC::SyncFileItem::NormalError and error: "Vorübergehender Fehler beim Entfernen eines vom Server entfernten lokalen Objekts."
2026-02-02 14:20:45:526 [ warning nextcloud.gui.activity C:\Users\User\AppData\Local\Temp\windows-36446\client-building\desktop\src\gui\tray\usermodel.cpp:904 ]:	Item  "04_Dept/Education/Projects/1) Project_World_Global/1) PT/MODULE/Flight & Migration"  retrieved resulted in  "Vorübergehender Fehler beim Entfernen eines vom Server entfernten lokalen Objekts."
2026-02-02 14:20:45:526 [ info nextcloud.gui.activity C:\Users\User\AppData\Local\Temp\windows-36446\client-building\desktop\src\gui\tray\usermodel.cpp:850 ]:	Item  "04_Dept/Education/Projects/1) Project_World_Global/1) PT/MODULE/Flight & Migration"  retrieved resulted in error  "Vorübergehender Fehler beim Entfernen eines vom Server entfernten lokalen Objekts."
2026-02-02 14:20:45:526 [ warning nextcloud.gui.activity C:\Users\User\AppData\Local\Temp\windows-36446\client-building\desktop\src\gui\tray\activitylistmodel.cpp:601 ]:	Error successfully added to the notification list:  OCC::ActivityListModel::ErrorType::SyncError "04_Dept/Education/Projects/1) Project_World_Global/1) PT/MODULE/Flight & Migration" "Vorübergehender Fehler beim Entfernen eines vom Server entfernten lokalen Objekts." OCC::SyncResult::Undefined OCC::SyncFileItem::NormalError
2026-02-02 14:20:45:535 [ warning nextcloud.gui.folder C:\Users\User\AppData\Local\Temp\windows-36446\client-building\desktop\src\gui\folder.cpp:1284 ]:	SyncEngine finished with ERROR

Additional info

No response

limatus avatar Feb 04 '26 14:02 limatus

Hi there, You confirm having this problem on PC client version 4.0.6 ?

TheGranadilla avatar Feb 04 '26 14:02 TheGranadilla

We have the problem also with 4.0.6, even the alpha versions produce the same errors

limatus avatar Feb 04 '26 14:02 limatus

I found this also in 4.0.x, but turning off the trash handling in the client eliminated the problem (the long path names were increasing in length on movement to the recycle bin, causing a Windows error):

Image

acrey1 avatar Feb 05 '26 07:02 acrey1

Thanks for the suggestion, it's not activated by default and none of our clients has this.

I also had the same idea in the beginning, as this seems to be an issue with the recycle bin.

limatus avatar Feb 05 '26 08:02 limatus

For us as well, this feature is not enabled by default, and we are experiencing the same frustrating issue whit 4.0.4 desktop version.

cyrzero avatar Feb 05 '26 13:02 cyrzero

Original message deleted, was probably another issue.

But I confirm I saw that bug too with 4.0.6 on PC. And I do believe it's the folder that were "traveled" by the User, that remained. So... maybe related to hidden files created (thumbnails etc...)

Floweb05 avatar Feb 09 '26 19:02 Floweb05

I don't know if it's a Windows and macOS issue, so far, I can only confirm it with Windows.

Additional Observation: When a Groupfolder is deleted server-side, the client successfully removes the files, but the empty folder structure often remains locally. I used Microsoft PowerToys File Locksmith to inspect these "undeletable" folders, and it showed that explorer.exe was the only process holding a handle on them.

Hypothesis: It seems like Windows Explorer gets stuck trying to read metadata/thumbnails from these deep directory paths, creating a temporary lock that causes the standard removal calls to fail. Or just fails, as of the long paths.

Suggestion: Could this be solved by explicitly using the Windows Native API with the Extended Path Prefix (\?) for directory removal?

From what I understand, standard Qt calls might struggle here, but using the \?\ prefix (e.g., prepending it to the path before calling RemoveDirectoryW) tells Windows to bypass the MAX_PATH parsing and ignore certain file system locks more aggressively.

Perhaps adding a small "retry" logic (waiting a few milliseconds if explorer.exe is locking it) combined with the extended path prefix would resolve these leftovers?

Its quite blocking the native usage of the client.

limatus avatar Feb 10 '26 08:02 limatus

  • the errors are piling up, and the error code is very generic (it took me a bit of brain to understand what the issue is linked to, a normal user will not be able - just in terms of user-friendly error codes): Image

limatus avatar Feb 10 '26 10:02 limatus

The problem persists with version 33.0.0-rc1. The same accounts for the daily version.

limatus avatar Feb 19 '26 19:02 limatus

Tested 33.0.0-rc1 on MacOS 15.7.4 + 26.0 ("MacOS running on cocoa")

I have the same Issue on MacOS

To reproduce: (I installed 4.0.6 MacOS 12+ > Changed update channel to beta > updated to 33.0.0 rc1) (push notifications activated server-side | Server: 32.0.5)

  1. As admin, I share a folder to a user group "team".
  2. As MacUser1 (member of "team" group) i "travel" that folder locally (i do not open any file)
  3. As admin, i delete that folder
  4. MacUser1 still see that folder + files in it, there is a "sync problem" icon only on the file inside that folder.

Nextcloud client of MacUser1 show the "admin deleted xx folder" notification. Restarted app + MacOS : No effect. But after reboot Nextcloud client say "Some files could not be synced! See bellow for warnings", but I can't see any warning.

(I also tested using a direct sharing to MacUser1 instead of group share : same issue) It seems any empty folder deletion works

Image

Debug archive ready if needed. I can also provide a user account on my server if this can help.

@limatus

Crucially, this issue appears to specifically influence files and folders with very long paths.

In my case, it occur on a verry short path.

@i2h3 Hello :) I think you can add the "os: Mac" Tag ;)

Floweb05 avatar Feb 20 '26 12:02 Floweb05

Very strange, thanks for sharing.

Can you test to add data (a document) into the folder, because for me the data deletion is no problem, it's just the folders causing issues. Which makes it even more confusing for me.

limatus avatar Feb 20 '26 12:02 limatus

Can you test to add data (a document) into the folder, because for me the data deletion is no problem, it's just the folders causing issues. Which makes it even more confusing for me.

Locally adding a file to that server-side-deleted directory : File stay local only. (And if I delete a folder with files in it : thoses files remain displayed locally, but I can't open it)

Other observations:

  1. It's not linked to sharing, I can reproduce this using only MacUser1 (web interface - client)
  2. This bug occur 100% of the time. But from my test, it's only when the directory have been locally traveled.
  3. Once Im in the "deleted folder sync issue" situation, When I add new folders on web interface, client sometimes don't sync it
  4. Disabling/Enabling Virtual Files fix the situation and remove deleted folder locally.

Floweb05 avatar Feb 20 '26 13:02 Floweb05

We face the same issue using 4.0.6 on Windows 11. We do not use Virtual Files, and the trash setting is disabled. For us, the case appeared when excluding a folder from synchronization. The folder is read-only and there have been no changes on the server for months, at least. Excluding the folder from the client leads to this error. I tried enabling/disabling the Virtual Files setting, let's see if that fixes it...

mrd0ll4r avatar Feb 26 '26 08:02 mrd0ll4r

I noticed another detail during my tests that might help narrow this down.

The client successfully deletes all individual files inside these deep folder structures. It only fails when attempting to remove the empty directories left behind.

Since the file deletions succeed, I am wondering if this might not be a strict MAX_PATH parsing issue after all. Could this be a timing issue / race condition? Hypothesis: When the client deletes a file, explorer.exe (via cfapi) briefly grabs a handle on the parent directory to update its metadata. If the client attempts to delete that same directory immediately afterward, it hits a temporary lock.

It's still an issue with RC2 btw.

Thanks for the hard work.

limatus avatar Feb 27 '26 19:02 limatus

The client successfully deletes all individual files inside these deep folder structures. It only fails when attempting to remove the empty directories left behind.

YES!

acrey1 avatar Feb 27 '26 22:02 acrey1

#8694

On PC (w11) : I can't reproduce this issue since RC1, I Don't understand 😭 (Maybe it occur sometimes and not 100% of the time?)

Nextcloud 33 RC2 MacOs release, the issue is still there 😒 NC Client fail to locally remove a folder that was deleted on server. DESPITE Nextcloud APP list the folder deletion in the recent events. It occur 100% of the time!

TO REPRODUCE: Fresh installed and updated MacOS 23.6. Server: 32.0.5 Docker (community, not AIO) / Behind Nginx Proxy

  • On web Interface I have Folder 1 > Subfolder > image.jpg.
  • I travel that directory, locally, on Mac.
  • I delete "Folder 1" from web interface.
  • "Folder 1" is still shown locally on my Mac, with subfolder and it's content (but I can't open image.jpg obviously)

I confirm it occur only when folder was travelled.

Attached file: MacOS Console events between folders creation, and folder deletion server side.

deletion_consolelog.txt

Floweb05 avatar Mar 02 '26 17:03 Floweb05

We also had this problem with all versions from 3.16.x onwards. The Windows client with version 3.15.3 does not seem to have this problem. After several tests with long paths and file names and a deep folder structure, everything worked perfectly here.

We have now reinstalled all installations back to 3.15.3 ...

It must be related to the long path and file name. If the folders don't have that depth and length, it works fine!

rosegarden40822-cmd avatar Mar 11 '26 08:03 rosegarden40822-cmd

@Floweb05 I somehow missed your mention. It would definitely be plausible for this to affect all platforms, given it being originally reported for the classic synchronization, if I am not mistaken. That is the reason why your screenshot confuses me, it looks like you are presenting the file provider domain but not a classic synchronization folder. Though, the original report was about a classic synchronization folder on Windows. The file provider extension on macOS is a completely independent implementation.

Besides, extraordinarily long paths are not an issue on macOS as they used to regularly be on Windows for historic reasons.

I vaguely remember there being an issue with group folders and their ETags not being updated in root folders and when the stars do not align… mumble… mumble… something edge case. 🤔

Anyway, aren't you describing your #9553? I just want to be sure I understand this correctly and we keep the issues on topic. It would be easier for us to handle and keep the conversation focussed when you open a dedicated issue for your problem (if necessary), when it is not classic synchronization folder on Windows but file provider extension on macOS.

PS: The most valuable log messages of your file provider extension are visible in Console.app only for debug builds (as a developer convenience feature to also reveal them in the Xcode console) while the JSON line log files are the main target for various reasons.

i2h3 avatar Mar 11 '26 08:03 i2h3

@rosegarden40822-cmd - thanks for sharing and confirming - for me, ill tried the same, but it's quite a challenging task / impossible. I hope someone from the Windows Client Dev Colleagues will see the issue... and then maybe the stars will align, and I can sleep better.

limatus avatar Mar 11 '26 09:03 limatus

For the record, I opened #9602 because this affects the macOS file provider extension, too. This might also turn out to be a server API issue. We will see on investigation.

i2h3 avatar Mar 11 '26 15:03 i2h3