Passed
Push — master ( c158ee...e231dd )
by Roeland
12:36 queued 11s
created
apps/dav/lib/BackgroundJob/UploadCleanup.php 1 patch
Indentation   +48 added lines, -48 removed lines patch added patch discarded remove patch
@@ -36,53 +36,53 @@
 block discarded – undo
36 36
 
37 37
 class UploadCleanup extends TimedJob {
38 38
 
39
-	/** @var IRootFolder */
40
-	private $rootFolder;
41
-
42
-	/** @var IJobList */
43
-	private $jobList;
44
-
45
-	public function __construct(ITimeFactory $time, IRootFolder $rootFolder, IJobList $jobList) {
46
-		parent::__construct($time);
47
-		$this->rootFolder = $rootFolder;
48
-		$this->jobList = $jobList;
49
-
50
-		// Run once a day
51
-		$this->setInterval(60*60*24);
52
-	}
53
-
54
-	protected function run($argument) {
55
-		$uid = $argument['uid'];
56
-		$folder = $argument['folder'];
57
-
58
-		try {
59
-			$userFolder = $this->rootFolder->getUserFolder($uid);
60
-			$userRoot = $userFolder->getParent();
61
-			/** @var Folder $uploads */
62
-			$uploads = $userRoot->get('uploads');
63
-			/** @var Folder $uploadFolder */
64
-			$uploadFolder = $uploads->get($folder);
65
-		} catch (NotFoundException $e) {
66
-			$this->jobList->remove(self::class, $argument);
67
-			return;
68
-		}
69
-
70
-		$files = $uploadFolder->getDirectoryListing();
71
-
72
-		// Remove if all files have an mtime of more than a day
73
-		$time = $this->time->getTime() - 60 * 60 * 24;
74
-
75
-		// The folder has to be more than a day old
76
-		$initial = $uploadFolder->getMTime() < $time;
77
-
78
-		$expire = array_reduce($files, function(bool $carry, File $file) use ($time) {
79
-			return $carry && $file->getMTime() < $time;
80
-		}, $initial);
81
-
82
-		if ($expire) {
83
-			$uploadFolder->delete();
84
-			$this->jobList->remove(self::class, $argument);
85
-		}
86
-	}
39
+    /** @var IRootFolder */
40
+    private $rootFolder;
41
+
42
+    /** @var IJobList */
43
+    private $jobList;
44
+
45
+    public function __construct(ITimeFactory $time, IRootFolder $rootFolder, IJobList $jobList) {
46
+        parent::__construct($time);
47
+        $this->rootFolder = $rootFolder;
48
+        $this->jobList = $jobList;
49
+
50
+        // Run once a day
51
+        $this->setInterval(60*60*24);
52
+    }
53
+
54
+    protected function run($argument) {
55
+        $uid = $argument['uid'];
56
+        $folder = $argument['folder'];
57
+
58
+        try {
59
+            $userFolder = $this->rootFolder->getUserFolder($uid);
60
+            $userRoot = $userFolder->getParent();
61
+            /** @var Folder $uploads */
62
+            $uploads = $userRoot->get('uploads');
63
+            /** @var Folder $uploadFolder */
64
+            $uploadFolder = $uploads->get($folder);
65
+        } catch (NotFoundException $e) {
66
+            $this->jobList->remove(self::class, $argument);
67
+            return;
68
+        }
69
+
70
+        $files = $uploadFolder->getDirectoryListing();
71
+
72
+        // Remove if all files have an mtime of more than a day
73
+        $time = $this->time->getTime() - 60 * 60 * 24;
74
+
75
+        // The folder has to be more than a day old
76
+        $initial = $uploadFolder->getMTime() < $time;
77
+
78
+        $expire = array_reduce($files, function(bool $carry, File $file) use ($time) {
79
+            return $carry && $file->getMTime() < $time;
80
+        }, $initial);
81
+
82
+        if ($expire) {
83
+            $uploadFolder->delete();
84
+            $this->jobList->remove(self::class, $argument);
85
+        }
86
+    }
87 87
 
88 88
 }
Please login to merge, or discard this patch.