Code Duplication    Length = 4-7 lines in 4 locations

lib/private/Installer.php 4 locations

@@ 100-106 (lines=7) @@
97
		}
98
		$basedir = "$appsFolder/$appId";
99
		//check if the destination directory already exists
100
		if(is_dir($basedir)) {
101
			OC_Helper::rmdirr($extractDir);
102
			if($data['source']=='http') {
103
				unlink($path);
104
			}
105
			throw new \Exception($l->t("App directory already exists"));
106
		}
107
108
		if(!empty($data['pretent'])) {
109
			return false;
@@ 123-126 (lines=4) @@
120
		}
121
122
		$extractDir .= '/' . $info['id'];
123
		if(!file_exists($extractDir)) {
124
			OC_Helper::rmdirr($basedir);
125
			throw new \Exception($l->t("Archive does not contain a directory named %s", $info['id']));
126
		}
127
		OC_Helper::copyr($extractDir, $basedir);
128
129
		//remove temporary files
@@ 290-296 (lines=7) @@
287
		mkdir($extractDir);
288
		if($archive=\OC\Archive\Archive::open($path)) {
289
			$archive->extract($extractDir);
290
		} else {
291
			OC_Helper::rmdirr($extractDir);
292
			if($data['source']=='http') {
293
				unlink($path);
294
			}
295
			throw new \Exception($l->t("Failed to open archive when installing app"));
296
		}
297
298
		return [
299
			$extractDir,
@@ 329-335 (lines=7) @@
326
				}
327
			}
328
		}
329
		if(!is_file($extractDir.'/appinfo/info.xml')) {
330
			OC_Helper::rmdirr($extractDir);
331
			if($data['source'] === 'http') {
332
				unlink($path);
333
			}
334
			throw new \Exception($l->t("App does not provide an info.xml file"));
335
		}
336
337
		$info = OC_App::getAppInfo($extractDir.'/appinfo/info.xml', true);
338
		if(!is_array($info)) {