Completed
Push — development ( 3378c0...2308db )
by Mirco
07:24
created

OkapiCleanup::run()   A

Complexity

Conditions 4
Paths 3

Size

Total Lines 14
Code Lines 6

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 4
eloc 6
nc 3
nop 0
dl 0
loc 14
rs 9.2
c 0
b 0
f 0
1
<?php
2
/***************************************************************************
3
 *  For license information see doc/license.txt
4
 *
5
 *  Workaround for OKAPI issue #246
6
 ***************************************************************************/
7
8
checkJob(new OkapiCleanup());
9
10
class OkapiCleanup
0 ignored issues
show
Coding Style Compatibility introduced by
PSR1 recommends that each class must be in a namespace of at least one level to avoid collisions.

You can fix this by adding a namespace to your class:

namespace YourVendor;

class YourClass { }

When choosing a vendor namespace, try to pick something that is not too generic to avoid conflicts with other libraries.

Loading history...
11
{
12
    public $name = 'okapi_cleanup';
13
    public $interval = 3600;
14
15
    public function run()
16
    {
17
        global $opt;
18
19
        $files = glob($opt['okapi']['var_dir'] . '/garmin*.zip');
20
        foreach ($files as $file) {
21
            // delete old download files after 24 hours; this large interval filters out any
22
            // timezone mismatches in file systems (e.g. on unconventional development
23
            // environments)
24
            if (is_file($file) && (time() - filemtime($file)) > 24 * 3600) {
25
                unlink($file);
26
            }
27
        }
28
    }
29
}
30