<commit_before><?php

OCP\JSON::checkLoggedIn();
\OC::$session->close();

// Load the files
$dir = isset( $_GET['dir'] ) ? $_GET['dir'] : '';
$dir = \OC\Files\Filesystem::normalizePath($dir);
$dirInfo = \OC\Files\Filesystem::getFileInfo($dir);
if (!$dirInfo->getType() === 'dir') {
	header("HTTP/1.0 404 Not Found");
	exit();
}

$data = array();
$baseUrl = OCP\Util::linkTo('files', 'index.php') . '?dir=';

$permissions = $dirInfo->getPermissions();

// make filelist
$files = \OCA\Files\Helper::getFiles($dir);

$data['directory'] = $dir;
$data['files'] = \OCA\Files\Helper::formatFileInfos($files);
$data['permissions'] = $permissions;

OCP\JSON::success(array('data' => $data));<commit_msg>Fixed dirInfo check for non existing dir in files ajax call<commit_after><?php

OCP\JSON::checkLoggedIn();
\OC::$session->close();

// Load the files
$dir = isset( $_GET['dir'] ) ? $_GET['dir'] : '';
$dir = \OC\Files\Filesystem::normalizePath($dir);
$dirInfo = \OC\Files\Filesystem::getFileInfo($dir);
if (!$dirInfo || !$dirInfo->getType() === 'dir') {
	header("HTTP/1.0 404 Not Found");
	exit();
}

$data = array();
$baseUrl = OCP\Util::linkTo('files', 'index.php') . '?dir=';

$permissions = $dirInfo->getPermissions();

// make filelist
$files = \OCA\Files\Helper::getFiles($dir);

$data['directory'] = $dir;
$data['files'] = \OCA\Files\Helper::formatFileInfos($files);
$data['permissions'] = $permissions;

OCP\JSON::success(array('data' => $data));
{'fraction_non_alphanumeric': 0.24740843123704215, 'fraction_numerical': 0.006910850034554251, 'mean_word_length': 5.92822966507177, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 11, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '6239880', 'n_tokens_mistral': 534, 'n_tokens_neox': 538, 'n_words': 94}