Skip to content

Commit

Permalink
v2.0.2
Browse files Browse the repository at this point in the history
  • Loading branch information
ctf0 committed Oct 31, 2017
1 parent cbc8d5b commit 8684e2e
Show file tree
Hide file tree
Showing 4 changed files with 28 additions and 28 deletions.
7 changes: 0 additions & 7 deletions logs/v2.0.1.txt

This file was deleted.

7 changes: 7 additions & 0 deletions logs/v2.0.2.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
- add support for file restriction using extension
- add MMFileMoved event
- change preview modal name
- fix folder count “+1” on folder move update
- update assets
- update readme
- update wiki
23 changes: 12 additions & 11 deletions src/Controllers/MediaController.php
Original file line number Diff line number Diff line change
Expand Up @@ -236,37 +236,38 @@ public function move_file(Request $request)
}

foreach ($request->moved_files as $one) {
$file_type = $one['type'];
$file_name = $one['name'];
$file_size = $one['size'];
$file_type = $one['type'];
$file_name = $one['name'];
$file_size = $one['size'];
$file_items = isset($one['items']) ? $one['items'] : 0;

$destination = "{$request->destination}/$file_name";
$old_path = "$folderLocation/$file_name";
$new_path = true == strpos($destination, '../')
? '/' . dirname($folderLocation) . '/' . str_replace('../', '', $destination)
: "$folderLocation/$destination";

$pattern = [
'/[[:alnum:]]+\/\.\.\/\//' => '',
'/\/\//' => '/',
];
$new_path = preg_replace(array_keys($pattern), array_values($pattern), $new_path);

try {
if (!file_exists($new_path)) {
if ($this->storageDisk->move($old_path, $new_path)) {
$result[] = [
'success' => true,
'name' => $one['name'],
'items' => $file_items,
'type' => $file_type,
'size' => $file_size,
];

$pattern= [
'/[a-zA-Z]+\/\.\.\/\//'=> '',
'/\/\//' => '/',
];

$final = preg_replace(array_keys($pattern), array_values($pattern), $new_path);

// fire event
event('MMFileMoved', [
'old' => $this->getFilePath($this->fileSystem, $old_path),
'new' => $this->getFilePath($this->fileSystem, $final),
'new' => $this->getFilePath($this->fileSystem, $new_path),
]);
} else {
throw new Exception(trans('MediaManager::messages.error_moving'));
Expand Down
19 changes: 9 additions & 10 deletions src/resources/assets/js/components/mixins/form.js
Original file line number Diff line number Diff line change
Expand Up @@ -162,18 +162,17 @@ export default {

this.showNotif(`Successfully moved "${item.name}" to "${destination}"`)
this.removeFromLists(item.name)
this.updateFolderCount(destination, 1, item.size)

// update dirs list after move
if (item.type.includes('folder')) {
this.updateDirsList()
}
})
// update folder count when folder is moved into another
if (this.fileTypeIs(item, 'folder')) {
if (item.items > 0) {
this.updateFolderCount(destination, item.items, item.size)
}

// update folder count when folder is moved into another
files.map((e) => {
if (e.items && e.items > 0) {
this.updateFolderCount(destination, e.items)
// update dirs list after move
this.updateDirsList()
} else {
this.updateFolderCount(destination, 1, item.size)
}
})

Expand Down

0 comments on commit 8684e2e

Please sign in to comment.