CopyOnReadDirectory currently deletes local files which are not found in remote upon close. The list of remote file is fixed for a given revision however list of local files may vary.
IndexTracker opens a new IndexNode upon update before closing the older one. When CopyOnRead is enabled it can happen that same local directory might be in use by two wrapper directories at the same time.
This introduces a race condition in removeDeletedFiles method as by the time it is invoked a newer wrapped directory might have started adding new files so those files would get included in the listing done for local directory and hence cause them to be deleted as they would not be found in remote directory which is pinned to older revision. Leading to following exception
As a fix the list of local file should be maintained as progress is made once the CopyOnRead instance gets created to ensure it does not pick up files which are added once the directory is closed