Adding and removing documents via the API did not always work correctly

When adding and removing documents via the API, SharePoint, website, and local files were not always processed correctly, causing the File field to be filled incorrectly.