[erlang-questions] Reading a file before it has been completely written

David Mercer dmercer@REDACTED
Thu Mar 8 15:23:30 CET 2012


On Wednesday, March 07, 2012, I wrote:
> On Wednesday, March 07, 2012, Richard Carlsson wrote:
> 
> > Trying to fiddle with exclusive locks is probably always
> going
> > to have corner cases. The only techniques you can trust to
> practically
> > always work and be portable across file systems are directory
> creation
> > and file renaming. So what Tony suggested is likely to be the best
> > solution: create the file under another name or in a separate
> > directory,
> > and when it's completely written, rename it.
> 
> I might go back to my renaming approach, which also had no failures
> during
> testing.  I just attempt to rename the file to itself.  If it fails, I
> try
> again 5 seconds later.

For closure here, I went back to my approach of attempting to rename the
file to itself before reading it.  I'll let y'all know if I encounter any
more corner cases.

Cheers,

DBM




More information about the erlang-questions mailing list