• Open Menu Close Menu
  • Apple
  • Shopping Bag
  • Apple
  • Mac
  • iPad
  • iPhone
  • Watch
  • TV
  • Music
  • Support
  • Search apple.com
  • Shopping Bag

Lists

Open Menu Close Menu
  • Terms and Conditions
  • Lists hosted on this site
  • Email the Postmaster
  • Tips for posting to public mailing lists
Re: Notification of file system modification arrives too early?
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Notification of file system modification arrives too early?


  • Subject: Re: Notification of file system modification arrives too early?
  • From: James Bucanek <email@hidden>
  • Date: Sun, 30 May 2010 07:57:24 -0700

Antonio Nunes <mailto:email@hidden> wrote (Friday, May 28, 2010 3:05 AM +0100):

My app is set to observe a folder for changes to its contents (using UKKQueue.
Thanks Uli! :-)). When files are dropped into the folder the app is notified
and processes the files. This works well, except for one catch: sometimes we
receive the notification and spawn the worker thread, and trying to load the
file fails ( [[PDFDocument alloc] initWithURL:sourceURL] returns nil). This
seems to happen predominantly with large files. I get the impression the
notification happens as soon as the file transfer into the watched directory
begins, and my worker thread is ready and starts loading the file before it
has been fully transferred. Hence the failure to create a PDFDocument from the
file.

Is there a way to check whether the file has been fully transferred, or, even
better, to get notified only when the file transfer has been completed?

I deal with this in my app by creating a kqueue to watch for changes in the enclosing folder. When a change occurs, I attempt to open the file using the FS API specifying exclusive read + exclusive write access. If it fails, it's likely because some other process still has the file open. I delay a half second or so and try again.


--
James Bucanek

_______________________________________________

Cocoa-dev mailing list (email@hidden)

Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com

Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden


  • Follow-Ups:
    • Re: Notification of file system modification arrives too early?
      • From: Jens Alfke <email@hidden>
References: 
 >Notification of file system modification arrives too early? (From: Antonio Nunes <email@hidden>)

  • Prev by Date: Re: example of a NSScrollView where scrolling is overridden ?
  • Next by Date: UTI strings
  • Previous by thread: Re: Notification of file system modification arrives too early?
  • Next by thread: Re: Notification of file system modification arrives too early?
  • Index(es):
    • Date
    • Thread