• Global community
    • Language:
      • Deutsch
      • English
      • Español
      • Français
      • Português
  • 日本語コミュニティ
    Dedicated community for Japanese speakers
  • 한국 커뮤니티
    Dedicated community for Korean speakers
Exit
0

cflock and iText

Explorer ,
Jan 14, 2009 Jan 14, 2009

Copy link to clipboard

Copied

Developers,

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: iText 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 other exclusive.

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.

Thanks.

TOPICS
Advanced techniques

Views

670

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Valorous Hero ,
Jan 14, 2009 Jan 14, 2009

Copy link to clipboard

Copied

> but returns a previously merged document with a previous image applied.

First thing I would ask is whether you checking the returned status of the insertWatermarkPDF function. So you can determine when an error occurs and perform a different action if one did ..

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Valorous Hero ,
Jan 14, 2009 Jan 14, 2009

Copy link to clipboard

Copied

LATEST
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.

Here is a good link on locking file renames:
http://www.houseoffusion.com/groups/cf-talk/thread.cfm/threadid:49321#263456

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Resources
Documentation