Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.lang.php > #3819

Re: Prevent unlink(...) warning

From Simon <bad@example.com>
Newsgroups comp.lang.php
Subject Re: Prevent unlink(...) warning
Date 2011-11-17 19:21 +0200
Message-ID <9iku5gFi18U1@mid.individual.net> (permalink)
References <9ikm3eFih4U1@mid.individual.net> <ja38jj$au4$1@news.albasani.net>

Show all headers | View raw


On 2011/11/17 05:18 PM, The Natural Philosopher wrote:
> Simon wrote:
>> Hi,
>>
>> I am having some race condition issues on my server when trying to
>> delete a file.
>>
>
> what makes you think its a race condition?

A guess really,

If I do:
...
if (file_exists($filename))
{

and followed by
...
   @unlink($filename);
}

And that gives me a

unlink(/home/xxx/public_html/temp/yyy.zz) [function.unlink]: No such 
file or directory

The something between file_exists(...) and @unlink(...) must have 
removed the file.
Either that or one of the two functions is not working as expected.

>
> Why do you care about the stat cache?
>

As per the doc, http://php.net/manual/en/function.clearstatcache.php, to 
make sure that file_exists($filename) does return a cached value.

>>
>> How can I prevent the warning?
>>
> Why prevent it at all?
>
> As long as the file is not there when you are finished - why not just
> unlink it anyway?
>

Because the warnings fill my logs and I aim for no warnings at all.

Simon

Back to comp.lang.php | Previous | Next — Previous in thread | Next in thread | Find similar | Unroll thread


Thread

Prevent unlink(...) warning Simon <bad@example.com> - 2011-11-17 17:04 +0200
  Re: Prevent unlink(...) warning The Natural Philosopher <tnp@invalid.invalid> - 2011-11-17 15:18 +0000
    Re: Prevent unlink(...) warning Simon <bad@example.com> - 2011-11-17 19:21 +0200
      Re: Prevent unlink(...) warning The Natural Philosopher <tnp@invalid.invalid> - 2011-11-17 18:29 +0000
  Re: Prevent unlink(...) warning "Álvaro G. Vicario" <alvaro.NOSPAMTHANX@demogracia.com.invalid> - 2011-11-17 18:42 +0100
  Re: Prevent unlink(...) warning Jerry Stuckle <jstucklex@attglobal.net> - 2011-11-17 13:54 -0500

csiph-web