I have a document library in SharePoint 2010 to which a user is uploading spreadsheets via a custom web part.
These spreadsheets are later processed by another custom web part and updated. A user could also potentially go to the document library and directly edit the spreadsheet as well (in the case that it contains errors that need to be fixed before it can be processed). We wish to track each version of the document so "Versioning - Major Versions Only" is enabled. To ensure that the user updates the document in the document library and puts a checkin comment, I set "Require documents to be checked out before they can be edited?" to Yes.
[Edit]: We also want to ensure that the document isn't edited whilst the code is reading and writing to the file.
The code in the web part that processes the spreadsheets retrieves the list of documents from the document library then loops through them one at a time to process them. At the start of the loop, the code attempts to perform a Check Out on the file but receives an error stating that the file is already checked out by that user and thus cannot be processed.
If I set "Require documents to be checked out before they can be edited?" to No, then this error goes away and the web part can check out the file and process it without any issues. As such, my question is this:
When does SharePoint check out the file when "Require documents to be checked out before they can be edited?" is set to Yes?