Beefy Boxes and Bandwidth Generously Provided by pair Networks
Welcome to the Monastery
 
PerlMonks  

Re: Intermittent bug in module: File not getting deleted as expected

by haukex (Archbishop)
on Feb 19, 2019 at 18:11 UTC ( #1230175=note: print w/replies, xml ) Need Help??


in reply to Intermittent bug in module: File not getting deleted as expected

In addition to what stevieb said about the -M test, which does seem a likely candidate (remember it depends on the behavior of the filesystem), I also see you aren't checking unlink for success or failure. For the former issue, you might want to add some kind of "force" parameter to cleanup to skip the -M test overall and just delete all files, that way the test will be more deterministic.

Replies are listed 'Best First'.
Re^2: Intermittent bug in module: File not getting deleted as expected
by stevieb (Canon) on Feb 19, 2019 at 18:23 UTC

    Good catch on the unlink checking, I had completely overlooked that. In cleanup(), OP should be doing something like:

    if (-M $file >= $age){ unlink $file or die "can't delete the damned file!: $!"; }

    ...even if your suggested "force" param is introduced.

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: note [id://1230175]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others perusing the Monastery: (3)
As of 2022-08-08 03:59 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found

    Notices?