Skip to content

Commit 8822522

Browse files
committed
remove redundant tree
1 parent bef79f4 commit 8822522

File tree

2 files changed

+16
-16
lines changed

2 files changed

+16
-16
lines changed

src/LfmPath.php

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -170,10 +170,11 @@ public function normalizeWorkingDir()
170170
*/
171171
public function sortByColumn($arr_items)
172172
{
173-
if ($this->helper->input('sort_type') === 'alphabetic') {
174-
$key_to_sort = 'name';
173+
$sort_by = $this->helper->input('sort_type');
174+
if (in_array($sort_by, ['name', 'time'])) {
175+
$key_to_sort = $sort_by;
175176
} else {
176-
$key_to_sort = 'time';
177+
$key_to_sort = 'name';
177178
}
178179

179180
uasort($arr_items, function ($a, $b) use ($key_to_sort) {

src/controllers/FolderController.php

Lines changed: 12 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -39,21 +39,20 @@ public function getAddfolder()
3939
{
4040
$folder_name = $this->helper->input('name');
4141

42-
if (empty($folder_name)) {
43-
return parent::error('folder-name');
44-
} elseif ($this->lfm->setName($folder_name)->exists()) {
45-
return parent::error('folder-exist');
46-
} elseif (config('lfm.alphanumeric_directory') && preg_match('/[^\w-]/i', $folder_name)) {
47-
return parent::error('folder-alnum');
48-
} else {
49-
$this->lfm->setName($folder_name)->createFolder();
42+
try {
43+
if (empty($folder_name)) {
44+
return $this->helper->error('folder-name');
45+
} elseif ($this->lfm->setName($folder_name)->exists()) {
46+
return $this->helper->error('folder-exist');
47+
} elseif (config('lfm.alphanumeric_directory') && preg_match('/[^\w-]/i', $folder_name)) {
48+
return $this->helper->error('folder-alnum');
49+
} else {
50+
$this->lfm->setName($folder_name)->createFolder();
51+
}
52+
} catch (\Exception $e) {
53+
return $e->getMessage();
5054
}
5155

52-
if (config('lfm.alphanumeric_directory') && preg_match('/[^\w-]/i', $folder_name)) {
53-
return parent::error('folder-alnum');
54-
}
55-
56-
parent::createFolderByPath($path);
5756
return parent::$success_response;
5857
}
5958
}

0 commit comments

Comments
 (0)