• 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
problem with updates to file last modified time
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

problem with updates to file last modified time


  • Subject: problem with updates to file last modified time
  • From: Alan Snyder <email@hidden>
  • Date: Fri, 02 Dec 2016 10:45:41 -0800

I am trying to write a test program for the Java Watch Service, which detects file creation, deletion, and modification by polling. Detection of file modification is implemented using the last modified time file attribute, which is read for each file individually and converted as needed to milliseconds by truncation.

To test the detection of file modification, I need to ensure that I modify the file in a way that changes the last modified time by at least one millisecond. The file may have just been created, so I pause for some amount of time before modifying the file to make sure that I am not modifying the file too soon after its creation to change the last modified time.

I am having trouble getting this to work reliably.

I have increased the pause before modification to 500 ms and the time I wait afterwards to observe a changed last modified time to 50 seconds, yet I still sometimes I timeout without seeing the attribute change. When this happens, my program modifies the file again. So far, that has never failed.

Two problems could be impacting this test, and it is hard to tease them apart:

1. A stale value could be written to the attribute when the file is closed.

2. Changes to the attribute are not visible for some time after the file is closed.

I am thinking the problem may be the first one, because waiting longer does not seem to help but modifying the file twice does.

Does anyone have advice on how to do this reliably?

  Alan




 _______________________________________________
Do not post admin requests to the list. They will be ignored.
Filesystem-dev mailing list      (email@hidden)
Help/Unsubscribe/Update your Subscription:

This email sent to email@hidden


  • Follow-Ups:
    • Re: problem with updates to file last modified time
      • From: Chris Murphy <email@hidden>
    • Re: problem with updates to file last modified time
      • From: Thomas Tempelmann <email@hidden>
  • Next by Date: Re: problem with updates to file last modified time
  • Next by thread: Re: problem with updates to file last modified time
  • Index(es):
    • Date
    • Thread