Code Duplication    Length = 4-7 lines in 4 locations

lib/private/Installer.php 4 locations

@@ 96-102 (lines=7) @@
93
		$appId = OC_App::cleanAppId($info['id']);
94
		$basedir = OC_App::getInstallPath().'/'.$appId;
95
		//check if the destination directory already exists
96
		if(is_dir($basedir)) {
97
			OC_Helper::rmdirr($extractDir);
98
			if($data['source']=='http') {
99
				unlink($path);
100
			}
101
			throw new \Exception($l->t("App directory already exists"));
102
		}
103
104
		if(!empty($data['pretent'])) {
105
			return false;
@@ 118-121 (lines=4) @@
115
		}
116
117
		$extractDir .= '/' . $info['id'];
118
		if(!file_exists($extractDir)) {
119
			OC_Helper::rmdirr($basedir);
120
			throw new \Exception($l->t("Archive does not contain a directory named %s", $info['id']));
121
		}
122
		OC_Helper::copyr($extractDir, $basedir);
123
124
		//remove temporary files
@@ 312-318 (lines=7) @@
309
		mkdir($extractDir);
310
		if($archive=\OC\Archive\Archive::open($path)) {
311
			$archive->extract($extractDir);
312
		} else {
313
			OC_Helper::rmdirr($extractDir);
314
			if($data['source']=='http') {
315
				unlink($path);
316
			}
317
			throw new \Exception($l->t("Failed to open archive when installing app"));
318
		}
319
320
		return [
321
			$extractDir,
@@ 351-357 (lines=7) @@
348
				}
349
			}
350
		}
351
		if(!is_file($extractDir.'/appinfo/info.xml')) {
352
			OC_Helper::rmdirr($extractDir);
353
			if($data['source'] === 'http') {
354
				unlink($path);
355
			}
356
			throw new \Exception($l->t("App does not provide an info.xml file"));
357
		}
358
359
		$info = OC_App::getAppInfo($extractDir.'/appinfo/info.xml', true);
360
		if(!is_array($info)) {