- zip folder fix for sisters directories

This commit is contained in:
Peter Papp
2021-01-17 13:30:18 +01:00
parent 77b126b85a
commit e0f192777f
2 changed files with 16 additions and 9 deletions

View File

@@ -742,27 +742,34 @@ function remove_accents($string) {
* Get all files from folder and get their folder location in VueFileManager directories * Get all files from folder and get their folder location in VueFileManager directories
* *
* @param $folders * @param $folders
* @param array $files * @param null $files
* @param array $path * @param array $path
* @return array * @return array
*/ */
function get_files_for_zip($folders, $files = [], $path = []) function get_files_for_zip($folders, $files, $path = [])
{ {
// Return file list // Return file list
if (!isset($folders->folders)) { if (!isset($folders->folders)) {
return $files; return $files->unique()->values()->all();
} }
// Push path // Push file path
array_push($path, $folders->name); array_push($path, $folders->name);
// Write file list // Push file to collection
foreach ($folders->files as $file) { $folders->files->each(function ($file) use ($files, $path) {
array_push($files, [ $files->push([
'name' => $file->name, 'name' => $file->name,
'basename' => $file->basename, 'basename' => $file->basename,
'folder_path' => implode('/', $path), 'folder_path' => implode('/', $path),
]); ]);
});
// Get all children folders and folders within
if ($folders->folders->isNotEmpty()) {
$folders->folders->map(function ($folder) use ($files, $path) {
return get_files_for_zip($folder, $files, $path);
});
} }
return get_files_for_zip($folders->folders->first(), $files, $path); return get_files_for_zip($folders->folders->first(), $files, $path);

View File

@@ -30,6 +30,7 @@ class Editor
* Zip requested folder * Zip requested folder
* *
* @param $unique_id * @param $unique_id
* @param $shared
* @return mixed * @return mixed
* @throws \Illuminate\Contracts\Filesystem\FileNotFoundException * @throws \Illuminate\Contracts\Filesystem\FileNotFoundException
*/ */
@@ -42,8 +43,7 @@ class Editor
->with('folders') ->with('folders')
->first(); ->first();
$files = get_files_for_zip($requested_folder, collect([]));
$files = get_files_for_zip($requested_folder);
// Local storage instance // Local storage instance
$disk_local = Storage::disk('local'); $disk_local = Storage::disk('local');