File Provider Extension Rollback Action

Hi all, i am trying to implement File Provider Extension. I have some scenarios that I can not figure out,

  1. User delete a file on local. 'deleteItem' callback is triggered. I send delete request to remote server. Remove server failed to apply deletion (for some reason deletion failed, blocked). I call 'completionHandler' with necessary error but here is the problem. File is removed in user local but exit in remote server. After some time 'deleteItem' callback is triggered multiple times for this file. I need to put same file in user local (rollback deletion) and stop triggered callbacks.

  2. I have a folder named "New folder". This folder is dataless (its sub items is not enumerated yet). User add a file named "a.txt" to this folder on remote server. I detect that addition. When I apply that addition with 'NSFileProviderChangeObserver' observers 'didUpdate' method then enumerate this directory "a.txt" is duplicated (a 2.txt is created). Is there any way to control folder named "New folder" is dataless (its sub items is not enumerated) so that I can skip file addition to prevent duplication.

Any suggestion about above scenarios

Answered by DTS Engineer in 829273022

Regarding question 1, the deleteItem method is triggered again to give you a chance to recover the error. Typically, you will take the chance to make sure that the file is deleted on the server side, and then report a success to the system by calling the completionHandler with nil.

Alternatively, if you'd recover the deleted file on the device, consider reporting a success in deleteItem, and then trigger a new enumeration by calling signalEnumerator for the extension to add back the item.

Regarding question 2, I can't quite reason why the issue happens. When getting notified of a server change, you trigger an enumeration, and your extension reports what the server has to the system, which shouldn't lead to a duplicate...

Does the issue happen with the Synchronizing files using file provider extensions sample? When you have the sample app and extension up and running on your system, the server side storage is at ~/Library/CloudStorage/<fileproviderdomain>, and so you can mimic your case by adding the file to the path, and see if that triggers the same issue.

Best,
——
Ziqiao Chen
 Worldwide Developer Relations.

Accepted Answer

Regarding question 1, the deleteItem method is triggered again to give you a chance to recover the error. Typically, you will take the chance to make sure that the file is deleted on the server side, and then report a success to the system by calling the completionHandler with nil.

Alternatively, if you'd recover the deleted file on the device, consider reporting a success in deleteItem, and then trigger a new enumeration by calling signalEnumerator for the extension to add back the item.

Regarding question 2, I can't quite reason why the issue happens. When getting notified of a server change, you trigger an enumeration, and your extension reports what the server has to the system, which shouldn't lead to a duplicate...

Does the issue happen with the Synchronizing files using file provider extensions sample? When you have the sample app and extension up and running on your system, the server side storage is at ~/Library/CloudStorage/<fileproviderdomain>, and so you can mimic your case by adding the file to the path, and see if that triggers the same issue.

Best,
——
Ziqiao Chen
 Worldwide Developer Relations.

File Provider Extension Rollback Action
 
 
Q