I'm using CFMX 7 with iText. I have a form in which users can
select multiple pdf documents via checkboxes. After selecting a
number of checkboxes, they can either immediately hit the Submit
button to merge (using iText) all selected documents, or from a
dropdown box, select an image to be applied to the top of each
document, and then hit Submit, which will merge the documents
first, then apply the image to each page of the merged documents.
(reference this post for additional information:
Watermark position issue)
The merging and watermarks work great; however the problem
I'm having now is what appears to be file corruption. Every now and
again, when a user selects the documents and an image, the page
processes, but returns a previously merged document with a previous
image applied. Looking at merged file on the server confirms that
the file is corrupt and sometimes I am able to delete the file and
then future selections merge correctly.
So I figured I could apply cflock - as this must be a race
condition issue - to prevent the corruption. However, I don't think
I fully understand it as it does not appear to be working. I have
some documentation where you are supposed to name the locks the
same and other documentation states to name one readonly and the
Attached is my code below. Can someone please look and give
advice as how to proceed? Also, I can include the code from
mergeOnly.cfm and mergeWatermark.cfm if necessary.
Also, if you are replacing an _existing_ file, you might
consider using a temporary file, to avoid locking the entire call.
Then at the end, replace the existing file with the temporary one,
and delete the temp file.